@@ -248,8 +248,6 @@ struct GpuReductionAttr{
248248struct GpuReduction {
249249 /* Function Arguments. */
250250 GpuReductionAttr grAttr ;
251- gpucontext * gpuCtx ;
252- ga_reduce_op op ;
253251 int nds ;
254252 int ndd ;
255253 int ndr ;
@@ -652,6 +650,8 @@ GPUARRAY_PUBLIC void GpuReductionAttr_free (GpuReductionAttr*
652650}
653651GPUARRAY_PUBLIC int GpuReduction_new (GpuReduction * * gr ,
654652 const GpuReductionAttr * grAttr ){
653+ GpuReduction * grOut = NULL ;
654+
655655 if (!gr ){
656656 return GA_INVALID_ERROR ;
657657 }
@@ -660,16 +660,14 @@ GPUARRAY_PUBLIC int GpuReduction_new (GpuReduction**
660660 return GA_INVALID_ERROR ;
661661 }
662662
663- * gr = calloc (1 , sizeof (* * gr ));
664- if (* gr ){
665- (* gr )-> grAttr = * grAttr ;
666- (* gr )-> gpuCtx = grAttr -> gpuCtx ;
667- (* gr )-> op = grAttr -> op ;
668- (* gr )-> nds = (int )grAttr -> maxSrcDims ;
669- (* gr )-> ndd = (int )grAttr -> maxDstDims ;
670- (* gr )-> ndr = (int )(grAttr -> maxSrcDims - grAttr -> maxDstDims );
663+ grOut = calloc (1 , sizeof (* grOut ));
664+ if (grOut ){
665+ grOut -> grAttr = * grAttr ;
666+ grOut -> nds = (int )grAttr -> maxSrcDims ;
667+ grOut -> ndd = (int )grAttr -> maxDstDims ;
668+ grOut -> ndr = (int )(grAttr -> maxSrcDims - grAttr -> maxDstDims );
671669
672- return reduxGenInit (* gr );
670+ return reduxGenInit (grOut );
673671 }else {
674672 return GA_MEMORY_ERROR ;
675673 }
@@ -684,7 +682,8 @@ GPUARRAY_PUBLIC int GpuReduction_call (const GpuReduction*
684682 unsigned reduxLen ,
685683 const int * reduxList ,
686684 int flags ){
687- redux_ctx ctxSTACK , * ctx = & ctxSTACK ;
685+ redux_ctx ctxSTACK ;
686+ redux_ctx * ctx = & ctxSTACK ;
688687 memset (ctx , 0 , sizeof (* ctx ));
689688
690689 ctx -> gr = gr ;
@@ -713,8 +712,7 @@ GPUARRAY_PUBLIC int GpuReduction_call (const GpuReduction*
713712 */
714713
715714static int reduxGetSumInit (int typecode , const char * * property ){
716- if (typecode == GA_POINTER ||
717- typecode == GA_BUFFER ){
715+ if (typecode < 0 ){
718716 return GA_UNSUPPORTED_ERROR ;
719717 }
720718 * property = "0" ;
@@ -733,8 +731,7 @@ static int reduxGetSumInit (int typecode, const char**
733731 */
734732
735733static int reduxGetProdInit (int typecode , const char * * property ){
736- if (typecode == GA_POINTER ||
737- typecode == GA_BUFFER ){
734+ if (typecode < 0 ){
738735 return GA_UNSUPPORTED_ERROR ;
739736 }
740737 * property = "1" ;
@@ -942,8 +939,7 @@ static int reduxGetMaxInit (int typecode, const char**
942939 */
943940
944941static int reduxGetAndInit (int typecode , const char * * property ){
945- if (typecode == GA_POINTER ||
946- typecode == GA_BUFFER ){
942+ if (typecode < 0 ){
947943 return GA_UNSUPPORTED_ERROR ;
948944 }
949945 * property = "~0" ;
@@ -962,8 +958,7 @@ static int reduxGetAndInit (int typecode, const char**
962958 */
963959
964960static int reduxGetOrInit (int typecode , const char * * property ){
965- if (typecode == GA_POINTER ||
966- typecode == GA_BUFFER ){
961+ if (typecode < 0 ){
967962 return GA_UNSUPPORTED_ERROR ;
968963 }
969964 * property = "0" ;
@@ -2867,7 +2862,7 @@ static int reduxGenCompile (GpuReduction* gr){
28672862 }
28682863
28692864 ret = GpuKernel_init (& gr -> k ,
2870- gr -> gpuCtx ,
2865+ gr -> grAttr . gpuCtx ,
28712866 1 ,
28722867 (const char * * )& gr -> kSourceCode ,
28732868 & gr -> kSourceCodeLen ,
@@ -3994,7 +3989,7 @@ static int reduxInvSchedule (redux_ctx* ctx){
39943989 ctx -> W0Off = reduxGenGetWMEMK0Off (ctx -> gr , 2 * ctx -> gs * ctx -> D );
39953990 ctx -> W1Off = reduxGenGetWMEMK1Off (ctx -> gr , 2 * ctx -> gs * ctx -> D );
39963991 WSPACESIZE = reduxGenGetWMEMSize (ctx -> gr , 2 * ctx -> gs * ctx -> D );
3997- ctx -> W = gpudata_alloc (ctx -> gr -> gpuCtx , WSPACESIZE , 0 , flags , 0 );
3992+ ctx -> W = gpudata_alloc (ctx -> gr -> grAttr . gpuCtx , WSPACESIZE , 0 , flags , 0 );
39983993 if (!ctx -> W ){
39993994 return reduxInvCleanupMsg (ctx , GA_MEMORY_ERROR ,
40003995 "Could not allocate %zu-byte workspace for reduction!\n" ,
0 commit comments