/** * opal_carto_base_get_nodes_distance - returns the distance of * all the nodes from the reference node. * * @param graph * @param reference_node * @param node_type the type of the nodes in the returned array * @param dist_array * * @return int number of nodes in the returned array. */ int opal_carto_base_get_nodes_distance_fn(opal_carto_graph_t *graph, opal_carto_base_node_t *reference_node, const char *node_type, opal_value_array_t *dist_array) { opal_value_array_t *distance_array; vertex_distance_from_t *vertex_distance; opal_carto_base_node_t *node; uint32_t i, graph_order; int distance_array_size; opal_carto_node_distance_t node_distance; distance_array = OBJ_NEW(opal_value_array_t); opal_value_array_init(distance_array, sizeof(vertex_distance_from_t)); opal_value_array_reserve(distance_array,50); /* use dijkstra algorithm to receive the distance of all the nodes from the referenced node */ graph_order = opal_graph_dijkstra(graph, reference_node->vertex, distance_array); /* for all the nodes in the dijkstra array */ for (i = 0, distance_array_size = 0; i < graph_order; i++) { vertex_distance = opal_value_array_get_item(distance_array, i); node = vertex_distance->vertex->vertex_data; /* check if the node is in the correct type */ if (NULL == node_type || 0 == strcmp(node->node_type, node_type)) { /* assigne the result distance array */ node_distance.node = vertex_distance->vertex->vertex_data; node_distance.node_distance = vertex_distance->weight; opal_value_array_append_item(dist_array, (void *)&node_distance); } } /* return the result distance array */ return distance_array_size; }
uint32_t opal_graph_spf(opal_graph_t *graph, opal_graph_vertex_t *vertex1, opal_graph_vertex_t *vertex2) { opal_value_array_t *distance_array; uint32_t items_in_distance_array, spf = DISTANCE_INFINITY; vertex_distance_from_t *vertex_distance; uint32_t i; /** * Verify that the first vertex belongs to the graph. */ if (graph != vertex1->in_graph) { OPAL_OUTPUT((0,"opal_graph_spf 1 Vertex1 %p not in the graph %p\n",(void *)vertex1,(void *)graph)); return DISTANCE_INFINITY; } /** * Verify that the second vertex belongs to the graph. */ if (graph != vertex2->in_graph) { OPAL_OUTPUT((0,"opal_graph_spf 2 Vertex2 %p not in the graph %p\n",(void *)vertex2,(void *)graph)); return DISTANCE_INFINITY; } /** * Run Dijkstra algorithm on the graph from the start vertex. */ distance_array = OBJ_NEW(opal_value_array_t); opal_value_array_init(distance_array, sizeof(vertex_distance_from_t)); opal_value_array_reserve(distance_array,50); items_in_distance_array = opal_graph_dijkstra(graph, vertex1, distance_array); /** * find the end vertex in the distance array that Dijkstra * algorithm returned. */ for (i = 0; i < items_in_distance_array; i++) { vertex_distance = opal_value_array_get_item(distance_array, i); if (vertex_distance->vertex == vertex2) { spf = vertex_distance->weight; break; } } OBJ_RELEASE(distance_array); /* return the distance (weight) to the end vertex */ return spf; }
/* ////////////////////////////////////////////////////////////////////////// */ static int verbs_runtime_query(mca_base_module_t **module, int *priority, const char *hint) { int rc = OSHMEM_SUCCESS; openib_device_t my_device; openib_device_t *device = &my_device; int num_devs = 0; int i = 0; *priority = 0; *module = NULL; memset(device, 0, sizeof(*device)); #ifdef HAVE_IBV_GET_DEVICE_LIST device->ib_devs = ibv_get_device_list(&num_devs); #else #error unsupported ibv_get_device_list in infiniband/verbs.h #endif if (num_devs == 0 || !device->ib_devs) { return OSHMEM_ERR_NOT_SUPPORTED; } /* Open device */ if (NULL != mca_sshmem_verbs_component.hca_name) { for (i = 0; i < num_devs; i++) { if (0 == strcmp(mca_sshmem_verbs_component.hca_name, ibv_get_device_name(device->ib_devs[i]))) { device->ib_dev = device->ib_devs[i]; break; } } } else { device->ib_dev = device->ib_devs[0]; } if (NULL == device->ib_dev) { rc = OSHMEM_ERR_NOT_FOUND; goto out; } if (NULL == (device->ib_dev_context = ibv_open_device(device->ib_dev))) { rc = OSHMEM_ERR_RESOURCE_BUSY; goto out; } /* Obtain device attributes */ if (ibv_query_device(device->ib_dev_context, &device->ib_dev_attr)) { rc = OSHMEM_ERR_RESOURCE_BUSY; goto out; } /* Allocate the protection domain for the device */ device->ib_pd = ibv_alloc_pd(device->ib_dev_context); if (NULL == device->ib_pd) { rc = OSHMEM_ERR_RESOURCE_BUSY; goto out; } /* Allocate memory */ if (!rc) { void *addr = NULL; size_t size = getpagesize(); struct ibv_mr *ib_mr = NULL; uint64_t access_flag = IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE | IBV_ACCESS_REMOTE_READ; uint64_t exp_access_flag = 0; OBJ_CONSTRUCT(&device->ib_mr_array, opal_value_array_t); opal_value_array_init(&device->ib_mr_array, sizeof(struct ibv_mr *)); #if defined(MPAGE_ENABLE) && (MPAGE_ENABLE > 0) exp_access_flag = IBV_EXP_ACCESS_ALLOCATE_MR | IBV_EXP_ACCESS_SHARED_MR_USER_READ | IBV_EXP_ACCESS_SHARED_MR_USER_WRITE; #endif /* MPAGE_ENABLE */ struct ibv_exp_reg_mr_in in = {device->ib_pd, addr, size, access_flag|exp_access_flag, 0}; ib_mr = ibv_exp_reg_mr(&in); if (NULL == ib_mr) { rc = OSHMEM_ERR_OUT_OF_RESOURCE; } else { device->ib_mr_shared = ib_mr; opal_value_array_append_item(&device->ib_mr_array, &ib_mr); } #if defined(MPAGE_ENABLE) && (MPAGE_ENABLE > 0) if (!rc) { struct ibv_exp_reg_shared_mr_in in_smr; access_flag = IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE | IBV_ACCESS_REMOTE_READ| IBV_EXP_ACCESS_NO_RDMA; addr = (void *)mca_sshmem_base_start_address; mca_sshmem_verbs_fill_shared_mr(&in_smr, device->ib_pd, device->ib_mr_shared->handle, addr, access_flag); ib_mr = ibv_exp_reg_shared_mr(&in_smr); if (NULL == ib_mr) { mca_sshmem_verbs_component.has_shared_mr = 0; } else { opal_value_array_append_item(&device->ib_mr_array, &ib_mr); mca_sshmem_verbs_component.has_shared_mr = 1; } } #endif /* MPAGE_ENABLE */ } /* all is well - rainbows and butterflies */ if (!rc) { *priority = mca_sshmem_verbs_component.priority; *module = (mca_base_module_t *)&mca_sshmem_verbs_module.super; } out: if (device) { if (opal_value_array_get_size(&device->ib_mr_array)) { struct ibv_mr** array; struct ibv_mr* ib_mr = NULL; array = OPAL_VALUE_ARRAY_GET_BASE(&device->ib_mr_array, struct ibv_mr *); while (opal_value_array_get_size(&device->ib_mr_array) > 0) { ib_mr = array[0]; ibv_dereg_mr(ib_mr); opal_value_array_remove_item(&device->ib_mr_array, 0); } if (device->ib_mr_shared) { device->ib_mr_shared = NULL; } OBJ_DESTRUCT(&device->ib_mr_array); } if (device->ib_pd) { ibv_dealloc_pd(device->ib_pd); device->ib_pd = NULL; } if(device->ib_dev_context) { ibv_close_device(device->ib_dev_context); device->ib_dev_context = NULL; } if(device->ib_devs) { ibv_free_device_list(device->ib_devs); device->ib_devs = NULL; } } return rc; }
int main(int argc, char* argv[]) { int rank, size, distance, distance_array_size, i; opal_carto_graph_t *graph; opal_carto_base_node_t *slot0, *end_node; opal_carto_node_distance_t *node_distance; opal_value_array_t *distance_array; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); printf("Hello, world, I am %d of %d\n", rank, size); if (0 == rank) { /** * */ opal_output(0," \n\nget_host_graph Full\n"); opal_carto_base_get_host_graph(&graph,NULL); opal_graph_print(graph); slot0 = opal_carto_base_find_node(graph, "slot0"); if (NULL == slot0) { opal_output(0,"couldnt find slot0 in the graph exiting\n"); opal_carto_base_free_graph(graph); return -1; } end_node = opal_carto_base_find_node(graph, "slot3"); if (NULL == end_node) { opal_output(0,"couldnt find mthca1 in the graph exiting\n"); opal_carto_base_free_graph(graph); return -1; } distance = opal_carto_base_spf(graph, slot0, end_node); opal_output(0,"\nThe distance between slot0 and slot3 is %d\n",distance); distance_array = OBJ_NEW(opal_value_array_t); opal_value_array_init(distance_array, sizeof(opal_carto_node_distance_t)); opal_value_array_reserve(distance_array, 50); distance_array_size = opal_carto_base_get_nodes_distance(graph, slot0, NULL, distance_array); for (i=0; i < distance_array_size; i++) { node_distance = opal_value_array_get_item(distance_array, i); opal_output(0,"Node %s distance from slot0 is %d\n",node_distance->node->node_name, node_distance->node_distance); } OBJ_RELEASE(distance_array); opal_carto_base_free_graph(graph); /** * */ opal_output(0," \n\nget_host_graph Infiniband\n"); opal_carto_base_get_host_graph(&graph,"Infiniband"); opal_graph_print(graph); slot0 = opal_carto_base_find_node(graph, "slot0"); if (NULL == slot0) { opal_output(0,"couldnt find slot0 in the graph exiting\n"); opal_carto_base_free_graph(graph); return -1; } end_node = opal_carto_base_find_node(graph, "mthca1"); if (NULL == end_node) { opal_output(0,"couldnt find mthca1 in the graph exiting\n"); opal_carto_base_free_graph(graph); return -1; } distance = opal_carto_base_spf(graph, slot0, end_node); opal_output(0,"\nThe distance between slot0 and mthca1 is %d\n",distance); distance_array = OBJ_NEW(opal_value_array_t); opal_value_array_init(distance_array, sizeof(opal_carto_node_distance_t)); opal_value_array_reserve(distance_array, 50); distance_array_size = opal_carto_base_get_nodes_distance(graph, slot0, "Infiniband", distance_array); for (i=0; i < distance_array_size; i++) { node_distance = opal_value_array_get_item(distance_array, i); opal_output(0,"Node %s distance from slot0 is %d\n",node_distance->node->node_name, node_distance->node_distance); } OBJ_RELEASE(distance_array); opal_carto_base_free_graph(graph); /** * */ opal_output(0," \n\nget_host_graph Ethernet\n"); opal_carto_base_get_host_graph(&graph,"Ethernet"); opal_graph_print(graph); slot0 = opal_carto_base_find_node(graph, "slot0"); if (NULL == slot0) { opal_output(0,"couldnt find slot0 in the graph exiting\n"); opal_carto_base_free_graph(graph); return -1; } end_node = opal_carto_base_find_node(graph, "eth1"); if (NULL == end_node) { opal_output(0,"couldnt find mthca1 in the graph exiting\n"); opal_carto_base_free_graph(graph); return -1; } distance = opal_carto_base_spf(graph, slot0, end_node); opal_output(0,"\nThe distance between slot0 and eth1 is %d\n",distance); distance_array = OBJ_NEW(opal_value_array_t); opal_value_array_init(distance_array, sizeof(opal_carto_node_distance_t)); opal_value_array_reserve(distance_array, 50); distance_array_size = opal_carto_base_get_nodes_distance(graph, slot0, "Ethernet", distance_array); for (i=0; i < distance_array_size; i++) { node_distance = opal_value_array_get_item(distance_array, i); opal_output(0,"Node %s distance from slot0 is %d\n",node_distance->node->node_name, node_distance->node_distance); } OBJ_RELEASE(distance_array); opal_carto_base_free_graph(graph); /** * */ opal_output(0," \n\nget_host_graph Memory\n"); opal_carto_base_get_host_graph(&graph,"Memory"); opal_graph_print(graph); slot0 = opal_carto_base_find_node(graph, "slot0"); if (NULL == slot0) { opal_output(0,"couldnt find slot0 in the graph exiting\n"); opal_carto_base_free_graph(graph); return -1; } end_node = opal_carto_base_find_node(graph, "mem3"); if (NULL == end_node) { opal_output(0,"couldnt find mthca1 in the graph exiting\n"); opal_carto_base_free_graph(graph); return -1; } distance = opal_carto_base_spf(graph, slot0, end_node); opal_output(0,"\nThe distance between slot0 and mem3 is %d\n",distance); distance_array = OBJ_NEW(opal_value_array_t); opal_value_array_init(distance_array, sizeof(opal_carto_node_distance_t)); opal_value_array_reserve(distance_array, 50); distance_array_size = opal_carto_base_get_nodes_distance(graph, slot0, "Memory", distance_array); for (i=0; i < distance_array_size; i++) { node_distance = opal_value_array_get_item(distance_array, i); opal_output(0,"Node %s distance from slot0 is %d\n",node_distance->node->node_name, node_distance->node_distance); } OBJ_RELEASE(distance_array); opal_carto_base_free_graph(graph); } MPI_Barrier(MPI_COMM_WORLD); MPI_Finalize(); return 0; }
/* ////////////////////////////////////////////////////////////////////////// */ static int segment_create(map_segment_t *ds_buf, const char *file_name, size_t size) { int rc = OSHMEM_SUCCESS; openib_device_t *device = &memheap_device; int num_devs = 0; int i = 0; assert(ds_buf); /* init the contents of map_segment_t */ shmem_ds_reset(ds_buf); memset(device, 0, sizeof(*device)); #ifdef HAVE_IBV_GET_DEVICE_LIST device->ib_devs = ibv_get_device_list(&num_devs); #else #error unsupported ibv_get_device_list in infiniband/verbs.h #endif if (num_devs == 0 || !device->ib_devs) { return OSHMEM_ERR_NOT_SUPPORTED; } /* Open device */ if (NULL != mca_sshmem_verbs_component.hca_name) { for (i = 0; i < num_devs; i++) { if (0 == strcmp(mca_sshmem_verbs_component.hca_name, ibv_get_device_name(device->ib_devs[i]))) { device->ib_dev = device->ib_devs[i]; break; } } } else { device->ib_dev = device->ib_devs[0]; } if (NULL == device->ib_dev) { OPAL_OUTPUT_VERBOSE( (5, oshmem_sshmem_base_framework.framework_output, "error getting device says %d: %s", errno, strerror(errno)) ); return OSHMEM_ERR_NOT_FOUND; } if (NULL == (device->ib_dev_context = ibv_open_device(device->ib_dev))) { OPAL_OUTPUT_VERBOSE( (5, oshmem_sshmem_base_framework.framework_output, "error obtaining device context for %s errno says %d: %s", ibv_get_device_name(device->ib_dev), errno, strerror(errno)) ); return OSHMEM_ERR_RESOURCE_BUSY; } /* Obtain device attributes */ if (ibv_query_device(device->ib_dev_context, &device->ib_dev_attr)) { OPAL_OUTPUT_VERBOSE( (5, oshmem_sshmem_base_framework.framework_output, "error obtaining device attributes for %s errno says %d: %s", ibv_get_device_name(device->ib_dev), errno, strerror(errno)) ); return OSHMEM_ERR_RESOURCE_BUSY; } /* Allocate the protection domain for the device */ device->ib_pd = ibv_alloc_pd(device->ib_dev_context); if (NULL == device->ib_pd) { OPAL_OUTPUT_VERBOSE( (5, oshmem_sshmem_base_framework.framework_output, "error allocating protection domain for %s errno says %d: %s", ibv_get_device_name(device->ib_dev), errno, strerror(errno)) ); return OSHMEM_ERR_RESOURCE_BUSY; } /* Allocate memory */ if (!rc) { void *addr = NULL; struct ibv_mr *ib_mr = NULL; uint64_t access_flag = IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE | IBV_ACCESS_REMOTE_READ; uint64_t exp_access_flag = 0; OBJ_CONSTRUCT(&device->ib_mr_array, opal_value_array_t); opal_value_array_init(&device->ib_mr_array, sizeof(struct ibv_mr *)); #if (MPAGE_ENABLE > 0) exp_access_flag = IBV_EXP_ACCESS_ALLOCATE_MR | IBV_EXP_ACCESS_SHARED_MR_USER_READ | IBV_EXP_ACCESS_SHARED_MR_USER_WRITE; #endif /* MPAGE_ENABLE */ struct ibv_exp_reg_mr_in in = {device->ib_pd, addr, size, access_flag|exp_access_flag, 0}; #if MPAGE_HAVE_IBV_EXP_REG_MR_CREATE_FLAGS if (0 == mca_sshmem_verbs_component.has_shared_mr) { in.addr = (void *)mca_sshmem_base_start_address; in.comp_mask = IBV_EXP_REG_MR_CREATE_FLAGS; in.create_flags = IBV_EXP_REG_MR_CREATE_CONTIG; in.exp_access = access_flag; } #endif ib_mr = ibv_exp_reg_mr(&in); if (NULL == ib_mr) { OPAL_OUTPUT_VERBOSE( (5, oshmem_sshmem_base_framework.framework_output, "error to ibv_exp_reg_mr() %llu bytes errno says %d: %s", (unsigned long long)size, errno, strerror(errno)) ); rc = OSHMEM_ERR_OUT_OF_RESOURCE; } else { device->ib_mr_shared = ib_mr; opal_value_array_append_item(&device->ib_mr_array, &ib_mr); } #if (MPAGE_ENABLE > 0) if (!rc && mca_sshmem_verbs_component.has_shared_mr) { void *addr = NULL; access_flag = IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE | IBV_ACCESS_REMOTE_READ| IBV_EXP_ACCESS_NO_RDMA; addr = (void *)mca_sshmem_base_start_address; struct ibv_exp_reg_shared_mr_in in; mca_sshmem_verbs_fill_shared_mr(&in, device->ib_pd, device->ib_mr_shared->handle, addr, access_flag); ib_mr = ibv_exp_reg_shared_mr(&in); if (NULL == ib_mr) { OPAL_OUTPUT_VERBOSE( (5, oshmem_sshmem_base_framework.framework_output, "error to ibv_reg_shared_mr() %llu bytes errno says %d: %s has_shared_mr: %d", (unsigned long long)size, errno, strerror(errno), mca_sshmem_verbs_component.has_shared_mr ) ); rc = OSHMEM_ERR_OUT_OF_RESOURCE; } else { opal_value_array_append_item(&device->ib_mr_array, &ib_mr); } } #endif /* MPAGE_ENABLE */ if (!rc) { OPAL_OUTPUT_VERBOSE( (70, oshmem_sshmem_base_framework.framework_output, "ibv device %s shared_mr: %d", ibv_get_device_name(device->ib_dev), mca_sshmem_verbs_component.has_shared_mr) ); if (mca_sshmem_verbs_component.has_shared_mr) { assert(size == device->ib_mr_shared->length); ds_buf->type = MAP_SEGMENT_ALLOC_IBV; ds_buf->seg_id = device->ib_mr_shared->handle; } else { ds_buf->type = MAP_SEGMENT_ALLOC_IBV_NOSHMR; ds_buf->seg_id = MAP_SEGMENT_SHM_INVALID; } ds_buf->super.va_base = ib_mr->addr; ds_buf->seg_size = size; ds_buf->super.va_end = (void*)((uintptr_t)ds_buf->super.va_base + ds_buf->seg_size); } } OPAL_OUTPUT_VERBOSE( (70, oshmem_sshmem_base_framework.framework_output, "%s: %s: create %s " "(id: %d, addr: %p size: %lu, name: %s)\n", mca_sshmem_verbs_component.super.base_version.mca_type_name, mca_sshmem_verbs_component.super.base_version.mca_component_name, (rc ? "failure" : "successful"), ds_buf->seg_id, ds_buf->super.va_base, (unsigned long)ds_buf->seg_size, ds_buf->seg_name) ); return rc; }
static int _ibv_attach(map_segment_t *s, size_t size) { int rc = OSHMEM_SUCCESS; static openib_device_t memheap_device; openib_device_t *device = &memheap_device; int num_devs = 0; assert(s); memset(device, 0, sizeof(*device)); #ifdef HAVE_IBV_GET_DEVICE_LIST device->ib_devs = ibv_get_device_list(&num_devs); #else #error unsupported ibv_get_device_list in infiniband/verbs.h #endif if (num_devs == 0 || !device->ib_devs) { rc = OSHMEM_ERR_NOT_SUPPORTED; } /* Open device */ if (!rc) { int i = 0; if (num_devs > 1) { if (NULL == mca_memheap_base_param_hca_name) { MEMHEAP_VERBOSE(5, "found %d HCAs, choosing the first", num_devs); } else { MEMHEAP_VERBOSE(5, "found %d HCAs, searching for %s", num_devs, mca_memheap_base_param_hca_name); } } for (i = 0; i < num_devs; i++) { device->ib_dev = device->ib_devs[i]; device->ib_dev_context = ibv_open_device(device->ib_dev); if (NULL == device->ib_dev_context) { MEMHEAP_ERROR("error obtaining device context for %s errno says %d: %s", ibv_get_device_name(device->ib_dev), errno, strerror(errno)); rc = OSHMEM_ERR_RESOURCE_BUSY; } else { if (NULL != mca_memheap_base_param_hca_name) { if (0 == strcmp(mca_memheap_base_param_hca_name,ibv_get_device_name(device->ib_dev))) { MEMHEAP_VERBOSE(5, "mca_memheap_base_param_hca_name = %s, selected %s as %d of %d", mca_memheap_base_param_hca_name, ibv_get_device_name(device->ib_dev), i, num_devs); rc = OSHMEM_SUCCESS; break; } } else { MEMHEAP_VERBOSE(5, "mca_memheap_base_param_hca_name = %s, selected %s as %d of %d", mca_memheap_base_param_hca_name, ibv_get_device_name(device->ib_dev), i, num_devs); rc = OSHMEM_SUCCESS; break; } } } } /* Obtain device attributes */ if (!rc) { if (ibv_query_device(device->ib_dev_context, &device->ib_dev_attr)) { MEMHEAP_ERROR("error obtaining device attributes for %s errno says %d: %s", ibv_get_device_name(device->ib_dev), errno, strerror(errno)); rc = OSHMEM_ERR_RESOURCE_BUSY; } else { MEMHEAP_VERBOSE(5, "ibv device %s", ibv_get_device_name(device->ib_dev)); } } /* Allocate the protection domain for the device */ if (!rc) { device->ib_pd = ibv_alloc_pd(device->ib_dev_context); if (NULL == device->ib_pd) { MEMHEAP_ERROR("error allocating protection domain for %s errno says %d: %s", ibv_get_device_name(device->ib_dev), errno, strerror(errno)); rc = OSHMEM_ERR_RESOURCE_BUSY; } } /* Allocate memory */ if (!rc) { void *addr = NULL; struct ibv_mr *ib_mr = NULL; int access_flag = IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE | IBV_ACCESS_REMOTE_READ; OBJ_CONSTRUCT(&device->ib_mr_array, opal_value_array_t); opal_value_array_init(&device->ib_mr_array, sizeof(struct ibv_mr *)); #if defined(MPAGE_ENABLE) && (MPAGE_ENABLE > 0) access_flag |= IBV_ACCESS_ALLOCATE_MR | IBV_ACCESS_SHARED_MR_USER_READ | IBV_ACCESS_SHARED_MR_USER_WRITE; #endif /* MPAGE_ENABLE */ ib_mr = ibv_reg_mr(device->ib_pd, addr, size, access_flag); if (NULL == ib_mr) { MEMHEAP_ERROR("error to ibv_reg_mr() %llu bytes errno says %d: %s", (unsigned long long)size, errno, strerror(errno)); rc = OSHMEM_ERR_OUT_OF_RESOURCE; } else { device->ib_mr_shared = ib_mr; opal_value_array_append_item(&device->ib_mr_array, &ib_mr); } #if defined(MPAGE_ENABLE) && (MPAGE_ENABLE > 0) if (!rc) { access_flag = IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE | IBV_ACCESS_REMOTE_READ| IBV_ACCESS_NO_RDMA; addr = (void *)mca_memheap_base_start_address; ib_mr = ibv_reg_shared_mr(device->ib_mr_shared->handle, device->ib_pd, addr, access_flag); if (NULL == ib_mr) { MEMHEAP_ERROR("error to ibv_reg_shared_mr() %llu bytes errno says %d: %s", (unsigned long long)size, errno, strerror(errno)); rc = OSHMEM_ERR_OUT_OF_RESOURCE; } else { opal_value_array_append_item(&device->ib_mr_array, &ib_mr); } } #endif /* MPAGE_ENABLE */ if (!rc) { assert(size == device->ib_mr_shared->length); s->type = MAP_SEGMENT_ALLOC_IBV; s->shmid = device->ib_mr_shared->handle; s->start = ib_mr->addr; s->size = size; s->end = (void*)((uintptr_t)s->start + s->size); s->context = &memheap_device; } } return rc; }