toi or not toi? Performance is the question on testfor.sac
Extended Description
Created an attachment (id=641)
Source code to reproduce fault
The attached code runs like dirt when compiled with the specified options below.
The numbers at the right are PAPI instruction counts:
sac2c -extrema -nowlf -doawlf crud.sac
crud.sac.exe.awlf.16700:MODIFIED.papiex.rattler.13222:PAPI_TOT_INS: 42043251277
sac2c -extrema -nowlf -doawlf crud.sac -DFAST
crud.sac.exe.awlf.16700:MODIFIED.papiex.rattler.13257:PAPI_TOT_INS: 87605002
sac2c crud.sac
crud.sac.exe.O3.16700:MODIFIED.papiex.rattler.13193:PAPI_TOT_INS: 163515463
sac2c crud.sac -DFAST
crud.sac.exe.O3.16700:MODIFIED.papiex.rattler.13284:PAPI_TOT_INS: 163515474
What is odd is the effect of the -DFAST on indexed assign. X is a rank-2 array,
and it's already int[+].
inline int[+] inds0(int[+] X, int I0, int Y)
{
#define FAST
#ifdef FAST
z = X;
#else // FAST
z = toi(X);
#endif // FAST
z[[I0]]=toi(Y);
return(z);
}
sac2c -V
sac2c v1.00-beta (Haggis And Apple)
product rev 16700:MODIFIED linux-gnu_x86_64
(Mon Jan 4 10:48:51 EST 2010 by sac)
Needless to say, this has a wee impact on performance...