root/oshmem/shmem/c/shmem_ptr.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. shmem_ptr

   1 /*
   2  * Copyright (c) 2013      Mellanox Technologies, Inc.
   3  *                         All rights reserved.
   4  * Copyright (c) 2019      Research Organization for Information Science
   5  *                         and Technology (RIST).  All rights reserved.
   6  * $COPYRIGHT$
   7  *
   8  * Additional copyrights may follow
   9  *
  10  * $HEADER$
  11  */
  12 
  13 #include "oshmem_config.h"
  14 
  15 #include <stdlib.h>
  16 
  17 #include "oshmem/constants.h"
  18 #include "oshmem/include/shmem.h"
  19 #include "oshmem/shmem/shmem_api_logger.h"
  20 
  21 #include "oshmem/runtime/runtime.h"
  22 #include "oshmem/mca/memheap/memheap.h"
  23 #include "oshmem/mca/memheap/base/base.h"
  24 
  25 
  26 #if OSHMEM_PROFILING
  27 #include "oshmem/include/pshmem.h"
  28 #pragma weak shmem_ptr = pshmem_ptr
  29 #include "oshmem/shmem/c/profile/defines.h"
  30 #endif
  31 
  32 void *shmem_ptr(const void *dst_addr, int pe)
  33 {
  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         /* TODO: iterate on all ctxs, try to get cached mkeys */
  56         mkey = mca_memheap_base_get_cached_mkey(oshmem_ctx_default, pe, (void *)dst_addr, i, &rva);
  57         if (!mkey) {
  58             continue;
  59         }
  60 
  61         if (mca_memheap_base_mkey_is_shm(mkey)) {
  62             return rva;
  63         }
  64 
  65         rva = MCA_SPML_CALL(rmkey_ptr(dst_addr, mkey, pe));
  66         if (rva != NULL) {
  67             return rva;
  68         }
  69     }
  70 
  71     return NULL;
  72 }

/* [<][>][^][v][top][bottom][index][help] */