|
| 1 | +/* |
| 2 | + * Copyright (c) 2016 Mellanox Technologies, Inc. |
| 3 | + * All rights reserved. |
| 4 | + * $COPYRIGHT$ |
| 5 | + * |
| 6 | + * Additional copyrights may follow |
| 7 | + * |
| 8 | + * $HEADER$ |
| 9 | + */ |
| 10 | +#include "oshmem_config.h" |
| 11 | + |
| 12 | +#include "oshmem/constants.h" |
| 13 | +#include "oshmem/include/shmem.h" |
| 14 | + |
| 15 | +#include "oshmem/runtime/runtime.h" |
| 16 | + |
| 17 | +#include "oshmem/mca/spml/spml.h" |
| 18 | + |
| 19 | +/* |
| 20 | + * The nonblocking put routines provide a method for copying data from a contiguous local data |
| 21 | + * object to a data object on a specified PE. |
| 22 | + * These routines transfer nelems elements of the data object at address source on the calling |
| 23 | + * PE, to the data object at address target on the remote PE pe. These routines start the |
| 24 | + * remote transfer and may return before the data is delivered to the remote PE. The delivery |
| 25 | + * of data into the data object on the destination PE from different put calls may occur in any |
| 26 | + * order. Because of this, two successive put operations may deliver data out of order unless a |
| 27 | + * call to shmem_fence() is introduced between the two calls. |
| 28 | + * The routines return after posting the operation. The operation is considered complete after a |
| 29 | + * subsequent call to shmem_quiet. At the completion of shmem_quiet, the data has been copied |
| 30 | + * into the dest array on the destination PE. |
| 31 | + */ |
| 32 | +#define SHMEM_TYPE_PUT_NB(type_name, type) \ |
| 33 | + void shmem##type_name##_put_nbi(type *target, const type *source, size_t len, int pe) \ |
| 34 | + { \ |
| 35 | + int rc = OSHMEM_SUCCESS; \ |
| 36 | + size_t size = 0; \ |
| 37 | + \ |
| 38 | + RUNTIME_CHECK_INIT(); \ |
| 39 | + RUNTIME_CHECK_PE(pe); \ |
| 40 | + RUNTIME_CHECK_ADDR(target); \ |
| 41 | + \ |
| 42 | + size = len * sizeof(type); \ |
| 43 | + rc = MCA_SPML_CALL(put_nb( \ |
| 44 | + (void *)target, \ |
| 45 | + size, \ |
| 46 | + (void *)source, \ |
| 47 | + pe, NULL)); \ |
| 48 | + RUNTIME_CHECK_RC(rc); \ |
| 49 | + \ |
| 50 | + return ; \ |
| 51 | + } |
| 52 | + |
| 53 | +#if OSHMEM_PROFILING |
| 54 | +#include "oshmem/include/pshmem.h" |
| 55 | +#pragma weak shmem_char_put_nbi = pshmem_char_put_nbi |
| 56 | +#pragma weak shmem_short_put_nbi = pshmem_short_put_nbi |
| 57 | +#pragma weak shmem_int_put_nbi = pshmem_int_put_nbi |
| 58 | +#pragma weak shmem_long_put_nbi = pshmem_long_put_nbi |
| 59 | +#pragma weak shmem_longlong_put_nbi = pshmem_longlong_put_nbi |
| 60 | +#pragma weak shmem_float_put_nbi = pshmem_float_put_nbi |
| 61 | +#pragma weak shmem_double_put_nbi = pshmem_double_put_nbi |
| 62 | +#pragma weak shmem_longdouble_put_nbi = pshmem_longdouble_put_nbi |
| 63 | +#pragma weak shmem_put8_nbi = pshmem_put8_nbi |
| 64 | +#pragma weak shmem_put16_nbi = pshmem_put16_nbi |
| 65 | +#pragma weak shmem_put32_nbi = pshmem_put32_nbi |
| 66 | +#pragma weak shmem_put64_nbi = pshmem_put64_nbi |
| 67 | +#pragma weak shmem_put128_nbi = pshmem_put128_nbi |
| 68 | +#pragma weak shmem_putmem_nbi = pshmem_putmem_nbi |
| 69 | +#include "oshmem/shmem/c/profile/defines.h" |
| 70 | +#endif |
| 71 | + |
| 72 | +SHMEM_TYPE_PUT_NB(_char, char) |
| 73 | +SHMEM_TYPE_PUT_NB(_short, short) |
| 74 | +SHMEM_TYPE_PUT_NB(_int, int) |
| 75 | +SHMEM_TYPE_PUT_NB(_long, long) |
| 76 | +SHMEM_TYPE_PUT_NB(_longlong, long long) |
| 77 | +SHMEM_TYPE_PUT_NB(_float, float) |
| 78 | +SHMEM_TYPE_PUT_NB(_double, double) |
| 79 | +SHMEM_TYPE_PUT_NB(_longdouble, long double) |
| 80 | + |
| 81 | +#define SHMEM_TYPE_PUTMEM_NB(name, element_size, prefix) \ |
| 82 | + void prefix##name##_nbi(void *target, const void *source, size_t nelems, int pe) \ |
| 83 | + { \ |
| 84 | + int rc = OSHMEM_SUCCESS; \ |
| 85 | + size_t size = 0; \ |
| 86 | + \ |
| 87 | + RUNTIME_CHECK_INIT(); \ |
| 88 | + RUNTIME_CHECK_PE(pe); \ |
| 89 | + RUNTIME_CHECK_ADDR(target); \ |
| 90 | + \ |
| 91 | + size = nelems * element_size; \ |
| 92 | + rc = MCA_SPML_CALL(put_nb( \ |
| 93 | + (void *)target, \ |
| 94 | + size, \ |
| 95 | + (void *)source, \ |
| 96 | + pe, NULL)); \ |
| 97 | + RUNTIME_CHECK_RC(rc); \ |
| 98 | + \ |
| 99 | + return ; \ |
| 100 | + } |
| 101 | + |
| 102 | +SHMEM_TYPE_PUTMEM_NB(_put8, 1, shmem) |
| 103 | +SHMEM_TYPE_PUTMEM_NB(_put16, 2, shmem) |
| 104 | +SHMEM_TYPE_PUTMEM_NB(_put32, 4, shmem) |
| 105 | +SHMEM_TYPE_PUTMEM_NB(_put64, 8, shmem) |
| 106 | +SHMEM_TYPE_PUTMEM_NB(_put128, 16, shmem) |
| 107 | +SHMEM_TYPE_PUTMEM_NB(_putmem, 1, shmem) |
0 commit comments