@@ -248,8 +248,6 @@ struct GpuReductionAttr{
248
248
struct GpuReduction {
249
249
/* Function Arguments. */
250
250
GpuReductionAttr grAttr ;
251
- gpucontext * gpuCtx ;
252
- ga_reduce_op op ;
253
251
int nds ;
254
252
int ndd ;
255
253
int ndr ;
@@ -651,6 +649,8 @@ GPUARRAY_PUBLIC void GpuReductionAttr_free (GpuReductionAttr*
651
649
}
652
650
GPUARRAY_PUBLIC int GpuReduction_new (GpuReduction * * gr ,
653
651
const GpuReductionAttr * grAttr ){
652
+ GpuReduction * grOut = NULL ;
653
+
654
654
if (!gr ){
655
655
return GA_INVALID_ERROR ;
656
656
}
@@ -659,16 +659,14 @@ GPUARRAY_PUBLIC int GpuReduction_new (GpuReduction**
659
659
return GA_INVALID_ERROR ;
660
660
}
661
661
662
- * gr = calloc (1 , sizeof (* * gr ));
663
- if (* gr ){
664
- (* gr )-> grAttr = * grAttr ;
665
- (* gr )-> gpuCtx = grAttr -> gpuCtx ;
666
- (* gr )-> op = grAttr -> op ;
667
- (* gr )-> nds = (int )grAttr -> maxSrcDims ;
668
- (* gr )-> ndd = (int )grAttr -> maxDstDims ;
669
- (* gr )-> ndr = (int )(grAttr -> maxSrcDims - grAttr -> maxDstDims );
662
+ grOut = calloc (1 , sizeof (* grOut ));
663
+ if (grOut ){
664
+ grOut -> grAttr = * grAttr ;
665
+ grOut -> nds = (int )grAttr -> maxSrcDims ;
666
+ grOut -> ndd = (int )grAttr -> maxDstDims ;
667
+ grOut -> ndr = (int )(grAttr -> maxSrcDims - grAttr -> maxDstDims );
670
668
671
- return reduxGenInit (* gr );
669
+ return reduxGenInit (grOut );
672
670
}else {
673
671
return GA_MEMORY_ERROR ;
674
672
}
@@ -683,7 +681,8 @@ GPUARRAY_PUBLIC int GpuReduction_call (const GpuReduction*
683
681
unsigned reduxLen ,
684
682
const int * reduxList ,
685
683
int flags ){
686
- redux_ctx ctxSTACK , * ctx = & ctxSTACK ;
684
+ redux_ctx ctxSTACK ;
685
+ redux_ctx * ctx = & ctxSTACK ;
687
686
memset (ctx , 0 , sizeof (* ctx ));
688
687
689
688
ctx -> gr = gr ;
@@ -712,8 +711,7 @@ GPUARRAY_PUBLIC int GpuReduction_call (const GpuReduction*
712
711
*/
713
712
714
713
static int reduxGetSumInit (int typecode , const char * * property ){
715
- if (typecode == GA_POINTER ||
716
- typecode == GA_BUFFER ){
714
+ if (typecode < 0 ){
717
715
return GA_UNSUPPORTED_ERROR ;
718
716
}
719
717
* property = "0" ;
@@ -732,8 +730,7 @@ static int reduxGetSumInit (int typecode, const char**
732
730
*/
733
731
734
732
static int reduxGetProdInit (int typecode , const char * * property ){
735
- if (typecode == GA_POINTER ||
736
- typecode == GA_BUFFER ){
733
+ if (typecode < 0 ){
737
734
return GA_UNSUPPORTED_ERROR ;
738
735
}
739
736
* property = "1" ;
@@ -941,8 +938,7 @@ static int reduxGetMaxInit (int typecode, const char**
941
938
*/
942
939
943
940
static int reduxGetAndInit (int typecode , const char * * property ){
944
- if (typecode == GA_POINTER ||
945
- typecode == GA_BUFFER ){
941
+ if (typecode < 0 ){
946
942
return GA_UNSUPPORTED_ERROR ;
947
943
}
948
944
* property = "~0" ;
@@ -961,8 +957,7 @@ static int reduxGetAndInit (int typecode, const char**
961
957
*/
962
958
963
959
static int reduxGetOrInit (int typecode , const char * * property ){
964
- if (typecode == GA_POINTER ||
965
- typecode == GA_BUFFER ){
960
+ if (typecode < 0 ){
966
961
return GA_UNSUPPORTED_ERROR ;
967
962
}
968
963
* property = "0" ;
@@ -2858,7 +2853,7 @@ static int reduxGenCompile (GpuReduction* gr){
2858
2853
}
2859
2854
2860
2855
ret = GpuKernel_init (& gr -> k ,
2861
- gr -> gpuCtx ,
2856
+ gr -> grAttr . gpuCtx ,
2862
2857
1 ,
2863
2858
(const char * * )& gr -> kSourceCode ,
2864
2859
& gr -> kSourceCodeLen ,
@@ -3985,7 +3980,7 @@ static int reduxInvSchedule (redux_ctx* ctx){
3985
3980
ctx -> W0Off = reduxGenGetWMEMK0Off (ctx -> gr , 2 * ctx -> gs * ctx -> D );
3986
3981
ctx -> W1Off = reduxGenGetWMEMK1Off (ctx -> gr , 2 * ctx -> gs * ctx -> D );
3987
3982
WSPACESIZE = reduxGenGetWMEMSize (ctx -> gr , 2 * ctx -> gs * ctx -> D );
3988
- ctx -> W = gpudata_alloc (ctx -> gr -> gpuCtx , WSPACESIZE , 0 , flags , 0 );
3983
+ ctx -> W = gpudata_alloc (ctx -> gr -> grAttr . gpuCtx , WSPACESIZE , 0 , flags , 0 );
3989
3984
if (!ctx -> W ){
3990
3985
return reduxInvCleanupMsg (ctx , GA_MEMORY_ERROR ,
3991
3986
"Could not allocate %zu-byte workspace for reduction!\n" ,
0 commit comments