PDA

View Full Version : Extending the Reduction Operations


BioASC
12-17-2007, 07:01 AM
I've been playing around with the reduction files located in /opt/clearspeed/csx600_m512_le/src/cs_reduction directory (using the Beta SDK).

I need an integer reduction similar to the double and float reductions. This will be used to develop other "fundamental operations" for the model I'm working on mapping onto the CS X620 board.

I've copied the reduction_float.cn to reduction_int.cn and changed all references from float to int, but I've done this in my local directory. I also changed the

#include "../include/reduction.h"
to
#include <reduction.h>

I'm not sure how to compile / link / and run it to test it out from my local directory since I do not have root access. The file will compile with the -S (compile only) option to produce a .is file. If I try to run cscn without any options, it produces a linking error.

Any input on how to test / use a "customized" reduction operator is welcomed! I feel like I'm missing an obvious answer.

Dangermouse
12-17-2007, 08:52 PM
Hi BioASC.

The approach you suggested should work and indeed for me it compiled and linked ok. Can you copy and paste the link error please?

As a simple test for your integer reduction you could create a poly int variable and assign with the PE number (get_penum()) and then try the reduction.

BioASC
12-18-2007, 12:38 AM
When I try to compile with or without the -l option for the cn_reduction library for the original file float version or for the new int version of the file,

cscn reduction_int.cn
cscn reduction_float.cn
cscn -lcn_reduction reduction_int.cn

They all produce the following error:

-----------------
ERROR: 1 undefined external symbol(s) found. Use -y option to trace where they were referenced.
main

1 error(s).

Link failed.
-----------------

I'm not sure if there are any options that I need to include on the compile to have it link properly.
Thanks.

Dangermouse
12-18-2007, 10:19 AM
Since you are implementing your own reduction routine you should not need to link with cn_reduction (which provides the float and double __cs_reduce_... routines).


ERROR: 1 undefined external symbol(s) found. Use -y option to trace where they were referenced.
main


You'll need to include a main().


#include <stdio.h>
#include <misc.h>

mono int reduce_mono_sum_int(poly int);

int main(void)
{
mono int value;
poly int valuep;

valuep = get_penum();
value = reduce_mono_sum_int(valuep);
printf("Completed reduction, result is %d.\n", value);
return 0;
}

Solomon
12-18-2007, 10:24 AM
This is a standard C issue - not particular to ClearSpeed.

missing main() means that the source code you compiled only contains functions/subroutines and no main program (cf PROGRAM in Fortran).

You could compile this file with with -c but really you probably want to compile your Cn test program - the one that calls the reduction function i.e. the one that #include's reduction_float.cn

The files in $CSHOME/src/cs_reduction are just the functions themselves - there aren't any example programs that call these functions.


By the way can you say any more about your Reduction needs:

1. Do you want to sum the integer - or find the product/maximum/minimum, ...?
2. Are these 32-bit integers to would less bits do - say 16 bit or 8 bit? (note that the ClearSpeed chip has special hardware for one-bit AND or OR)
3. Do you have to reduce one number at a time or can you batch them up? (I have code that does 3 doubles at a time - this takes less than 10% longer than doing just one double - and indeed 96 numbers per PE can probably be done in the not much more that 6x this time)


Hope this helps,
Solomon