00001 #include <parallel_reduce.h> 00002 #include <parallel_utils.h> 00003 00004 namespace parallel_ode 00005 { 00006 00007 using ::parallel_utils::fillSequentialVector; 00008 using ::parallel_utils::fillStridedVector; 00009 using ::parallel_utils::iPower2Up; 00010 00011 void ReduceStrategy::initialize( int bodySize, int maxBodyRepetitionCount, const IntVector& batchRepetitionCount ) 00012 { 00013 setBodySize( bodySize ); 00014 setBodySizeWithReduction( bodySize ); 00015 setBodyStride( 1 ); 00016 setBodyOffsetStride( 0 ); 00017 } 00018 00020 00021 void SequentialReduceStrategy::initialize( int bodySize, int maxBodyRepetitionCount, const IntVector& batchRepetitionCount ) 00022 { 00023 setBodySize( bodySize ); 00024 setBodyStride( iPower2Up( maxBodyRepetitionCount ) ); 00025 setBodySizeWithReduction( getBodyStride( ) * getBodySize( ) ); 00026 setBodyOffsetStride( 1 ); 00027 } 00028 00030 00031 void StridedReduceStrategy::initialize( int bodySize, int maxBodyRepetitionCount, const IntVector& batchRepetitionCount ) 00032 { 00033 setBodySize( bodySize ); 00034 setBodyOffsetStride( alignDefaultSize( getBodySize( ) ) ); 00035 setBodySizeWithReduction( getBodyOffsetStride( ) * maxBodyRepetitionCount ); 00036 setBodyStride( 1 ); 00037 } 00038 00040 00041 void CompactReduceStrategy::initialize( int bodySize, int maxBodyRepetitionCount, const IntVector& batchRepetitionCount ) 00042 { 00043 setBodySize( bodySize ); 00044 int tempReductionSize = 0; 00045 for(size_t batchID = 0; batchID < batchRepetitionCount.size( ); ++batchID) { 00046 tempReductionSize += batchRepetitionCount[ batchID ]; 00047 } 00048 setBodySizeWithReduction( tempReductionSize ); 00049 setBodyStride( -1 ); 00050 setBodyOffsetStride( 1 ); 00051 } 00052 00053 }