X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/00f2021a5b4cf37f52dab7839d0d29505a60e673..777919eabc0add61d461c886c434ae6ca1ba4d34:/examples/smpi/gemm/gemm.c diff --git a/examples/smpi/gemm/gemm.c b/examples/smpi/gemm/gemm.c index 3aedd0942c..b9f0635d70 100644 --- a/examples/smpi/gemm/gemm.c +++ b/examples/smpi/gemm/gemm.c @@ -15,29 +15,29 @@ #include #include -void multiply(float* a, float* b, float* c, int istart, int iend, int size); -void multiply_sampled(float* a, float* b, float* c, int istart, int iend, int size); - - -void multiply(float* a, float* b, float* c, int istart, int iend, int size) +static void multiply(const float* a, const float* b, float* c, int istart, int iend, int size) { for (int i = istart; i <= iend; ++i) { for (int j = 0; j < size; ++j) { - for (int k = 0; k < size; ++k) { - c[i*size+j] += a[i*size+k] * b[k*size+j]; - } + float sum = 0.0; + for (int k = 0; k < size; ++k) { + sum += a[i * size + k] * b[k * size + j]; + } + c[i * size + j] += sum; } } } -void multiply_sampled(float* a, float* b, float* c, int istart, int iend, int size) +static void multiply_sampled(const float* a, const float* b, float* c, int istart, int iend, int size) { //for (int i = istart; i <= iend; ++i) { SMPI_SAMPLE_GLOBAL (int i = istart, i <= iend, ++i, 10, 0.005){ for (int j = 0; j < size; ++j) { - for (int k = 0; k < size; ++k) { - c[i*size+j] += a[i*size+k] * b[k*size+j]; - } + float sum = 0.0; + for (int k = 0; k < size; ++k) { + sum += a[i * size + k] * b[k * size + j]; + } + c[i * size + j] += sum; } } }