From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111c93,42147f5b2d81aa51 X-Google-Attributes: gid111c93,public From: Alex Rhomberg Subject: Re: optimized (or optimizable) C programming? Date: 1999/10/05 Message-ID: <37FA0D1B.BF58B3D4@ife.ee.ethz.ch>#1/1 X-Deja-AN: 533090834 Content-Transfer-Encoding: 7bit References: <37F8AC50.13AA8F7D@ife.ee.ethz.ch> Content-Type: text/plain; charset=us-ascii X-Trace: 5 Oct 1999 16:37:15 +0100, beethoven.ee.ethz.ch Organization: Electronics Lab, ETH Zurich, Switzerland MIME-Version: 1.0 Newsgroups: comp.os.linux.alpha Robert Harley wrote: > > Alex Rhomberg writes: > > void test2 (double *fmat_lin, const double *x, const double *dhdX0_lin) > > If you know that fmat_lin doesn't overlap with the others you can mark > it with __restrict in ccc and in the latest gcc. > #define RESTRICT __restrict > void test2 > ( double * RESTRICT fmat_lin, const double *x, const double *dhdX0_lin ) { This doesn't seem to make a difference: =cut thistest.c void scatter( double * __restrict dforce, double * df_el, int *nodeI) { int thisnode; int jE_node; for (jE_node = 0; jE_node < 8; jE_node++) /* scatter internal force*/ { thisnode = nodeI[jE_node]*3;/*will be replaced by pointers*/ dforce[thisnode+0] -= df_el[jE_node*3+0]; dforce[thisnode+1] -= df_el[jE_node*3+1]; dforce[thisnode+2] -= df_el[jE_node*3+2]; } } =cut commands ccc -fast -std1 -c thistest.c -o ttt.o # both -std1 and __restrict should tell the # compiler that inputs don't overlap objdump -rd ttt.o | more =cut part of output, annotated 9c: 00 00 88 8e ldt $f20,0(t7) a0: d0 ff b1 8e ldt $f21,-48(a1) a4: 34 14 95 5a subt $f20,$f21,$f20 #first wait for $f21 a8: 00 00 88 9e stt $f20,0(t7) #wait for fadd latency ac: 08 00 c8 8e ldt $f22,8(t7) b0: d8 ff f1 8e ldt $f23,-40(a1) b4: 36 14 d7 5a subt $f22,$f23,$f22 #sleep(2) b8: 08 00 c8 9e stt $f22,8(t7) #drink_coffee =cut comment It gets better if I restrict ALL the parameters - Alex