@@ -18,14 +18,7 @@ int mca_coll_solo_allreduce_intra(const void *sbuf, void *rbuf,
1818 struct ompi_communicator_t * comm ,
1919 mca_coll_base_module_t * module )
2020{
21- if (ompi_datatype_is_contiguous_memory_layout (dtype , count )) {
22- mca_coll_solo_allreduce_ring_intra_memcpy (sbuf , rbuf , count , dtype , op , comm , module );
23- }
24- else {
25- mca_coll_solo_allreduce_ring_intra_osc (sbuf , rbuf , count , dtype , op , comm , module );
26- }
27- return OMPI_SUCCESS ;
28-
21+ return mca_coll_solo_allreduce_ring_intra_memcpy (sbuf , rbuf , count , dtype , op , comm , module );
2922}
3023
3124
@@ -91,10 +84,7 @@ int mca_coll_solo_allreduce_ring_intra_memcpy(const void *sbuf, void *rbuf, int
9184 }
9285 } else {
9386 /* For the messages which are greater than mpool_large_block_size*np, invoke this reduce multiple times */
94- int seg_count = count ;
95- size_t typelng ;
96- ompi_datatype_type_size (dtype , & typelng );
97- COLL_BASE_COMPUTED_SEGCOUNT (mca_coll_solo_component .mpool_large_block_size , typelng , seg_count );
87+ int seg_count = mca_coll_solo_component .mpool_large_block_size / extent ;
9888 int num_segments = (count + seg_count - 1 ) / seg_count ;
9989 int last_count = count - seg_count * (num_segments - 1 );
10090 for (int i = 0 ; i < num_segments ; i ++ ) {
@@ -122,7 +112,7 @@ int mca_coll_solo_allreduce_ring_intra_memcpy(const void *sbuf, void *rbuf, int
122112 }
123113 /* At first iteration, copy local data to the solo data buffer */
124114 if (cur == rank ) {
125- memcpy ( data_bufs [ cur ], ( char * ) sbuf + cur * l_seg_count * extent , seg_count * extent );
115+ mca_coll_solo_copy (( void * ) (( char * ) sbuf + cur * l_seg_count * extent ), ( void * ) data_bufs [ cur ], dtype , seg_count , extent );
126116 mac_coll_solo_barrier_intra (comm , module );
127117
128118 }
@@ -147,7 +137,7 @@ int mca_coll_solo_allreduce_ring_intra_memcpy(const void *sbuf, void *rbuf, int
147137 } else {
148138 seg_count = count - i * l_seg_count ;
149139 }
150- memcpy (( char * ) c , data_bufs [i ], seg_count * extent );
140+ mca_coll_solo_copy (( void * ) data_bufs [i ], ( void * ) c , dtype , seg_count , extent );
151141 c = c + seg_count * extent ;
152142 }
153143 mac_coll_solo_barrier_intra (comm , module );
@@ -167,127 +157,4 @@ int mca_coll_solo_allreduce_ring_intra_memcpy(const void *sbuf, void *rbuf, int
167157
168158 }
169159 return OMPI_SUCCESS ;
170- }
171-
172- int mca_coll_solo_allreduce_ring_intra_osc (const void * sbuf , void * rbuf , int count ,
173- struct ompi_datatype_t * dtype ,
174- struct ompi_op_t * op ,
175- struct ompi_communicator_t * comm ,
176- mca_coll_base_module_t * module )
177- {
178- mca_coll_solo_module_t * solo_module = (mca_coll_solo_module_t * ) module ;
179- int size = ompi_comm_size (comm );
180- int rank = ompi_comm_rank (comm );
181- int i ;
182- ptrdiff_t extent , lower_bound ;
183- ompi_datatype_get_extent (dtype , & lower_bound , & extent );
184-
185- /* Enable solo module if necessary */
186- if (!solo_module -> enabled ) {
187- mca_coll_solo_lazy_enable (module , comm );
188- }
189-
190- /* Set up segment count */
191- int seg_count , l_seg_count ;
192- seg_count = count / size ;
193- l_seg_count = seg_count ;
194- if (rank == size - 1 ) {
195- seg_count = count - rank * l_seg_count ;
196- }
197-
198- char * * data_bufs = NULL ;
199- int id ;
200- MPI_Win cur_win ;
201- char * local_buf = NULL ;
202- if ((size_t ) l_seg_count * extent <= mca_coll_solo_component .static_block_size ) {
203- data_bufs = (char * * ) malloc (sizeof (char * ) * size );
204- for (i = 0 ; i < size ; i ++ ) {
205- data_bufs [i ] = (char * ) 0 + 4 * opal_cache_line_size ;
206- }
207- cur_win = solo_module -> static_win ;
208- } else if ((size_t ) l_seg_count * extent <= mca_coll_solo_component .mpool_large_block_size ) {
209- id = mca_coll_solo_mpool_request (mca_coll_solo_component .solo_mpool , l_seg_count * extent );
210- local_buf =
211- mca_coll_solo_mpool_calculate (mca_coll_solo_component .solo_mpool , id ,
212- l_seg_count * extent );
213- data_bufs = mca_coll_solo_attach_buf (solo_module , comm , local_buf , l_seg_count * extent );
214- cur_win = solo_module -> dynamic_win ;
215- } else {
216- /* For the messages which are greater than mpool_large_block_size*np, invoke this reduce multiple times */
217- int seg_count = count ;
218- size_t typelng ;
219- ompi_datatype_type_size (dtype , & typelng );
220- COLL_BASE_COMPUTED_SEGCOUNT (mca_coll_solo_component .mpool_large_block_size , typelng , seg_count );
221- int num_segments = (count + seg_count - 1 ) / seg_count ;
222- int last_count = count - seg_count * (num_segments - 1 );
223- for (int i = 0 ; i < num_segments ; i ++ ) {
224- char * temp_sbuf = (char * )sbuf + seg_count * extent * i ;
225- char * temp_rbuf = (char * )rbuf + seg_count * extent * i ;
226- int temp_count = seg_count ;
227- if (i == num_segments - 1 ) {
228- temp_count = last_count ;
229- }
230- mca_coll_solo_allreduce_ring_intra_osc (temp_sbuf , temp_rbuf , temp_count , dtype , op ,
231- comm , module );
232- }
233- return MPI_SUCCESS ;
234- }
235-
236- * (int * ) (solo_module -> ctrl_bufs [rank ]) = rank ;
237- mac_coll_solo_barrier_intra (comm , module );
238-
239- int cur = rank ;
240- for (i = 0 ; i < size ; i ++ ) {
241- if (cur != size - 1 ) {
242- seg_count = l_seg_count ;
243- } else {
244- seg_count = count - cur * l_seg_count ;
245- }
246- /* At first iteration, copy local data to the solo data buffer */
247- if (cur == rank ) {
248- cur_win -> w_osc_module -> osc_fence (0 , cur_win );
249- cur_win -> w_osc_module -> osc_put ((char * ) sbuf +
250- cur * l_seg_count * extent ,
251- seg_count , dtype , cur ,
252- (ptrdiff_t ) data_bufs [cur ], seg_count , dtype , cur_win );
253- cur_win -> w_osc_module -> osc_fence (0 , cur_win );
254- }
255- /* For other iterations, do operations on the solo data buffer */
256- else {
257- cur_win -> w_osc_module -> osc_accumulate ((char * ) sbuf +
258- cur * l_seg_count *
259- extent , seg_count , dtype , cur , (ptrdiff_t )
260- data_bufs [cur ], seg_count , dtype , op , cur_win );
261- cur_win -> w_osc_module -> osc_fence (0 , cur_win );
262- }
263- cur = (cur - 1 + size ) % size ;
264- * (int * ) (solo_module -> ctrl_bufs [rank ]) =
265- (* (int * ) (solo_module -> ctrl_bufs [rank ]) + 1 ) % size ;
266- mac_coll_solo_barrier_intra (comm , module );
267-
268- }
269- /* At last, all the processes copies data from the solo data buffer */
270- char * c ;
271- c = rbuf ;
272- for (i = 0 ; i < size ; i ++ ) {
273- if (i != size - 1 ) {
274- seg_count = l_seg_count ;
275- } else {
276- seg_count = count - i * l_seg_count ;
277- }
278- cur_win -> w_osc_module -> osc_get (c , seg_count , dtype , i ,
279- (ptrdiff_t ) data_bufs [i ], seg_count , dtype , cur_win );
280- c = c + seg_count * extent ;
281- }
282- cur_win -> w_osc_module -> osc_fence (0 , cur_win );
283- if ((size_t ) l_seg_count * extent <= mca_coll_solo_component .static_block_size ) {
284- if (data_bufs != NULL ) {
285- free (data_bufs );
286- data_bufs = NULL ;
287- }
288- } else if ((size_t ) l_seg_count * extent <= mca_coll_solo_component .mpool_large_block_size ) {
289- mca_coll_solo_detach_buf (solo_module , comm , local_buf , & data_bufs );
290- mca_coll_solo_mpool_return (mca_coll_solo_component .solo_mpool , id , l_seg_count * extent );
291- }
292- return OMPI_SUCCESS ;
293- }
160+ }
0 commit comments