1
1
/* -*- Mode: C; c-basic-offset:4 ; -*- */
2
2
/*
3
- * Copyright (c) 2004-2017 The University of Tennessee and The University
3
+ * Copyright (c) 2004-2019 The University of Tennessee and The University
4
4
* of Tennessee Research Foundation. All rights
5
5
* reserved.
6
6
* Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
35
35
#endif
36
36
37
37
38
- #define _predefined_data DT_CONCAT(MEM_OP_NAME,_predefined_data)
39
- #define _contiguous_loop DT_CONCAT(MEM_OP_NAME,_contiguous_loop)
40
38
#define _copy_content_same_ddt DT_CONCAT(MEM_OP_NAME,_copy_content_same_ddt)
41
39
42
- static inline void _predefined_data ( const dt_elem_desc_t * ELEM ,
43
- const opal_datatype_t * DATATYPE ,
44
- unsigned char * SOURCE_BASE ,
45
- size_t TOTAL_COUNT ,
46
- size_t COUNT ,
47
- unsigned char * SOURCE ,
48
- unsigned char * DESTINATION ,
49
- size_t * SPACE )
40
+ #if !defined(MEM_OP_BLOCK_SIZE_CONST )
41
+ #error
42
+ #endif
43
+
44
+ #if !defined(_memcpy_vector )
45
+
46
+ #define _memcpy_vector DT_CONCAT(MEM_OP_NAME,_memcpy_vector)
47
+ #define __OPAL_DATATYPE_DEFINE__memcpy_vector
48
+
49
+ static inline size_t
50
+ _memcpy_vector ( unsigned char * dest , /* destination pointer of the copy */
51
+ unsigned char * source , /* source pointer of the copy */
52
+ size_t blength , /* size in bytes of each block */
53
+ size_t count , /* the number of blocks */
54
+ ptrdiff_t dstride , /* the stride at the destination of each block */
55
+ ptrdiff_t sstride ) /* the stride at the source of each block */
56
+ {
57
+ size_t _length = 0 ;
58
+ if ( (blength == (size_t )(sstride )) && (sstride == dstride ) ) {
59
+ _length = count * blength ;
60
+ /* the extent and the size of the basic datatype are equals */
61
+ DO_DEBUG ( opal_output ( 0 , "vector copy [*] %s( %p, %p, %" PRIsize_t " )\n" ,
62
+ STRINGIFY (MEM_OP_NAME ), (void * )dest , (void * )source , _length ); );
63
+ MEM_OP ( dest , source , _length );
64
+ } else {
65
+ for (size_t _i = 0 ; _i < count ; _i ++ ) {
66
+ /* the extent and the size of the basic datatype are equals */
67
+ DO_DEBUG ( opal_output ( 0 , "vector copy [%" PRIsize_t "] %s( %p, %p, %" PRIsize_t " )\n" ,
68
+ _i , STRINGIFY (MEM_OP_NAME ), (void * )dest , (void * )source , blength ); );
69
+ MEM_OP ( dest , source , blength );
70
+ _length += blength ;
71
+ source += sstride ;
72
+ dest += dstride ;
73
+ }
74
+ }
75
+ return _length ;
76
+ }
77
+ #endif /* !defined(_memcpy_vector) */
78
+
79
+ #if !defined(_predefined_data )
80
+
81
+ #define _predefined_data DT_CONCAT(MEM_OP_NAME,_predefined_data)
82
+ #define __OPAL_DATATYPE_DEFINE__predefined_data
83
+
84
+ static inline
85
+ void _predefined_data ( const dt_elem_desc_t * ELEM ,
86
+ const opal_datatype_t * DATATYPE ,
87
+ unsigned char * SOURCE_BASE ,
88
+ size_t TOTAL_COUNT ,
89
+ size_t COUNT ,
90
+ unsigned char * SOURCE ,
91
+ unsigned char * DESTINATION ,
92
+ size_t * SPACE )
50
93
{
51
94
size_t _copy_count = (COUNT );
52
95
size_t _copy_blength ;
@@ -57,38 +100,34 @@ static inline void _predefined_data( const dt_elem_desc_t* ELEM,
57
100
_copy_blength = opal_datatype_basicDatatypes [_elem -> common .type ]-> size ;
58
101
59
102
if ( _copy_blength == (size_t )_elem -> extent ) {
60
- _copy_blength *= _copy_count ;
61
103
OPAL_DATATYPE_SAFEGUARD_POINTER ( _source , _copy_blength , (SOURCE_BASE ),
62
104
(DATATYPE ), (TOTAL_COUNT ) );
63
- /* the extent and the size of the basic datatype are equals */
64
- DO_DEBUG ( opal_output ( 0 , "copy 1. %s( %p, %p, %" PRIsize_t " ) => space %" PRIsize_t "\n" ,
65
- STRINGIFY (MEM_OP_NAME ), (void * )_destination , (void * )_source , _copy_blength , * (SPACE ) ); );
66
- MEM_OP ( _destination , _source , _copy_blength );
67
- _source += _copy_blength ;
68
- _destination += _copy_blength ;
69
105
} else {
70
106
for (size_t _i = 0 ; _i < _copy_count ; _i ++ ) {
71
107
OPAL_DATATYPE_SAFEGUARD_POINTER ( _source , _copy_blength , (SOURCE_BASE ),
72
108
(DATATYPE ), (TOTAL_COUNT ) );
73
- DO_DEBUG ( opal_output ( 0 , "copy 2. %s( %p, %p, %lu ) => space %lu\n" ,
74
- STRINGIFY (MEM_OP_NAME ), (void * )_destination , (void * )_source , (unsigned long )_copy_blength , (unsigned long )(* (SPACE ) - (_i * _copy_blength )) ); );
75
- MEM_OP ( _destination , _source , _copy_blength );
76
- _source += _elem -> extent ;
77
- _destination += _elem -> extent ;
78
109
}
79
- _copy_blength *= _copy_count ;
80
110
}
81
- * (SPACE ) -= _copy_blength ;
111
+ _copy_blength = _memcpy_vector ( _destination , _source ,
112
+ _copy_blength , _copy_count ,
113
+ _elem -> extent , _elem -> extent );
114
+ * (SPACE ) -= _copy_blength ;
82
115
}
116
+ #endif /* !defined(_predefined_data) */
83
117
84
- static inline void _contiguous_loop ( const dt_elem_desc_t * ELEM ,
85
- const opal_datatype_t * DATATYPE ,
86
- unsigned char * SOURCE_BASE ,
87
- size_t TOTAL_COUNT ,
88
- size_t COUNT ,
89
- unsigned char * SOURCE ,
90
- unsigned char * DESTINATION ,
91
- size_t * SPACE )
118
+ #if !defined(_contiguous_loop )
119
+ #define _contiguous_loop DT_CONCAT(MEM_OP_NAME,_contiguous_loop)
120
+ #define __OPAL_DATATYPE_DEFINE__contiguous_loop
121
+
122
+ static inline
123
+ void _contiguous_loop ( const dt_elem_desc_t * ELEM ,
124
+ const opal_datatype_t * DATATYPE ,
125
+ unsigned char * SOURCE_BASE ,
126
+ size_t TOTAL_COUNT ,
127
+ size_t COUNT ,
128
+ unsigned char * SOURCE ,
129
+ unsigned char * DESTINATION ,
130
+ size_t * SPACE )
92
131
{
93
132
ddt_loop_desc_t * _loop = (ddt_loop_desc_t * )(ELEM );
94
133
ddt_endloop_desc_t * _end_loop = (ddt_endloop_desc_t * )((ELEM ) + _loop -> items );
@@ -115,6 +154,7 @@ static inline void _contiguous_loop( const dt_elem_desc_t* ELEM,
115
154
}
116
155
* (SPACE ) -= _copy_loops ;
117
156
}
157
+ #endif /* !defined(_contiguous_loop) */
118
158
119
159
static inline int32_t _copy_content_same_ddt ( const opal_datatype_t * datatype , int32_t count ,
120
160
char * destination_base , char * source_base )
@@ -146,7 +186,7 @@ static inline int32_t _copy_content_same_ddt( const opal_datatype_t* datatype, i
146
186
source += datatype -> true_lb ;
147
187
if ( (ptrdiff_t )datatype -> size == extent ) { /* all contiguous == no gaps around */
148
188
size_t total_length = iov_len_local ;
149
- size_t memop_chunk = opal_datatype_memop_block_size ;
189
+ size_t memop_chunk = MEM_OP_BLOCK_SIZE_CONST ;
150
190
while ( total_length > 0 ) {
151
191
if ( memop_chunk > total_length ) memop_chunk = total_length ;
152
192
OPAL_DATATYPE_SAFEGUARD_POINTER ( destination , memop_chunk ,
@@ -251,3 +291,18 @@ static inline int32_t _copy_content_same_ddt( const opal_datatype_t* datatype, i
251
291
}
252
292
}
253
293
}
294
+
295
+ #if defined(__OPAL_DATATYPE_DEFINE__memcpy_vector )
296
+ #undef __OPAL_DATATYPE_DEFINE__memcpy_vector
297
+ #undef _memcpy_vector
298
+ #endif /* defined(__OPAL_DATATYPE_DEFINE__memcpy_vector) */
299
+
300
+ #if defined(__OPAL_DATATYPE_DEFINE__predefined_data )
301
+ #undef __OPAL_DATATYPE_DEFINE__predefined_data
302
+ #undef _predefined_data
303
+ #endif /* defined(__OPAL_DATATYPE_DEFINE__predefined_data) */
304
+
305
+ #if defined(__OPAL_DATATYPE_DEFINE__contiguous_loop )
306
+ #undef __OPAL_DATATYPE_DEFINE__contiguous_loop
307
+ #undef _contiguous_loop
308
+ #endif /* defined(__OPAL_DATATYPE_DEFINE__contiguous_loop) */
0 commit comments