/oshmem/op/op.c

https://github.com/open-mpi/ompi · C · 510 lines · 405 code · 42 blank · 63 comment · 9 complexity · 689d1c5c1c0bd2719ceeb4ccfa389908 MD5 · raw file

  1. /*
  2. * Copyright (c) 2013 Mellanox Technologies, Inc.
  3. * All rights reserved.
  4. * Copyright (c) 2013 Cisco Systems, Inc. All rights reserved.
  5. * Copyright (c) 2015-2019 Research Organization for Information Science
  6. * and Technology (RIST). All rights reserved.
  7. * $COPYRIGHT$
  8. *
  9. * Additional copyrights may follow
  10. *
  11. * $HEADER$
  12. */
  13. #include "oshmem_config.h"
  14. #include <complex.h>
  15. #include "opal/datatype/opal_datatype.h"
  16. #include "opal/datatype/opal_datatype_internal.h"
  17. #include "opal/class/opal_pointer_array.h"
  18. #include "oshmem/constants.h"
  19. #include "oshmem/op/op.h"
  20. /*
  21. * Table for op handle conversion
  22. */
  23. opal_pointer_array_t oshmem_op_array = {{0}};
  24. /*
  25. * Class information
  26. */
  27. static void oshmem_op_construct(oshmem_op_t *object);
  28. static void oshmem_op_destruct(oshmem_op_t *object);
  29. /*
  30. * Class instance
  31. */
  32. OBJ_CLASS_INSTANCE(oshmem_op_t,
  33. opal_object_t,
  34. oshmem_op_construct,
  35. oshmem_op_destruct);
  36. /*
  37. * Intrinsic Operation objects
  38. */
  39. /* Bitwise AND */
  40. oshmem_op_t* oshmem_op_and_short = NULL;
  41. oshmem_op_t* oshmem_op_and_int = NULL;
  42. oshmem_op_t* oshmem_op_and_long = NULL;
  43. oshmem_op_t* oshmem_op_and_longlong = NULL;
  44. oshmem_op_t* oshmem_op_and_fint2 = NULL;
  45. oshmem_op_t* oshmem_op_and_fint4 = NULL;
  46. oshmem_op_t* oshmem_op_and_fint8 = NULL;
  47. oshmem_op_t* oshmem_op_and_int16 = NULL;
  48. oshmem_op_t* oshmem_op_and_int32 = NULL;
  49. oshmem_op_t* oshmem_op_and_int64 = NULL;
  50. /* Bitwise OR */
  51. oshmem_op_t* oshmem_op_or_short = NULL;
  52. oshmem_op_t* oshmem_op_or_int = NULL;
  53. oshmem_op_t* oshmem_op_or_long = NULL;
  54. oshmem_op_t* oshmem_op_or_longlong = NULL;
  55. oshmem_op_t* oshmem_op_or_fint2 = NULL;
  56. oshmem_op_t* oshmem_op_or_fint4 = NULL;
  57. oshmem_op_t* oshmem_op_or_fint8 = NULL;
  58. oshmem_op_t* oshmem_op_or_int16 = NULL;
  59. oshmem_op_t* oshmem_op_or_int32 = NULL;
  60. oshmem_op_t* oshmem_op_or_int64 = NULL;
  61. /* Bitwise XOR */
  62. oshmem_op_t* oshmem_op_xor_short = NULL;
  63. oshmem_op_t* oshmem_op_xor_int = NULL;
  64. oshmem_op_t* oshmem_op_xor_long = NULL;
  65. oshmem_op_t* oshmem_op_xor_longlong = NULL;
  66. oshmem_op_t* oshmem_op_xor_fint2 = NULL;
  67. oshmem_op_t* oshmem_op_xor_fint4 = NULL;
  68. oshmem_op_t* oshmem_op_xor_fint8 = NULL;
  69. oshmem_op_t* oshmem_op_xor_int16 = NULL;
  70. oshmem_op_t* oshmem_op_xor_int32 = NULL;
  71. oshmem_op_t* oshmem_op_xor_int64 = NULL;
  72. /* MAX */
  73. oshmem_op_t* oshmem_op_max_short = NULL;
  74. oshmem_op_t* oshmem_op_max_int = NULL;
  75. oshmem_op_t* oshmem_op_max_long = NULL;
  76. oshmem_op_t* oshmem_op_max_longlong = NULL;
  77. oshmem_op_t* oshmem_op_max_float = NULL;
  78. oshmem_op_t* oshmem_op_max_double = NULL;
  79. oshmem_op_t* oshmem_op_max_longdouble = NULL;
  80. oshmem_op_t* oshmem_op_max_fint2 = NULL;
  81. oshmem_op_t* oshmem_op_max_fint4 = NULL;
  82. oshmem_op_t* oshmem_op_max_fint8 = NULL;
  83. oshmem_op_t* oshmem_op_max_freal4 = NULL;
  84. oshmem_op_t* oshmem_op_max_freal8 = NULL;
  85. oshmem_op_t* oshmem_op_max_freal16 = NULL;
  86. oshmem_op_t* oshmem_op_max_int16 = NULL;
  87. oshmem_op_t* oshmem_op_max_int32 = NULL;
  88. oshmem_op_t* oshmem_op_max_int64 = NULL;
  89. /* MIN */
  90. oshmem_op_t* oshmem_op_min_short = NULL;
  91. oshmem_op_t* oshmem_op_min_int = NULL;
  92. oshmem_op_t* oshmem_op_min_long = NULL;
  93. oshmem_op_t* oshmem_op_min_longlong = NULL;
  94. oshmem_op_t* oshmem_op_min_float = NULL;
  95. oshmem_op_t* oshmem_op_min_double = NULL;
  96. oshmem_op_t* oshmem_op_min_longdouble = NULL;
  97. oshmem_op_t* oshmem_op_min_fint2 = NULL;
  98. oshmem_op_t* oshmem_op_min_fint4 = NULL;
  99. oshmem_op_t* oshmem_op_min_fint8 = NULL;
  100. oshmem_op_t* oshmem_op_min_freal4 = NULL;
  101. oshmem_op_t* oshmem_op_min_freal8 = NULL;
  102. oshmem_op_t* oshmem_op_min_freal16 = NULL;
  103. oshmem_op_t* oshmem_op_min_int16 = NULL;
  104. oshmem_op_t* oshmem_op_min_int32 = NULL;
  105. oshmem_op_t* oshmem_op_min_int64 = NULL;
  106. /* SUM */
  107. oshmem_op_t* oshmem_op_sum_short = NULL;
  108. oshmem_op_t* oshmem_op_sum_int = NULL;
  109. oshmem_op_t* oshmem_op_sum_long = NULL;
  110. oshmem_op_t* oshmem_op_sum_longlong = NULL;
  111. oshmem_op_t* oshmem_op_sum_float = NULL;
  112. oshmem_op_t* oshmem_op_sum_double = NULL;
  113. oshmem_op_t* oshmem_op_sum_longdouble = NULL;
  114. oshmem_op_t* oshmem_op_sum_complexf = NULL;
  115. oshmem_op_t* oshmem_op_sum_complexd = NULL;
  116. oshmem_op_t* oshmem_op_sum_fint2 = NULL;
  117. oshmem_op_t* oshmem_op_sum_fint4 = NULL;
  118. oshmem_op_t* oshmem_op_sum_fint8 = NULL;
  119. oshmem_op_t* oshmem_op_sum_freal4 = NULL;
  120. oshmem_op_t* oshmem_op_sum_freal8 = NULL;
  121. oshmem_op_t* oshmem_op_sum_freal16 = NULL;
  122. oshmem_op_t* oshmem_op_sum_int16 = NULL;
  123. oshmem_op_t* oshmem_op_sum_int32 = NULL;
  124. oshmem_op_t* oshmem_op_sum_int64 = NULL;
  125. /* PROD */
  126. oshmem_op_t* oshmem_op_prod_short = NULL;
  127. oshmem_op_t* oshmem_op_prod_int = NULL;
  128. oshmem_op_t* oshmem_op_prod_long = NULL;
  129. oshmem_op_t* oshmem_op_prod_longlong = NULL;
  130. oshmem_op_t* oshmem_op_prod_float = NULL;
  131. oshmem_op_t* oshmem_op_prod_double = NULL;
  132. oshmem_op_t* oshmem_op_prod_longdouble = NULL;
  133. oshmem_op_t* oshmem_op_prod_complexf = NULL;
  134. oshmem_op_t* oshmem_op_prod_complexd = NULL;
  135. oshmem_op_t* oshmem_op_prod_fint2 = NULL;
  136. oshmem_op_t* oshmem_op_prod_fint4 = NULL;
  137. oshmem_op_t* oshmem_op_prod_fint8 = NULL;
  138. oshmem_op_t* oshmem_op_prod_freal4 = NULL;
  139. oshmem_op_t* oshmem_op_prod_freal8 = NULL;
  140. oshmem_op_t* oshmem_op_prod_freal16 = NULL;
  141. oshmem_op_t* oshmem_op_prod_int16 = NULL;
  142. oshmem_op_t* oshmem_op_prod_int32 = NULL;
  143. oshmem_op_t* oshmem_op_prod_int64 = NULL;
  144. /* SWAP */
  145. oshmem_op_t* oshmem_op_swap_int = NULL;
  146. oshmem_op_t* oshmem_op_swap_long = NULL;
  147. oshmem_op_t* oshmem_op_swap_longlong = NULL;
  148. oshmem_op_t* oshmem_op_swap_int32 = NULL;
  149. oshmem_op_t* oshmem_op_swap_int64 = NULL;
  150. #define FUNC_OP_CREATE(name, type_name, type, calc) \
  151. void oshmem_op_##name##_##type_name##_func(void *in, void *out, int count); \
  152. void oshmem_op_##name##_##type_name##_func(void *in, void *out, int count) \
  153. { \
  154. int i; \
  155. type *a = (type *) in; \
  156. type *b = (type *) out; \
  157. for (i = 0; i < count; ++i) { \
  158. *(b) = calc(*(b), *(a)); \
  159. ++b; \
  160. ++a; \
  161. } \
  162. }
  163. #define OBJ_OP_CREATE(name, type_name, type, op_id, dt_id) \
  164. oshmem_op_##name##_##type_name = OBJ_NEW(oshmem_op_t); \
  165. if (oshmem_op_##name##_##type_name) \
  166. { \
  167. oshmem_op_##name##_##type_name->op = op_id; \
  168. oshmem_op_##name##_##type_name->dt = dt_id; \
  169. oshmem_op_##name##_##type_name->dt_size = sizeof(type); \
  170. oshmem_op_##name##_##type_name->o_func.c_fn = oshmem_op_##name##_##type_name##_func; \
  171. } \
  172. /* Bitwise AND */
  173. #define __and_op(a, b) ((a) & (b))
  174. FUNC_OP_CREATE(and, short, short, __and_op)
  175. FUNC_OP_CREATE(and, int, int, __and_op)
  176. FUNC_OP_CREATE(and, long, long, __and_op)
  177. FUNC_OP_CREATE(and, longlong, long long, __and_op)
  178. FUNC_OP_CREATE(and, fint2, ompi_fortran_integer4_t, __and_op)
  179. FUNC_OP_CREATE(and, fint4, ompi_fortran_integer4_t, __and_op)
  180. FUNC_OP_CREATE(and, fint8, ompi_fortran_integer8_t, __and_op)
  181. FUNC_OP_CREATE(and, int16, int16_t, __and_op)
  182. FUNC_OP_CREATE(and, int32, int32_t, __and_op)
  183. FUNC_OP_CREATE(and, int64, int64_t, __and_op)
  184. /* Bitwise OR */
  185. #define __or_op(a, b) ((a) | (b))
  186. FUNC_OP_CREATE(or, short, short, __or_op)
  187. FUNC_OP_CREATE(or, int, int, __or_op)
  188. FUNC_OP_CREATE(or, long, long, __or_op)
  189. FUNC_OP_CREATE(or, longlong, long long, __or_op)
  190. FUNC_OP_CREATE(or, fint2, ompi_fortran_integer2_t, __or_op)
  191. FUNC_OP_CREATE(or, fint4, ompi_fortran_integer4_t, __or_op)
  192. FUNC_OP_CREATE(or, fint8, ompi_fortran_integer8_t, __or_op)
  193. FUNC_OP_CREATE(or, int16, int16_t, __or_op)
  194. FUNC_OP_CREATE(or, int32, int32_t, __or_op)
  195. FUNC_OP_CREATE(or, int64, int64_t, __or_op)
  196. /* Bitwise XOR */
  197. #define __xor_op(a, b) ((a) ^ (b))
  198. FUNC_OP_CREATE(xor, short, short, __xor_op)
  199. FUNC_OP_CREATE(xor, int, int, __xor_op)
  200. FUNC_OP_CREATE(xor, long, long, __xor_op)
  201. FUNC_OP_CREATE(xor, longlong, long long, __xor_op)
  202. FUNC_OP_CREATE(xor, fint2, ompi_fortran_integer4_t, __xor_op)
  203. FUNC_OP_CREATE(xor, fint4, ompi_fortran_integer4_t, __xor_op)
  204. FUNC_OP_CREATE(xor, fint8, ompi_fortran_integer8_t, __xor_op)
  205. FUNC_OP_CREATE(xor, int16, int16_t, __xor_op)
  206. FUNC_OP_CREATE(xor, int32, int32_t, __xor_op)
  207. FUNC_OP_CREATE(xor, int64, int64_t, __xor_op)
  208. /* MAX */
  209. #define __max_op(a, b) ((a) > (b) ? (a) : (b))
  210. FUNC_OP_CREATE(max, short, short, __max_op)
  211. FUNC_OP_CREATE(max, int, int, __max_op)
  212. FUNC_OP_CREATE(max, long, long, __max_op)
  213. FUNC_OP_CREATE(max, longlong, long long, __max_op)
  214. FUNC_OP_CREATE(max, float, float, __max_op)
  215. FUNC_OP_CREATE(max, double, double, __max_op)
  216. FUNC_OP_CREATE(max, longdouble, long double, __max_op)
  217. FUNC_OP_CREATE(max, fint2, ompi_fortran_integer4_t, __max_op)
  218. FUNC_OP_CREATE(max, fint4, ompi_fortran_integer4_t, __max_op)
  219. FUNC_OP_CREATE(max, fint8, ompi_fortran_integer8_t, __max_op)
  220. FUNC_OP_CREATE(max, freal4, ompi_fortran_real4_t, __max_op)
  221. FUNC_OP_CREATE(max, freal8, ompi_fortran_real8_t, __max_op)
  222. #if OMPI_HAVE_FORTRAN_REAL16
  223. FUNC_OP_CREATE(max, freal16, ompi_fortran_real16_t, __max_op)
  224. #endif
  225. FUNC_OP_CREATE(max, int16, int16_t, __max_op)
  226. FUNC_OP_CREATE(max, int32, int32_t, __max_op)
  227. FUNC_OP_CREATE(max, int64, int64_t, __max_op)
  228. /* MIN */
  229. #define __min_op(a, b) ((a) < (b) ? (a) : (b))
  230. FUNC_OP_CREATE(min, short, short, __min_op)
  231. FUNC_OP_CREATE(min, int, int, __min_op)
  232. FUNC_OP_CREATE(min, long, long, __min_op)
  233. FUNC_OP_CREATE(min, longlong, long long, __min_op)
  234. FUNC_OP_CREATE(min, float, float, __min_op)
  235. FUNC_OP_CREATE(min, double, double, __min_op)
  236. FUNC_OP_CREATE(min, longdouble, long double, __min_op)
  237. FUNC_OP_CREATE(min, fint2, ompi_fortran_integer4_t, __min_op)
  238. FUNC_OP_CREATE(min, fint4, ompi_fortran_integer4_t, __min_op)
  239. FUNC_OP_CREATE(min, fint8, ompi_fortran_integer8_t, __min_op)
  240. FUNC_OP_CREATE(min, freal4, ompi_fortran_real4_t, __min_op)
  241. FUNC_OP_CREATE(min, freal8, ompi_fortran_real8_t, __min_op)
  242. #if OMPI_HAVE_FORTRAN_REAL16
  243. FUNC_OP_CREATE(min, freal16, ompi_fortran_real16_t, __min_op)
  244. #endif
  245. FUNC_OP_CREATE(min, int16, int16_t, __min_op)
  246. FUNC_OP_CREATE(min, int32, int32_t, __min_op)
  247. FUNC_OP_CREATE(min, int64, int64_t, __min_op)
  248. /* SUM */
  249. #define __sum_op(a, b) ((a) + (b))
  250. FUNC_OP_CREATE(sum, short, short, __sum_op)
  251. FUNC_OP_CREATE(sum, int, int, __sum_op)
  252. FUNC_OP_CREATE(sum, long, long, __sum_op)
  253. FUNC_OP_CREATE(sum, longlong, long long, __sum_op)
  254. FUNC_OP_CREATE(sum, float, float, __sum_op)
  255. FUNC_OP_CREATE(sum, double, double, __sum_op)
  256. FUNC_OP_CREATE(sum, longdouble, long double, __sum_op)
  257. FUNC_OP_CREATE(sum, complexf, float complex, __sum_op)
  258. FUNC_OP_CREATE(sum, complexd, double complex, __sum_op)
  259. FUNC_OP_CREATE(sum, fint2, ompi_fortran_integer4_t, __sum_op)
  260. FUNC_OP_CREATE(sum, fint4, ompi_fortran_integer4_t, __sum_op)
  261. FUNC_OP_CREATE(sum, fint8, ompi_fortran_integer8_t, __sum_op)
  262. FUNC_OP_CREATE(sum, freal4, ompi_fortran_real4_t, __sum_op)
  263. FUNC_OP_CREATE(sum, freal8, ompi_fortran_real8_t, __sum_op)
  264. #if OMPI_HAVE_FORTRAN_REAL16
  265. FUNC_OP_CREATE(sum, freal16, ompi_fortran_real16_t, __sum_op)
  266. #endif
  267. FUNC_OP_CREATE(sum, int16, int16_t, __sum_op)
  268. FUNC_OP_CREATE(sum, int32, int32_t, __sum_op)
  269. FUNC_OP_CREATE(sum, int64, int64_t, __sum_op)
  270. /* PROD */
  271. #define __prod_op(a, b) ((a) * (b))
  272. FUNC_OP_CREATE(prod, short, short, __prod_op)
  273. FUNC_OP_CREATE(prod, int, int, __prod_op)
  274. FUNC_OP_CREATE(prod, long, long, __prod_op)
  275. FUNC_OP_CREATE(prod, longlong, long long, __prod_op)
  276. FUNC_OP_CREATE(prod, float, float, __prod_op)
  277. FUNC_OP_CREATE(prod, double, double, __prod_op)
  278. FUNC_OP_CREATE(prod, longdouble, long double, __prod_op)
  279. FUNC_OP_CREATE(prod, complexf, float complex, __prod_op)
  280. FUNC_OP_CREATE(prod, complexd, double complex, __prod_op)
  281. FUNC_OP_CREATE(prod, fint2, ompi_fortran_integer2_t, __prod_op)
  282. FUNC_OP_CREATE(prod, fint4, ompi_fortran_integer4_t, __prod_op)
  283. FUNC_OP_CREATE(prod, fint8, ompi_fortran_integer8_t, __prod_op)
  284. FUNC_OP_CREATE(prod, freal4, ompi_fortran_real4_t, __prod_op)
  285. FUNC_OP_CREATE(prod, freal8, ompi_fortran_real8_t, __prod_op)
  286. #if OMPI_HAVE_FORTRAN_REAL16
  287. FUNC_OP_CREATE(prod, freal16, ompi_fortran_real16_t, __prod_op)
  288. #endif
  289. FUNC_OP_CREATE(prod, int16, int16_t, __prod_op)
  290. FUNC_OP_CREATE(prod, int32, int32_t, __prod_op)
  291. FUNC_OP_CREATE(prod, int64, int64_t, __prod_op)
  292. /* SWAP */
  293. #define __swap_op(a, b) (a)
  294. FUNC_OP_CREATE(swap, int, int, __swap_op)
  295. FUNC_OP_CREATE(swap, long, long, __swap_op)
  296. FUNC_OP_CREATE(swap, longlong, long long, __swap_op)
  297. FUNC_OP_CREATE(swap, int32, int32_t, __swap_op)
  298. FUNC_OP_CREATE(swap, int64, int64_t, __swap_op)
  299. int oshmem_op_init(void)
  300. {
  301. /* Setup operation array */
  302. OBJ_CONSTRUCT(&oshmem_op_array, opal_pointer_array_t);
  303. if (OPAL_SUCCESS
  304. != opal_pointer_array_init(&oshmem_op_array,
  305. 0,
  306. INT_MAX,
  307. 1)) {
  308. return OSHMEM_ERROR;
  309. }
  310. /* Bitwise AND */
  311. OBJ_OP_CREATE(and, short, short, OSHMEM_OP_AND, OSHMEM_OP_TYPE_SHORT);
  312. OBJ_OP_CREATE(and, int, int, OSHMEM_OP_AND, OSHMEM_OP_TYPE_INT);
  313. OBJ_OP_CREATE(and, long, long, OSHMEM_OP_AND, OSHMEM_OP_TYPE_LONG);
  314. OBJ_OP_CREATE(and, longlong, long long, OSHMEM_OP_AND, OSHMEM_OP_TYPE_LLONG);
  315. OBJ_OP_CREATE(and, fint2, ompi_fortran_integer2_t, OSHMEM_OP_AND, OSHMEM_OP_TYPE_FINT2);
  316. OBJ_OP_CREATE(and, fint4, ompi_fortran_integer4_t, OSHMEM_OP_AND, OSHMEM_OP_TYPE_FINT4);
  317. OBJ_OP_CREATE(and, fint8, ompi_fortran_integer8_t, OSHMEM_OP_AND, OSHMEM_OP_TYPE_FINT8);
  318. OBJ_OP_CREATE(and, int16, int16_t, OSHMEM_OP_AND, OSHMEM_OP_TYPE_INT16_T);
  319. OBJ_OP_CREATE(and, int32, int32_t, OSHMEM_OP_AND, OSHMEM_OP_TYPE_INT32_T);
  320. OBJ_OP_CREATE(and, int64, int64_t, OSHMEM_OP_AND, OSHMEM_OP_TYPE_INT64_T);
  321. /* Bitwise OR */
  322. OBJ_OP_CREATE(or, short, short, OSHMEM_OP_OR, OSHMEM_OP_TYPE_SHORT);
  323. OBJ_OP_CREATE(or, int, int, OSHMEM_OP_OR, OSHMEM_OP_TYPE_INT);
  324. OBJ_OP_CREATE(or, long, long, OSHMEM_OP_OR, OSHMEM_OP_TYPE_LONG);
  325. OBJ_OP_CREATE(or, longlong, long long, OSHMEM_OP_OR, OSHMEM_OP_TYPE_LLONG);
  326. OBJ_OP_CREATE(or, fint2, ompi_fortran_integer2_t, OSHMEM_OP_OR, OSHMEM_OP_TYPE_FINT2);
  327. OBJ_OP_CREATE(or, fint4, ompi_fortran_integer4_t, OSHMEM_OP_OR, OSHMEM_OP_TYPE_FINT4);
  328. OBJ_OP_CREATE(or, fint8, ompi_fortran_integer8_t, OSHMEM_OP_OR, OSHMEM_OP_TYPE_FINT8);
  329. OBJ_OP_CREATE(or, int16, int16_t, OSHMEM_OP_OR, OSHMEM_OP_TYPE_INT16_T);
  330. OBJ_OP_CREATE(or, int32, int32_t, OSHMEM_OP_OR, OSHMEM_OP_TYPE_INT32_T);
  331. OBJ_OP_CREATE(or, int64, int64_t, OSHMEM_OP_OR, OSHMEM_OP_TYPE_INT64_T);
  332. /* Bitwise XOR */
  333. OBJ_OP_CREATE(xor, short, short, OSHMEM_OP_XOR, OSHMEM_OP_TYPE_SHORT);
  334. OBJ_OP_CREATE(xor, int, int, OSHMEM_OP_XOR, OSHMEM_OP_TYPE_INT);
  335. OBJ_OP_CREATE(xor, long, long, OSHMEM_OP_XOR, OSHMEM_OP_TYPE_LONG);
  336. OBJ_OP_CREATE(xor, longlong, long long, OSHMEM_OP_XOR, OSHMEM_OP_TYPE_LLONG);
  337. OBJ_OP_CREATE(xor, fint2, ompi_fortran_integer2_t, OSHMEM_OP_XOR, OSHMEM_OP_TYPE_FINT2);
  338. OBJ_OP_CREATE(xor, fint4, ompi_fortran_integer4_t, OSHMEM_OP_XOR, OSHMEM_OP_TYPE_FINT4);
  339. OBJ_OP_CREATE(xor, fint8, ompi_fortran_integer8_t, OSHMEM_OP_XOR, OSHMEM_OP_TYPE_FINT8);
  340. OBJ_OP_CREATE(xor, int16, int16_t, OSHMEM_OP_XOR, OSHMEM_OP_TYPE_INT16_T);
  341. OBJ_OP_CREATE(xor, int32, int32_t, OSHMEM_OP_XOR, OSHMEM_OP_TYPE_INT32_T);
  342. OBJ_OP_CREATE(xor, int64, int64_t, OSHMEM_OP_XOR, OSHMEM_OP_TYPE_INT64_T);
  343. /* MAX */
  344. OBJ_OP_CREATE(max, short, short, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_SHORT);
  345. OBJ_OP_CREATE(max, int, int, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_INT);
  346. OBJ_OP_CREATE(max, long, long, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_LONG);
  347. OBJ_OP_CREATE(max, longlong, long long, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_LLONG);
  348. OBJ_OP_CREATE(max, float, float, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_FLOAT);
  349. OBJ_OP_CREATE(max, double, double, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_DOUBLE);
  350. OBJ_OP_CREATE(max, longdouble, long double, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_LDOUBLE);
  351. OBJ_OP_CREATE(max, fint2, ompi_fortran_integer2_t, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_FINT2);
  352. OBJ_OP_CREATE(max, fint4, ompi_fortran_integer4_t, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_FINT4);
  353. OBJ_OP_CREATE(max, fint8, ompi_fortran_integer8_t, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_FINT8);
  354. OBJ_OP_CREATE(max, freal4, ompi_fortran_real4_t, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_FREAL4);
  355. OBJ_OP_CREATE(max, freal8, ompi_fortran_real8_t, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_FREAL8);
  356. #if OMPI_HAVE_FORTRAN_REAL16
  357. OBJ_OP_CREATE(max, freal16, ompi_fortran_real16_t, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_FREAL16);
  358. #endif
  359. OBJ_OP_CREATE(max, int16, int16_t, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_INT16_T);
  360. OBJ_OP_CREATE(max, int32, int32_t, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_INT32_T);
  361. OBJ_OP_CREATE(max, int64, int64_t, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_INT64_T);
  362. /* MIN */
  363. OBJ_OP_CREATE(min, short, short, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_SHORT);
  364. OBJ_OP_CREATE(min, int, int, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_INT);
  365. OBJ_OP_CREATE(min, long, long, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_LONG);
  366. OBJ_OP_CREATE(min, longlong, long long, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_LLONG);
  367. OBJ_OP_CREATE(min, float, float, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_FLOAT);
  368. OBJ_OP_CREATE(min, double, double, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_DOUBLE);
  369. OBJ_OP_CREATE(min, longdouble, long double, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_LDOUBLE);
  370. OBJ_OP_CREATE(min, fint2, ompi_fortran_integer2_t, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_FINT2);
  371. OBJ_OP_CREATE(min, fint4, ompi_fortran_integer4_t, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_FINT4);
  372. OBJ_OP_CREATE(min, fint8, ompi_fortran_integer8_t, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_FINT8);
  373. OBJ_OP_CREATE(min, freal4, ompi_fortran_real4_t, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_FREAL4);
  374. OBJ_OP_CREATE(min, freal8, ompi_fortran_real8_t, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_FREAL8);
  375. #if OMPI_HAVE_FORTRAN_REAL16
  376. OBJ_OP_CREATE(min, freal16, ompi_fortran_real16_t, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_FREAL16);
  377. #endif
  378. OBJ_OP_CREATE(min, int16, int16_t, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_INT16_T);
  379. OBJ_OP_CREATE(min, int32, int32_t, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_INT32_T);
  380. OBJ_OP_CREATE(min, int64, int64_t, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_INT64_T);
  381. /* SUM */
  382. OBJ_OP_CREATE(sum, short, short, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_SHORT);
  383. OBJ_OP_CREATE(sum, int, int, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_INT);
  384. OBJ_OP_CREATE(sum, long, long, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_LONG);
  385. OBJ_OP_CREATE(sum, longlong, long long, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_LLONG);
  386. OBJ_OP_CREATE(sum, float, float, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_FLOAT);
  387. OBJ_OP_CREATE(sum, double, double, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_DOUBLE);
  388. OBJ_OP_CREATE(sum, longdouble, long double, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_LDOUBLE);
  389. OBJ_OP_CREATE(sum, complexf, float complex, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_FCOMPLEX);
  390. OBJ_OP_CREATE(sum, complexd, double complex, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_DCOMPLEX);
  391. OBJ_OP_CREATE(sum, fint2, ompi_fortran_integer2_t, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_FINT2);
  392. OBJ_OP_CREATE(sum, fint4, ompi_fortran_integer4_t, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_FINT4);
  393. OBJ_OP_CREATE(sum, fint8, ompi_fortran_integer8_t, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_FINT8);
  394. OBJ_OP_CREATE(sum, freal4, ompi_fortran_real4_t, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_FREAL4);
  395. OBJ_OP_CREATE(sum, freal8, ompi_fortran_real8_t, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_FREAL8);
  396. #if OMPI_HAVE_FORTRAN_REAL16
  397. OBJ_OP_CREATE(sum, freal16, ompi_fortran_real16_t, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_FREAL16);
  398. #endif
  399. OBJ_OP_CREATE(sum, int16, int16_t, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_INT16_T);
  400. OBJ_OP_CREATE(sum, int32, int32_t, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_INT32_T);
  401. OBJ_OP_CREATE(sum, int64, int64_t, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_INT64_T);
  402. /* PROD */
  403. OBJ_OP_CREATE(prod, short, short, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_SHORT);
  404. OBJ_OP_CREATE(prod, int, int, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_INT);
  405. OBJ_OP_CREATE(prod, long, long, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_LONG);
  406. OBJ_OP_CREATE(prod, longlong, long long, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_LLONG);
  407. OBJ_OP_CREATE(prod, float, float, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_FLOAT);
  408. OBJ_OP_CREATE(prod, double, double, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_DOUBLE);
  409. OBJ_OP_CREATE(prod, longdouble, long double, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_LDOUBLE);
  410. OBJ_OP_CREATE(prod, complexf, float complex, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_FCOMPLEX);
  411. OBJ_OP_CREATE(prod, complexd, double complex, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_DCOMPLEX);
  412. OBJ_OP_CREATE(prod, fint2, ompi_fortran_integer2_t, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_FINT2);
  413. OBJ_OP_CREATE(prod, fint4, ompi_fortran_integer4_t, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_FINT4);
  414. OBJ_OP_CREATE(prod, fint8, ompi_fortran_integer8_t, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_FINT8);
  415. OBJ_OP_CREATE(prod, freal4, ompi_fortran_real4_t, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_FREAL4);
  416. OBJ_OP_CREATE(prod, freal8, ompi_fortran_real8_t, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_FREAL8);
  417. #if OMPI_HAVE_FORTRAN_REAL16
  418. OBJ_OP_CREATE(prod, freal16, ompi_fortran_real16_t, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_FREAL16);
  419. #endif
  420. OBJ_OP_CREATE(prod, int16, int16_t, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_INT16_T);
  421. OBJ_OP_CREATE(prod, int32, int32_t, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_INT32_T);
  422. OBJ_OP_CREATE(prod, int64, int64_t, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_INT64_T);
  423. /* SWAP */
  424. /* swap op is not used in reduce operations, let's set ID to invalid
  425. * value (will not affect to any collective) */
  426. OBJ_OP_CREATE(swap, int, int, OSHMEM_OP_NUMBER, OSHMEM_OP_TYPE_INT);
  427. OBJ_OP_CREATE(swap, long, long, OSHMEM_OP_NUMBER, OSHMEM_OP_TYPE_LONG);
  428. OBJ_OP_CREATE(swap, longlong, long long, OSHMEM_OP_NUMBER, OSHMEM_OP_TYPE_LLONG);
  429. OBJ_OP_CREATE(swap, int32, int32_t, OSHMEM_OP_NUMBER, OSHMEM_OP_TYPE_INT32_T);
  430. OBJ_OP_CREATE(swap, int64, int64_t, OSHMEM_OP_NUMBER, OSHMEM_OP_TYPE_INT64_T);
  431. return OSHMEM_SUCCESS;
  432. }
  433. int oshmem_op_finalize(void)
  434. {
  435. int max, i;
  436. oshmem_op_t *op;
  437. /* Check whether we have some left */
  438. max = opal_pointer_array_get_size(&oshmem_op_array);
  439. for (i = 0; i < max; i++) {
  440. op = (oshmem_op_t *) opal_pointer_array_get_item(&oshmem_op_array, i);
  441. if (NULL != op) {
  442. OBJ_RELEASE(op);
  443. }
  444. }
  445. OBJ_DESTRUCT(&oshmem_op_array);
  446. return OSHMEM_SUCCESS;
  447. }
  448. /**************************************************************************
  449. *
  450. * Static functions
  451. *
  452. **************************************************************************/
  453. /*
  454. * Op constructor
  455. */
  456. static void oshmem_op_construct(oshmem_op_t *object)
  457. {
  458. object->id = opal_pointer_array_add(&oshmem_op_array, object);
  459. }
  460. /*
  461. * Op destructor
  462. */
  463. static void oshmem_op_destruct(oshmem_op_t *object)
  464. {
  465. if (NULL != opal_pointer_array_get_item(&oshmem_op_array, object->id)) {
  466. opal_pointer_array_set_item(&oshmem_op_array, object->id, NULL );
  467. }
  468. }