From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31262 invoked by alias); 4 Nov 2006 21:24:32 -0000 Received: (qmail 31245 invoked by uid 48); 4 Nov 2006 21:24:24 -0000 Date: Sat, 04 Nov 2006 21:24:00 -0000 Message-ID: <20061104212424.31244.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug fortran/29549] matmul slow for complex matrices In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "jb at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-11/txt/msg00296.txt.bz2 List-Id: ------- Comment #3 from jb at gcc dot gnu dot org 2006-11-04 21:24 ------- Well, redoing the C benchmark above to use 1d arrays and manual index calculations, the results are now essentially the same as for the Fortran version. And a commercial compiler produces about the same results for the Fortran version as gfortran, which means the reason for our poor complex matmul performance lies elsewhere. #include #include #include #include #include int main(void) { int n = 300; complex float *a, *b, *c; int i, j, k, tc; a = malloc (n*n * sizeof (*a)); b = malloc (n*n * sizeof (*b)); c = malloc (n*n * sizeof (*c)); struct timeval tv, tv2; float res; FILE *fp; tc = 0; for (i = 0; i < n*n; i++) { a[i] = i*10.0 + 100.0*I; b[i] = 1.0 + 42.0*I; c[i] = 0.0 + 0.0*I; } gettimeofday (&tv, NULL); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { c[i*n + j] = 0.0 + 0.0*I; for (k = 0; k < n; k++) { c[i*n + j] = c[i*n + j] + a[i*n + k] * b[k*n + j]; tc++; } } } gettimeofday (&tv2, NULL); res = tv2.tv_sec - tv.tv_sec + (tv2.tv_usec - tv.tv_usec) / 1000000.0; printf ("gemm time: %f\n", res); fp = fopen ("c-matrix", "w"); for (i = 0; i < n; i++) { for (j = 0; j