[SciPy-user] some benchmark data for numarray, Numeric and scipy-newcore

Ted Horst ted.horst at earthlink.net
Mon Dec 5 03:24:52 EST 2005


On Dec 4, 2005, at 16:57, Travis Oliphant wrote:

> The other issue of vector-vector and vector-scalar operations, I'm less
> convinced about.   Do we really need a whole other class of functions 
> in
> the ufunc machinery.   If so, I'm inclined to included them in the math
> operations for array-scalars, rather than the ufunc machinery.

The thing that led me to this was that scipy was spending a lot more 
time in DOUBLE_multiply than numarray was spending in 
multiply_ddxd_vvxv.  Since the functions are equivalent, 
DOUBLE_multiply must be getting called more than multiply_ddxd_vvxv.  
My first guess was that this was because in numarray vetcor-scalar 
multiplies were going through multiply_ddxd_svxv.  I tried to add a 
test for that by changing (the source to) DOUBLE_multiply to the 
following:

/**begin repeat

#TYP=FLOAT,DOUBLE,LONGDOUBLE#
#typ=float,double,longdouble#
*/
static void
@TYP at _multiply(char **args, intp *dimensions, intp *steps, void *func)
{
	register intp i;
	intp is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];
	char *i1=args[0], *i2=args[1], *op=args[2];
	/* fprintf(stderr, "Multiplying %d elements of type @typ@\n", n);
	fprintf(stderr, "args= %p, %p, %p\n", i1, i2, op);
	fprintf(stderr, "steps=%d, %d, %d\n", is1, is2, os); */
	if (is1 == 0) {
		@typ@ temp = *(@typ@ *)i1;
		for(i=0; i<n; i++, i2+=is2, op+=os) {
			*((@typ@ *)op)=temp * *((@typ@ *)i2);
		}
	}
	else if (is2 == 0) {
		@typ@ temp = *(@typ@ *)i2;
		for(i=0; i<n; i++, i1+=is1, op+=os) {
			*((@typ@ *)op)=temp * *((@typ@ *)i1);
		}
	}
	else {
		for(i=0; i<n; i++, i1+=is1, i2+=is2, op+=os) {
			*((@typ@ *)op)=*((@typ@ *)i1) * *((@typ@ *)i2);
		}
	}
}
/**end repeat**/

But there was still a lot of time spent in the else clause even when I 
was only testing scalar-vector multiplication.  I think this has 
something to do with the ufunc buffers and broadcasting, but I got a 
bit lost at this point.

Another observation is that scipy's LONG_remainder is much slower than 
numarray's remainder_iixi_vsxv.  LONG_remainder calculates the 
remainder using floating point math whereas numarray just uses the C % 
operator.

Hope this is useful.

Ted




More information about the SciPy-User mailing list