# HG changeset patch # User Shohei KOKUBO # Date 1383472845 -32400 # Node ID 893353c014f59da6f917ebac597abe267ad637aa # Parent 6bd9a57eb44dc59127d3556d7d48c1f9e9ea58d2 run sort by ANY_ANY diff -r 6bd9a57eb44d -r 893353c014f5 example/fft/gpu/spinFact.cl --- a/example/fft/gpu/spinFact.cl Sat Nov 02 17:34:40 2013 +0900 +++ b/example/fft/gpu/spinFact.cl Sun Nov 03 19:00:45 2013 +0900 @@ -10,7 +10,6 @@ float2 angle; angle.x = (float)(2*i*PI/(float)n); angle.y = (float)((2*i*PI/(float)n) + PI_2); - w[i].x = cos(angle.x); w[i].y = cos(angle.y); } diff -r 6bd9a57eb44d -r 893353c014f5 example/fft/output.pgm Binary file example/fft/output.pgm has changed diff -r 6bd9a57eb44d -r 893353c014f5 example/many_task/Makefile.def --- a/example/many_task/Makefile.def Sat Nov 02 17:34:40 2013 +0900 +++ b/example/many_task/Makefile.def Sun Nov 03 19:00:45 2013 +0900 @@ -14,7 +14,7 @@ CFLAGS = -Wall $(OPT) -DUSE_SIMPLE_TASK CXXFLAGS = ${CFLAGS} -INCLUDE = -I${CERIUM}/include/TaskManager -I. -I.. +INCLUDE = -I. -I.. -I${CERIUM}/include/TaskManager LIBS = -L${CERIUM}/TaskManager ABIBIT = 64 diff -r 6bd9a57eb44d -r 893353c014f5 example/many_task/Makefile.gpu --- a/example/many_task/Makefile.gpu Sat Nov 02 17:34:40 2013 +0900 +++ b/example/many_task/Makefile.gpu Sun Nov 03 19:00:45 2013 +0900 @@ -14,7 +14,6 @@ CC += $(ABI) CFLAGS += -D__CERIUM_GPU__ -INCLUDE = -I${CERIUM}/include/TaskManager -I. -I.. LIBS = -L${CERIUM}/TaskManager -DUSE_SIMPLE_TASK -lGpuManager -framework opencl `sdl-config --libs` .SUFFIXES: .cc .o diff -r 6bd9a57eb44d -r 893353c014f5 example/many_task/Makefile.macosx --- a/example/many_task/Makefile.macosx Sat Nov 02 17:34:40 2013 +0900 +++ b/example/many_task/Makefile.macosx Sun Nov 03 19:00:45 2013 +0900 @@ -16,7 +16,7 @@ CC += $(ABI) # CFLAGS = -g -Wall# -O9 #-DDEBUG -INCLUDE = -I${CERIUM}/include/TaskManager -I. -I.. +INCLUDE = -I. -I.. -I${CERIUM}/include/TaskManager LIBS = -L${CERIUM}/TaskManager -lFifoManager `sdl-config --libs` .SUFFIXES: .cc .o diff -r 6bd9a57eb44d -r 893353c014f5 example/many_task/gpu/QuickSort.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/many_task/gpu/QuickSort.cc Sun Nov 03 19:00:45 2013 +0900 @@ -0,0 +1,103 @@ +#include "QuickSort.h" +#include +#include + +SchedDefineTask(QuickSort); + +static void quick_sort( Data *data, int begin, int end ) ; + +static void +swap( Data *data, int left, int right ) +{ + Data tmp = data[left]; + data[left] = data[right]; + data[right] = tmp; +} + +//#define USE_MEMCPY + +void +bubble_sort(Data *data, int begin, int end) +{ + for (int count=0;countcount;c--) { + if (data[c].indexread_size()/sizeof(Data); + Data *r_data = (Data*)rbuff; +#ifdef USE_MEMCPY + Data *w_data = (Data*)wbuff; +#endif +#else + int end = s->get_inputSize(0)/sizeof(Data); + DataPtr r_data = (DataPtr)s->get_input(0); +#ifdef USE_MEMCPY + DataPtr w_data = (DataPtr)s->get_output(0); +#endif +#endif + + // printf("[PPE] Quick: length:%d addr->%x \n",end, (int)rbuff); + // printf("[PPE] Quick: data[0]: %ld addr->%lx\n",sizeof(r_data),(long)r_data); + + quick_sort(r_data, begin, end); + +#ifdef USE_MEMCPY + memcpy(w_data, r_data, sizeof(Data)*end); +#else + s->swap(); +#endif + + return 0; +} + +void +qsort_test(Data *data, int begin, int end ) { + quick_sort(data, begin, end-1); +} + +static void +quick_sort( Data *data, int begin, int end ) { + int stack[1024]; + int sp = 0; + int p; + + while (1) { + while (begin < end) { + + if (end-begin <= 50) { + //bubble_sort(data, begin, end); + //break; + } + + int where = (begin + end) / 2; + int pivot = data[where].index; + data[where].index = data[begin].index; + int i; + p = begin; + for (i=begin+1; i<=end; i++) { + if (data[i].index < pivot) { + p++; + swap(data, p, i); + } + } + data[begin].index = data[p].index; + data[p].index = pivot; + + stack[sp++] = p + 1; + stack[sp++] = end; + end = p - 1; + } + if (sp == 0) return; + end = stack[--sp]; + begin = stack[--sp]; + begin = p + 1; + } +} +/* end */ diff -r 6bd9a57eb44d -r 893353c014f5 example/many_task/gpu/QuickSort.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/many_task/gpu/QuickSort.h Sun Nov 03 19:00:45 2013 +0900 @@ -0,0 +1,10 @@ +#ifndef INCLUDED_TASK_QUICKSORT +#define INCLUDED_TASK_QUICKSORT + +#ifndef INCLUDED_SCHED_TASK +# include "SchedTask.h" +#endif + +#include "sort.h" + +#endif diff -r 6bd9a57eb44d -r 893353c014f5 example/many_task/gpu/task_init.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/many_task/gpu/task_init.cc Sun Nov 03 19:00:45 2013 +0900 @@ -0,0 +1,21 @@ +#include "Func.h" +#include "Scheduler.h" +#include "GpuScheduler.h" + +SchedExternTask(QuickSort); +SchedExternTask(SortSimple); +SchedExternTask(SortCompat); + +void +task_init(void) +{ + SchedRegister(SortSimple); + SchedRegisterTask(QUICK_SORT, QuickSort); + // SchedRegister(SortCompat); +} + +void +gpu_task_init(void) +{ + GpuSchedRegister(QUICK_SORT,"gpu/QuickSort.cl","quick_sort"); +} diff -r 6bd9a57eb44d -r 893353c014f5 example/many_task/main.cc --- a/example/many_task/main.cc Sat Nov 02 17:34:40 2013 +0900 +++ b/example/many_task/main.cc Sun Nov 03 19:00:45 2013 +0900 @@ -9,6 +9,7 @@ #include "sort.h" extern void task_init(); +extern void gpu_task_init(); extern int get_split_num(int len, int num); @@ -67,6 +68,9 @@ use_task_array = 1; } + if (strcmp(argv[i], "-any") == 0 ) { + spe_cpu = ANY_ANY; + } } return 0; @@ -146,6 +150,7 @@ } task_init(); + gpu_task_init(); int cpu = manager->get_cpuNum(); // in case of -cpu 0 diff -r 6bd9a57eb44d -r 893353c014f5 example/many_task/ppe/task_init.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/many_task/ppe/task_init.cc Sun Nov 03 19:00:45 2013 +0900 @@ -0,0 +1,21 @@ +#include "Func.h" +#include "Scheduler.h" +#include "GpuScheduler.h" + +SchedExternTask(QuickSort); +SchedExternTask(SortSimple); +SchedExternTask(SortCompat); + +void +task_init(void) +{ + SchedRegisterTask(QUICK_SORT, QuickSort); + SchedRegister(SortSimple); + // SchedRegister(SortCompat); +} + +void +gpu_task_init(void) +{ + +} diff -r 6bd9a57eb44d -r 893353c014f5 example/many_task/task_init.cc --- a/example/many_task/task_init.cc Sat Nov 02 17:34:40 2013 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -#include "Func.h" -#include "Scheduler.h" -#include "GpuScheduler.h" - -#ifndef __CERIUM_GPU__ -SchedExternTask(QuickSort); -#endif // __CERIUM_GPU__ -SchedExternTask(SortSimple); -SchedExternTask(SortCompat); - -void -task_init(void) -{ -#ifdef __CERIUM_GPU__ - GpuSchedRegister(QUICK_SORT, "gpu/QuickSort.cl", "quick_sort"); -#else - SchedRegisterTask(QUICK_SORT, QuickSort); -#endif - - - SchedRegister(SortSimple); - // SchedRegister(SortCompat); -}