|
19 | 19 | #include "oshmem/shmem/shmem_api_logger.h" |
20 | 20 |
|
21 | 21 | #include "oshmem/runtime/runtime.h" |
| 22 | +#include "oshmem/mca/memheap/memheap.h" |
| 23 | +#include "oshmem/mca/memheap/base/base.h" |
| 24 | + |
22 | 25 |
|
23 | 26 | #if OSHMEM_PROFILING |
24 | 27 | #include "oshmem/include/pshmem.h" |
25 | 28 | #pragma weak shmem_ptr = pshmem_ptr |
26 | 29 | #include "oshmem/shmem/c/profile/defines.h" |
27 | 30 | #endif |
28 | 31 |
|
29 | | -void *shmem_ptr(const void *ptr, int pe) |
| 32 | +void *shmem_ptr(const void *dst_addr, int pe) |
30 | 33 | { |
31 | | - SHMEM_API_VERBOSE(10, |
32 | | - "*************** WARNING!!! NOT SUPPORTED FUNCTION **********************\n" |
33 | | - "shmem_ptr() function is available only on systems where ordinary memory loads\n" |
34 | | - "and stores are used to implement OpenSHMEM put and get operations."); |
35 | | - return 0; |
| 34 | + ompi_proc_t *proc; |
| 35 | + sshmem_mkey_t *mkey; |
| 36 | + int i; |
| 37 | + void *rva; |
| 38 | + |
| 39 | + RUNTIME_CHECK_INIT(); |
| 40 | + RUNTIME_CHECK_PE(pe); |
| 41 | + RUNTIME_CHECK_ADDR(dst_addr); |
| 42 | + |
| 43 | + /* process can access its own memory */ |
| 44 | + if (pe == oshmem_my_proc_id()) { |
| 45 | + return (void *)dst_addr; |
| 46 | + } |
| 47 | + |
| 48 | + /* The memory must be on the local node */ |
| 49 | + proc = oshmem_proc_group_find(oshmem_group_all, pe); |
| 50 | + if (!OPAL_PROC_ON_LOCAL_NODE(proc->super.proc_flags)) { |
| 51 | + return NULL; |
| 52 | + } |
| 53 | + |
| 54 | + for (i = 0; i < mca_memheap_base_num_transports(); i++) { |
| 55 | + mkey = mca_memheap_base_get_cached_mkey(pe, (void *)dst_addr, i, &rva); |
| 56 | + if (!mkey) { |
| 57 | + continue; |
| 58 | + } |
| 59 | + |
| 60 | + if (mca_memheap_base_mkey_is_shm(mkey)) { |
| 61 | + return rva; |
| 62 | + } |
| 63 | + |
| 64 | + rva = MCA_SPML_CALL(rmkey_ptr(dst_addr, mkey, pe)); |
| 65 | + if (rva != NULL) { |
| 66 | + return rva; |
| 67 | + } |
| 68 | + } |
| 69 | + |
| 70 | + return NULL; |
36 | 71 | } |
0 commit comments