libxmp/libxmpf in Omni Compiler
1.3.4
|
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <limits.h>
#include <float.h>
#include "mpi.h"
#include "xmp_internal.h"
|
void | _XMP_setup_reduce_type (MPI_Datatype *mpi_datatype, size_t *datatype_size, int datatype) |
|
void | _XMP_reduce_NODES_ENTIRE (_XMP_nodes_t *nodes, void *addr, int count, int datatype, int op) |
|
void | _XMP_reduce_FLMM_NODES_ENTIRE (_XMP_nodes_t *nodes, void *addr, int count, int datatype, int op, int num_locs,...) |
|
void | _XMPF_reduce_FLMM_NODES_ENTIRE (_XMP_nodes_t *nodes, void *addr, int count, int datatype, int op, int num_locs, void **loc_vars, int *loc_types) |
|
void | _XMP_reduce_CLAUSE (void *data_addr, int count, int datatype, int op) |
|
void | _XMP_reduce_FLMM_CLAUSE (void *data_addr, int count, int datatype, int op, int num_locs,...) |
|
int | _XMP_init_reduce_comm_NODES (_XMP_nodes_t *nodes,...) |
|
int | _XMP_init_reduce_comm_TEMPLATE (_XMP_template_t *template,...) |
|
void | xmp_reduce_initialize () |
|
void | xmp_reduce_loc_init (const int nlocs, const long double value, void *value_addr, const int datatype) |
|
void | xmp_reduce_loc_set (void *buf, const int length, const size_t s) |
|
void | xmp_reduce_loc_execute (const int op) |
|
◆ _XMP_M_COMPARE_REDUCE_RESULTS_MAIN
#define _XMP_M_COMPARE_REDUCE_RESULTS_MAIN |
( |
|
type | ) |
|
Value:{ \
type *buf1 = (type *)temp_buffer; \
type *buf2 = (type *)addr; \
for (int i = 0; i < count; i++) { \
} \
break; \
}
◆ _XMP_M_DEFINE_WITH_CAST
#define _XMP_M_DEFINE_WITH_CAST |
( |
|
type, |
|
|
|
addr, |
|
|
|
value |
|
) |
| *(type *)addr = (type)value; |
◆ _XMP_M_INIT_LOCATION_VARIABLES_MAIN
#define _XMP_M_INIT_LOCATION_VARIABLES_MAIN |
( |
|
type, |
|
|
|
init_min, |
|
|
|
init_max |
|
) |
| |
Value:{ \
type *buf = (type *)loc; \
for (int i = 0; i < count; i++) { \
if (!cmp_buffer[i]) { \
switch (op) { \
buf[i] = init_max; \
break; \
buf[i] = init_min; \
break; \
default: \
_XMP_fatal("unknown reduce operation"); \
} \
} \
} \
break; \
}
◆ MPI_PORTABLE_PLATFORM_H
#define MPI_PORTABLE_PLATFORM_H |
◆ _XMP_init_reduce_comm_NODES()
int _XMP_init_reduce_comm_NODES |
( |
_XMP_nodes_t * |
nodes, |
|
|
|
... |
|
) |
| |
417 int acc_nodes_size = 1;
418 int nodes_dim = nodes->
dim;
421 va_start(args, nodes);
422 for (
int i = 0; i < nodes_dim; i++) {
426 if (va_arg(args,
int) == 1) {
427 color += (acc_nodes_size * rank);
430 acc_nodes_size *= size;
437 MPI_Comm *comm =
_XMP_alloc(
sizeof(MPI_Comm));
◆ _XMP_init_reduce_comm_TEMPLATE()
456 int acc_nodes_size = 1;
457 int template_dim =
template->
dim;
460 va_start(args,
template);
461 for (
int i = 0; i < template_dim; i++) {
471 size = onto_nodes_info->
size;
472 rank = onto_nodes_info->
rank;
475 if (va_arg(args,
int) == 1) {
476 color += (acc_nodes_size * rank);
479 acc_nodes_size *= size;
486 MPI_Comm *comm =
_XMP_alloc(
sizeof(MPI_Comm));
◆ _XMP_reduce_CLAUSE()
void _XMP_reduce_CLAUSE |
( |
void * |
data_addr, |
|
|
int |
count, |
|
|
int |
datatype, |
|
|
int |
op |
|
) |
| |
355 MPI_Datatype mpi_datatype = MPI_INT;
356 size_t datatype_size;
357 MPI_Op mpi_op = MPI_SUM;
359 _XMP_setup_reduce_op(&mpi_op, op);
362 MPI_Allreduce(MPI_IN_PLACE, data_addr, count, mpi_datatype, mpi_op, *((MPI_Comm *)(
_XMP_get_execution_nodes())->comm));
◆ _XMP_reduce_FLMM_CLAUSE()
void _XMP_reduce_FLMM_CLAUSE |
( |
void * |
data_addr, |
|
|
int |
count, |
|
|
int |
datatype, |
|
|
int |
op, |
|
|
int |
num_locs, |
|
|
|
... |
|
) |
| |
371 MPI_Datatype mpi_datatype;
372 size_t datatype_size;
375 _XMP_setup_reduce_op(&mpi_op, op);
378 size_t n = datatype_size * count;
380 memcpy(temp_buffer, data_addr, n);
382 MPI_Allreduce(temp_buffer, data_addr, count, mpi_datatype, mpi_op, *((MPI_Comm *)nodes->
comm));
385 n =
sizeof(int) * count;
387 _XMP_compare_reduce_results(cmp_buffer, temp_buffer, data_addr, count, datatype);
391 va_start(args, num_locs);
392 for (
int i = 0; i < num_locs; i++) {
393 void *loc = va_arg(args,
void *);
394 int loc_datatype = va_arg(args,
int);
397 _XMP_setup_reduce_FLMM_op(&mpi_op, op);
398 _XMP_init_localtion_variables(loc, count, loc_datatype, cmp_buffer, op);
400 n = datatype_size * count;
402 memcpy(loc_temp, loc, n);
404 MPI_Allreduce(loc_temp, loc, count, mpi_datatype, mpi_op, *((MPI_Comm *)nodes->
comm));
◆ _XMP_reduce_FLMM_NODES_ENTIRE()
void _XMP_reduce_FLMM_NODES_ENTIRE |
( |
_XMP_nodes_t * |
nodes, |
|
|
void * |
addr, |
|
|
int |
count, |
|
|
int |
datatype, |
|
|
int |
op, |
|
|
int |
num_locs, |
|
|
|
... |
|
) |
| |
248 if(count == 0)
return;
252 MPI_Datatype mpi_datatype;
253 size_t datatype_size;
256 _XMP_setup_reduce_op(&mpi_op, op);
259 size_t n = datatype_size * count;
261 memcpy(temp_buffer, addr, n);
263 MPI_Allreduce(temp_buffer, addr, count, mpi_datatype, mpi_op, *((MPI_Comm *)nodes->
comm));
266 n =
sizeof(int) * count;
268 _XMP_compare_reduce_results(cmp_buffer, temp_buffer, addr, count, datatype);
272 va_start(args, num_locs);
273 for (
int i = 0; i < num_locs; i++) {
274 void *loc = va_arg(args,
void *);
275 int loc_datatype = va_arg(args,
int);
278 _XMP_setup_reduce_FLMM_op(&mpi_op, op);
279 _XMP_init_localtion_variables(loc, count, loc_datatype, cmp_buffer, op);
281 n = datatype_size * count;
283 memcpy(loc_temp, loc, n);
285 MPI_Allreduce(loc_temp, loc, count, mpi_datatype, mpi_op, *((MPI_Comm *)nodes->
comm));
◆ _XMP_reduce_NODES_ENTIRE()
void _XMP_reduce_NODES_ENTIRE |
( |
_XMP_nodes_t * |
nodes, |
|
|
void * |
addr, |
|
|
int |
count, |
|
|
int |
datatype, |
|
|
int |
op |
|
) |
| |
227 MPI_Datatype mpi_datatype = MPI_INT;
228 size_t datatype_size;
229 MPI_Op mpi_op = MPI_SUM;
231 _XMP_setup_reduce_op(&mpi_op, op);
236 MPI_Iallreduce(MPI_IN_PLACE, addr, count, mpi_datatype, mpi_op, *((MPI_Comm *)nodes->
comm),
242 MPI_Allreduce(MPI_IN_PLACE, addr, count, mpi_datatype, mpi_op, *((MPI_Comm *)nodes->
comm));
◆ _XMP_setup_reduce_type()
void _XMP_setup_reduce_type |
( |
MPI_Datatype * |
mpi_datatype, |
|
|
size_t * |
datatype_size, |
|
|
int |
datatype |
|
) |
| |
17 { *mpi_datatype = MPI_LOGICAL; *datatype_size =
sizeof(_Bool);
break; }
19 { *mpi_datatype = MPI_SIGNED_CHAR; *datatype_size =
sizeof(char);
break; }
21 { *mpi_datatype = MPI_UNSIGNED_CHAR; *datatype_size =
sizeof(
unsigned char);
break; }
23 { *mpi_datatype = MPI_SHORT; *datatype_size =
sizeof(short);
break; }
25 { *mpi_datatype = MPI_UNSIGNED_SHORT; *datatype_size =
sizeof(
unsigned short);
break; }
27 { *mpi_datatype = MPI_INT; *datatype_size =
sizeof(int);
break; }
29 { *mpi_datatype = MPI_UNSIGNED; *datatype_size =
sizeof(
unsigned int);
break; }
31 { *mpi_datatype = MPI_LONG; *datatype_size =
sizeof(long);
break; }
33 { *mpi_datatype = MPI_UNSIGNED_LONG; *datatype_size =
sizeof(
unsigned long);
break; }
35 { *mpi_datatype = MPI_LONG_LONG; *datatype_size =
sizeof(
long long);
break; }
37 { *mpi_datatype = MPI_UNSIGNED_LONG_LONG; *datatype_size =
sizeof(
unsigned long long);
break; }
39 { *mpi_datatype = MPI_FLOAT; *datatype_size =
sizeof(float);
break; }
41 { *mpi_datatype = MPI_DOUBLE; *datatype_size =
sizeof(double);
break; }
43 { *mpi_datatype = MPI_LONG_DOUBLE; *datatype_size =
sizeof(
long double);
break; }
44 #ifdef __STD_IEC_559_COMPLEX__
45 case _XMP_N_TYPE_FLOAT_IMAGINARY:
46 { *mpi_datatype = MPI_FLOAT; *datatype_size =
sizeof(
float _Imaginary);
break; }
47 case _XMP_N_TYPE_DOUBLE_IMAGINARY:
48 { *mpi_datatype = MPI_DOUBLE; *datatype_size =
sizeof(
double _Imaginary);
break; }
49 case _XMP_N_TYPE_LONG_DOUBLE_IMAGINARY:
50 { *mpi_datatype = MPI_LONG_DOUBLE; *datatype_size =
sizeof(
long double _Imaginary);
break; }
53 #if ((MPI_VERSION >= 3) || (MPI_VERSION == 2 && MPI_SUBVERSION >= 2))
55 { *mpi_datatype = MPI_C_FLOAT_COMPLEX; *datatype_size =
sizeof(
float _Complex);
break; }
57 { *mpi_datatype = MPI_C_DOUBLE_COMPLEX; *datatype_size =
sizeof(
double _Complex);
break; }
59 { *mpi_datatype = MPI_C_LONG_DOUBLE_COMPLEX; *datatype_size =
sizeof(
long double _Complex);
break; }
◆ _XMPF_reduce_FLMM_NODES_ENTIRE()
void _XMPF_reduce_FLMM_NODES_ENTIRE |
( |
_XMP_nodes_t * |
nodes, |
|
|
void * |
addr, |
|
|
int |
count, |
|
|
int |
datatype, |
|
|
int |
op, |
|
|
int |
num_locs, |
|
|
void ** |
loc_vars, |
|
|
int * |
loc_types |
|
) |
| |
309 MPI_Datatype mpi_datatype;
310 size_t datatype_size;
313 _XMP_setup_reduce_op(&mpi_op, op);
316 size_t n = datatype_size * count;
318 memcpy(temp_buffer, addr, n);
320 MPI_Allreduce(temp_buffer, addr, count, mpi_datatype, mpi_op, *((MPI_Comm *)nodes->
comm));
323 n =
sizeof(int) * count;
325 _XMP_compare_reduce_results(cmp_buffer, temp_buffer, addr, count, datatype);
328 for (
int i = 0; i < num_locs; i++) {
329 void *loc = loc_vars[i];
330 int loc_datatype = loc_types[i];
333 _XMP_setup_reduce_FLMM_op(&mpi_op, op);
334 _XMP_init_localtion_variables(loc, count, loc_datatype, cmp_buffer, op);
336 n = datatype_size * count;
338 memcpy(loc_temp, loc, n);
340 MPI_Allreduce(loc_temp, loc, count, mpi_datatype, mpi_op, *((MPI_Comm *)nodes->
comm));
◆ xmp_reduce_initialize()
void xmp_reduce_initialize |
( |
| ) |
|
555 MPI_Op_create(_reduce_maxloc, 1, &_xmp_maxloc);
556 MPI_Op_create(_reduce_minloc, 1, &_xmp_minloc);
◆ xmp_reduce_loc_execute()
void xmp_reduce_loc_execute |
( |
const int |
op | ) |
|
657 size_t total_reduce_size = 0;
658 for(
int i=0;i<_nlocs+2;i++)
659 total_reduce_size += _size[i];
661 char *buffer = malloc(total_reduce_size);
664 for(
int i=0;i<_nlocs+2;i++){
665 memcpy(buffer + offset, _addr[i], _size[i]);
670 MPI_Allreduce(MPI_IN_PLACE, buffer, total_reduce_size, MPI_BYTE, _xmp_maxloc, *((MPI_Comm *)nodes->
comm));
672 MPI_Allreduce(MPI_IN_PLACE, buffer, total_reduce_size, MPI_BYTE, _xmp_minloc, *((MPI_Comm *)nodes->
comm));
674 _XMP_fatal(
"Unknown operation in reduction directve");
677 for(
int i=0;i<_nlocs+2;i++){
678 memcpy(_addr[i], buffer + offset, _size[i]);
682 long double value = *(
long double *)_addr[0];
683 _cast_define_double_value(_value_addr, value, _datatype);
◆ xmp_reduce_loc_init()
void xmp_reduce_loc_init |
( |
const int |
nlocs, |
|
|
const long double |
value, |
|
|
void * |
value_addr, |
|
|
const int |
datatype |
|
) |
| |
575 _value_addr = value_addr;
576 _datatype = datatype;
579 _addr = malloc(
sizeof(
void *) * (nlocs+2));
581 _addr[1] = &_node_num;
583 _size = malloc(
sizeof(
int) * (nlocs+2));
584 _size[0] =
sizeof(
long double);
585 _size[1] =
sizeof(int);
◆ xmp_reduce_loc_set()
void xmp_reduce_loc_set |
( |
void * |
buf, |
|
|
const int |
length, |
|
|
const size_t |
s |
|
) |
| |
600 _size[_num] = length * s;
int size
Definition: xmp_data_struct.h:32
_XMP_nodes_info_t info[1]
Definition: xmp_data_struct.h:60
Definition: xmp_data_struct.h:31
int comm_size
Definition: xmp_data_struct.h:48
#define _XMP_N_TYPE_BOOL
Definition: xmp_constant.h:80
#define _XMP_N_TYPE_INT
Definition: xmp_constant.h:85
_Bool xmp_is_async()
Definition: xmp_async.c:20
#define _XMP_N_REDUCE_MINLOC
Definition: xmp_constant.h:61
int is_member
Definition: xmp_data_struct.h:46
void * _XMP_alloc(size_t size)
Definition: xmp_util.c:21
#define _XMP_N_TYPE_DOUBLE
Definition: xmp_constant.h:92
#define _XMP_N_REDUCE_LASTMIN
Definition: xmp_constant.h:56
#define _XMP_N_TYPE_DOUBLE_COMPLEX
Definition: xmp_constant.h:102
#define _XMP_N_TYPE_LONG_DOUBLE
Definition: xmp_constant.h:93
_XMP_nodes_info_t * onto_nodes_info
Definition: xmp_data_struct.h:94
void _XMP_finalize_comm(void *comm)
int _XMP_world_rank
Definition: xmp_world.c:9
#define _XMP_N_TYPE_UNSIGNED_LONGLONG
Definition: xmp_constant.h:90
#define _XMP_N_REDUCE_FIRSTMAX
Definition: xmp_constant.h:53
#define _XMP_N_TYPE_LONG
Definition: xmp_constant.h:87
#define _XMP_N_TYPE_SHORT
Definition: xmp_constant.h:83
#define _XMP_N_TYPE_FLOAT_COMPLEX
Definition: xmp_constant.h:101
#define _XMP_N_TYPE_FLOAT
Definition: xmp_constant.h:91
#define _XMP_N_TYPE_UNSIGNED_INT
Definition: xmp_constant.h:86
#define _XMP_N_INT_FALSE
Definition: xmp_constant.h:5
_XMP_async_comm_t * _XMP_get_current_async()
Definition: xmp_async.c:205
#define _XMP_N_TYPE_UNSIGNED_LONG
Definition: xmp_constant.h:88
Definition: xmp_data_struct.h:78
int nreqs
Definition: xmp_data_struct.h:460
#define _XMP_N_DIST_DUPLICATION
Definition: xmp_constant.h:28
#define _XMP_N_TYPE_UNSIGNED_SHORT
Definition: xmp_constant.h:84
#define _XMP_N_TYPE_CHAR
Definition: xmp_constant.h:81
#define _XMP_N_TYPE_UNSIGNED_CHAR
Definition: xmp_constant.h:82
#define _XMP_N_REDUCE_MAXLOC
Definition: xmp_constant.h:60
MPI_Request * reqs
Definition: xmp_data_struct.h:464
Definition: xmp_data_struct.h:458
int rank
Definition: xmp_data_struct.h:35
int dist_manner
Definition: xmp_data_struct.h:87
void _XMP_free(void *p)
Definition: xmp_util.c:37
#define _XMP_ASSERT(_flag)
Definition: xmp_internal.h:34
#define _XMP_N_TYPE_LONG_DOUBLE_COMPLEX
Definition: xmp_constant.h:103
#define _XMP_N_REDUCE_LASTMAX
Definition: xmp_constant.h:55
_XMP_comm_t * comm
Definition: xmp_data_struct.h:53
void _XMP_fatal(char *msg)
Definition: xmp_util.c:42
void _XMP_setup_reduce_type(MPI_Datatype *mpi_datatype, size_t *datatype_size, int datatype)
Definition: xmp_reduce.c:13
#define _XMP_N_TYPE_LONGLONG
Definition: xmp_constant.h:89
#define _XMP_N_REDUCE_FIRSTMIN
Definition: xmp_constant.h:54
_Bool is_distributed
Definition: xmp_data_struct.h:105
int dim
Definition: xmp_data_struct.h:47
Definition: xmp_data_struct.h:40
void _XMP_push_comm(void *comm)
#define _XMP_RETURN_IF_SINGLE
Definition: xmp_internal.h:37
#define _XMP_N_INT_TRUE
Definition: xmp_constant.h:4
void * _XMP_get_execution_nodes(void)
Definition: xmp_nodes_stack.c:46