/* * One time initialization at startup */ int mca_pml_base_bsend_init(bool thread_safe) { size_t tmp; if(OPAL_THREAD_ADD32(&mca_pml_bsend_init, 1) > 1) return OMPI_SUCCESS; /* initialize static objects */ OBJ_CONSTRUCT(&mca_pml_bsend_mutex, opal_mutex_t); OBJ_CONSTRUCT(&mca_pml_bsend_condition, opal_condition_t); /* lookup name of the allocator to use for buffered sends */ if(NULL == (mca_pml_bsend_allocator_component = mca_allocator_component_lookup(ompi_pml_base_bsend_allocator_name))) { return OMPI_ERR_BUFFER; } /* determine page size */ tmp = mca_pml_bsend_pagesz = sysconf(_SC_PAGESIZE); mca_pml_bsend_pagebits = 0; while( tmp != 0 ) { tmp >>= 1; mca_pml_bsend_pagebits++; } return OMPI_SUCCESS; }
int mca_common_ompio_cuda_alloc_init ( void ) { bool thread_safe=true; if(OPAL_THREAD_ADD_FETCH32(&mca_common_ompio_cuda_init, 1) > 1) return OMPI_SUCCESS; /* initialize static objects */ OBJ_CONSTRUCT(&mca_common_ompio_cuda_mutex, opal_mutex_t); OPAL_THREAD_LOCK (&mca_common_ompio_cuda_mutex ); /* lookup name of the allocator to use */ if(NULL == (mca_common_ompio_allocator_component = mca_allocator_component_lookup("basic"))) { OPAL_THREAD_UNLOCK(&mca_common_ompio_cuda_mutex); return OMPI_ERR_BUFFER; } /* create an instance of the allocator */ mca_common_ompio_allocator = mca_common_ompio_allocator_component->allocator_init(thread_safe, mca_common_ompio_cuda_alloc_seg, mca_common_ompio_cuda_free_seg, NULL); if(NULL == mca_common_ompio_allocator) { OPAL_THREAD_UNLOCK(&mca_common_ompio_cuda_mutex); return OMPI_ERR_BUFFER; } // mca_common_ompio_pagesize = sysconf(_SC_PAGESIZE); mca_common_ompio_pagesize = opal_getpagesize(); OPAL_THREAD_UNLOCK(&mca_common_ompio_cuda_mutex); return OMPI_SUCCESS; }
/* * One time initialization at startup */ int mca_pml_base_bsend_init(bool thread_safe) { char *name; size_t tmp; if(OPAL_THREAD_ADD32(&mca_pml_bsend_init, 1) > 1) return OMPI_SUCCESS; /* initialize static objects */ OBJ_CONSTRUCT(&mca_pml_bsend_mutex, opal_mutex_t); OBJ_CONSTRUCT(&mca_pml_bsend_condition, opal_condition_t); /* lookup name of the allocator to use for buffered sends */ (void) mca_base_param_reg_string_name ("pml", "base_bsend_allocator", NULL, false, false, "basic", &name); if(NULL == (mca_pml_bsend_allocator_component = mca_allocator_component_lookup(name))) { free(name); return OMPI_ERR_BUFFER; } free(name); /* determine page size */ tmp = mca_pml_bsend_pagesz = sysconf(_SC_PAGESIZE); mca_pml_bsend_pagebits = 0; while( tmp != 0 ) { tmp >>= 1; mca_pml_bsend_pagebits++; } return OMPI_SUCCESS; }
mca_mpool_base_module_t *common_sm_mpool_create (mca_common_sm_mpool_resources_t *resources) { mca_common_sm_mpool_module_t *mpool_module; mca_allocator_base_component_t* allocator_component; /* Make a new mpool module */ mpool_module = (mca_common_sm_mpool_module_t *) malloc (sizeof (*mpool_module)); mca_common_sm_mpool_module_init(mpool_module); /* set sm_size */ mpool_module->sm_size = resources->size; allocator_component = mca_allocator_component_lookup(resources->allocator); /* if specified allocator cannot be loaded - look for an alternative */ if (NULL == allocator_component) { if (opal_list_get_size(&opal_allocator_base_framework.framework_components) == 0) { mca_base_component_list_item_t *item = (mca_base_component_list_item_t *) opal_list_get_first(&opal_allocator_base_framework.framework_components); allocator_component = (mca_allocator_base_component_t *)item->cli_component; opal_output( 0, "mca_common_sm_mpool_init: " "unable to locate allocator: %s - using %s\n", resources->allocator, allocator_component->allocator_version.mca_component_name); } else { opal_output(0, "mca_common_sm_mpool_init: " "unable to locate allocator: %s\n", resources->allocator); free(mpool_module); return NULL; } } mpool_module->mem_node = resources->mem_node; if (NULL == (mpool_module->sm_common_module = mca_common_sm_module_attach(&resources->bs_meta_buf, sizeof(mca_common_sm_module_t), 8))) { opal_output(0, "mca_common_sm_mpool_init: " "unable to create shared memory mapping (%s)", resources->bs_meta_buf.seg_name); free(mpool_module); return NULL; } /* setup allocator */ mpool_module->sm_allocator = allocator_component->allocator_init (true, mca_common_sm_seg_alloc, NULL, mpool_module->sm_common_module); if (NULL == mpool_module->sm_allocator) { opal_output(0, "mca_common_sm_mpool_init: unable to initialize allocator"); free(mpool_module); return NULL; } return &mpool_module->super; }
static int mca_pml_csum_component_open(void) { int value; mca_allocator_base_component_t* allocator_component; value = mca_pml_csum_param_register_int("verbose", 0); mca_pml_csum_output = opal_output_open(NULL); opal_output_set_verbosity(mca_pml_csum_output, value); mca_pml_csum.free_list_num = mca_pml_csum_param_register_int("free_list_num", 4); mca_pml_csum.free_list_max = mca_pml_csum_param_register_int("free_list_max", -1); mca_pml_csum.free_list_inc = mca_pml_csum_param_register_int("free_list_inc", 64); mca_pml_csum.priority = mca_pml_csum_param_register_int("priority", 0); mca_pml_csum.send_pipeline_depth = mca_pml_csum_param_register_int("send_pipeline_depth", 3); mca_pml_csum.recv_pipeline_depth = mca_pml_csum_param_register_int("recv_pipeline_depth", 4); mca_pml_csum.rdma_put_retries_limit = mca_pml_csum_param_register_int("rdma_put_retries_limit", 5); mca_pml_csum.max_rdma_per_request = mca_pml_csum_param_register_int("max_rdma_per_request", 4); mca_pml_csum.max_send_per_range = mca_pml_csum_param_register_int("max_send_per_range", 4); mca_pml_csum.unexpected_limit = mca_pml_csum_param_register_int("unexpected_limit", 128); mca_base_param_reg_string(&mca_pml_csum_component.pmlm_version, "allocator", "Name of allocator component for unexpected messages", false, false, "bucket", &mca_pml_csum.allocator_name); allocator_component = mca_allocator_component_lookup( mca_pml_csum.allocator_name ); if(NULL == allocator_component) { opal_output(0, "mca_pml_csum_component_open: can't find allocator: %s\n", mca_pml_csum.allocator_name); return OMPI_ERROR; } mca_pml_csum.allocator = allocator_component->allocator_init(true, mca_pml_csum_seg_alloc, mca_pml_csum_seg_free, NULL); if(NULL == mca_pml_csum.allocator) { opal_output(0, "mca_pml_csum_component_open: unable to initialize allocator\n"); return OMPI_ERROR; } mca_pml_csum.enabled = false; return mca_bml_base_open(); }
static mca_pml_base_module_t* mca_pml_ob1_component_init( int* priority, bool enable_progress_threads, bool enable_mpi_threads ) { mca_allocator_base_component_t* allocator_component; opal_output_verbose( 10, mca_pml_ob1_output, "in ob1, my priority is %d\n", mca_pml_ob1.priority); if((*priority) > mca_pml_ob1.priority) { *priority = mca_pml_ob1.priority; return NULL; } *priority = mca_pml_ob1.priority; allocator_component = mca_allocator_component_lookup( mca_pml_ob1.allocator_name ); if(NULL == allocator_component) { opal_output(0, "mca_pml_ob1_component_init: can't find allocator: %s\n", mca_pml_ob1.allocator_name); return NULL; } mca_pml_ob1.allocator = allocator_component->allocator_init(true, mca_pml_ob1_seg_alloc, mca_pml_ob1_seg_free, NULL); if(NULL == mca_pml_ob1.allocator) { opal_output(0, "mca_pml_ob1_component_init: unable to initialize allocator\n"); return NULL; } if(OMPI_SUCCESS != mca_bml_base_init( enable_progress_threads, enable_mpi_threads)) { return NULL; } /* Set this here (vs in component_open()) because opal_leave_pinned* may have been set after MCA params were read (e.g., by the openib btl) */ mca_pml_ob1.leave_pinned = (1 == opal_leave_pinned); mca_pml_ob1.leave_pinned_pipeline = (int) opal_leave_pinned_pipeline; return &mca_pml_ob1.super; }
/* * Initializes the mpool module. */ int mca_mpool_hugepage_module_init(mca_mpool_hugepage_module_t *mpool, mca_mpool_hugepage_hugepage_t *huge_page) { mca_allocator_base_component_t *allocator_component; int rc; mpool->super.mpool_component = &mca_mpool_hugepage_component.super; mpool->super.mpool_base = NULL; /* no base .. */ mpool->super.mpool_alloc = mca_mpool_hugepage_alloc; mpool->super.mpool_realloc = mca_mpool_hugepage_realloc; mpool->super.mpool_free = mca_mpool_hugepage_free; mpool->super.mpool_finalize = mca_mpool_hugepage_finalize; mpool->super.mpool_ft_event = mca_mpool_hugepage_ft_event; mpool->super.flags = MCA_MPOOL_FLAGS_MPI_ALLOC_MEM; OBJ_CONSTRUCT(&mpool->lock, opal_mutex_t); mpool->huge_page = huge_page; /* use an allocator component to reduce waste when making small allocations */ allocator_component = mca_allocator_component_lookup ("bucket"); if (NULL == allocator_component) { return OPAL_ERR_NOT_AVAILABLE; } mpool->allocator = allocator_component->allocator_init (true, mca_mpool_hugepage_seg_alloc, mca_mpool_hugepage_seg_free, mpool); OBJ_CONSTRUCT(&mpool->allocation_tree, opal_rb_tree_t); rc = opal_rb_tree_init (&mpool->allocation_tree, mca_mpool_rb_hugepage_compare); if (OPAL_SUCCESS != rc) { OBJ_DESTRUCT(&mpool->allocation_tree); return OPAL_ERR_NOT_AVAILABLE; } return OPAL_SUCCESS; }
static int mca_pml_bfo_component_open(void) { mca_allocator_base_component_t* allocator_component; mca_pml_bfo_output = opal_output_open(NULL); opal_output_set_verbosity(mca_pml_bfo_output, mca_pml_bfo_verbose); allocator_component = mca_allocator_component_lookup( mca_pml_bfo.allocator_name ); if(NULL == allocator_component) { opal_output(0, "mca_pml_bfo_component_open: can't find allocator: %s\n", mca_pml_bfo.allocator_name); return OMPI_ERROR; } mca_pml_bfo.allocator = allocator_component->allocator_init(true, mca_pml_bfo_seg_alloc, mca_pml_bfo_seg_free, NULL); if(NULL == mca_pml_bfo.allocator) { opal_output(0, "mca_pml_bfo_component_open: unable to initialize allocator\n"); return OMPI_ERROR; } mca_pml_bfo.enabled = false; return mca_base_framework_open(&ompi_bml_base_framework, 0); }
static mca_mpool_base_module_t* mca_mpool_sm_init( struct mca_mpool_base_resources_t* resources) { char *file_name; int len; mca_mpool_sm_module_t* mpool_module; mca_allocator_base_component_t* allocator_component; long min_size; ompi_proc_t **procs; size_t num_all_procs, i, num_local_procs = 0; /* README: this needs to change if procs in different jobs (even spawned ones) are to talk using shared memory */ procs = ompi_proc_world(&num_all_procs); for (i = 0 ; i < num_all_procs ; ++i) { if (procs[i]->proc_flags & OMPI_PROC_FLAG_LOCAL) { num_local_procs++; } } /* parse the min size and validate it */ /* if other parameters are added, absolutely necessary to reset errno each time */ errno = 0; min_size = strtol(min_size_param, (char **)NULL, 10); if (errno == ERANGE) { opal_output(0, "mca_mpool_sm_init: min_size overflows! set to default (%ld)", default_min); min_size = default_min; } else if (errno == EINVAL) { opal_output(0, "mca_mpool_sm_init: invalid min_size entered. set it to (%ld)", default_min); min_size = default_min; } /* Make a new mpool module */ mpool_module = (mca_mpool_sm_module_t*)malloc(sizeof(mca_mpool_sm_module_t)); mca_mpool_sm_module_init(mpool_module); /* set sm_size */ mpool_module->sm_size = resources->size; /* clip at the min size */ if (mpool_module->sm_size < min_size) { mpool_module->sm_size = min_size; } /* add something for the control structure */ mpool_module->sm_size += sizeof(mca_common_sm_mmap_t); allocator_component = mca_allocator_component_lookup( mca_mpool_sm_component.sm_allocator_name); /* if specified allocator cannot be loaded - look for an alternative */ if(NULL == allocator_component) { if(opal_list_get_size(&mca_allocator_base_components) == 0) { mca_base_component_list_item_t* item = (mca_base_component_list_item_t*) opal_list_get_first(&mca_allocator_base_components); allocator_component = (mca_allocator_base_component_t*)item->cli_component; opal_output(0, "mca_mpool_sm_init: unable to locate allocator: %s - using %s\n", mca_mpool_sm_component.sm_allocator_name, allocator_component->allocator_version.mca_component_name); } else { opal_output(0, "mca_mpool_sm_init: unable to locate allocator: %s\n", mca_mpool_sm_component.sm_allocator_name); free(procs); return NULL; } } /* create initial shared memory mapping */ len = asprintf( &file_name, "%s"OPAL_PATH_SEP"shared_mem_pool.%s", orte_process_info.job_session_dir, orte_process_info.nodename ); if ( 0 > len ) { free(mpool_module); free(procs); return NULL; } opal_output(mca_mpool_sm_component.verbose, "mca_mpool_sm_init: shared memory size used: (%ld)", mpool_module->sm_size); if (NULL == (mpool_module->sm_common_mmap = mca_common_sm_mmap_init(procs, num_all_procs, mpool_module->sm_size, file_name, sizeof(mca_common_sm_mmap_t), 8))) { opal_output(mca_mpool_sm_component.verbose, "mca_mpool_sm_init: unable to create shared memory mapping (%s)", file_name); free(file_name); free(mpool_module); free(procs); return NULL; } free(procs); free(file_name); /* setup allocator */ mpool_module->sm_allocator = allocator_component->allocator_init(true, mca_common_sm_mmap_seg_alloc, NULL, &(mpool_module->super)); if(NULL == mpool_module->sm_allocator) { opal_output(0, "mca_mpool_sm_init: unable to initialize allocator"); free(mpool_module); return NULL; } return &mpool_module->super; }
static mca_mpool_base_module_t * mca_mpool_sm_init(struct mca_mpool_base_resources_t *resources) { mca_mpool_sm_module_t *mpool_module; mca_allocator_base_component_t* allocator_component; ompi_proc_t **procs; size_t num_all_procs, i, num_local_procs = 0; /* README: this needs to change if procs in different jobs (even * spawned ones) are to talk using shared memory */ if (NULL == (procs = ompi_proc_world(&num_all_procs))) { /* out of resources, so just bail */ return NULL; } for (i = 0 ; i < num_all_procs ; ++i) { if (OPAL_PROC_ON_LOCAL_NODE(procs[i]->proc_flags)) { num_local_procs++; } } /* Make a new mpool module */ mpool_module = (mca_mpool_sm_module_t *)malloc(sizeof(mca_mpool_sm_module_t)); mca_mpool_sm_module_init(mpool_module); /* set sm_size */ mpool_module->sm_size = resources->size; /* clip at the min size */ if (mpool_module->sm_size < (long) ompi_mpool_sm_min_size) { mpool_module->sm_size = (long) ompi_mpool_sm_min_size; } allocator_component = mca_allocator_component_lookup( mca_mpool_sm_component.sm_allocator_name); /* if specified allocator cannot be loaded - look for an alternative */ if (NULL == allocator_component) { if (opal_list_get_size(&ompi_allocator_base_framework.framework_components) == 0) { mca_base_component_list_item_t *item = (mca_base_component_list_item_t *) opal_list_get_first(&ompi_allocator_base_framework.framework_components); allocator_component = (mca_allocator_base_component_t *)item->cli_component; opal_output( 0, "mca_mpool_sm_init: " "unable to locate allocator: %s - using %s\n", mca_mpool_sm_component.sm_allocator_name, allocator_component->allocator_version.mca_component_name); } else { opal_output(0, "mca_mpool_sm_init: " "unable to locate allocator: %s\n", mca_mpool_sm_component.sm_allocator_name); free(procs); return NULL; } } mpool_module->mem_node = resources->mem_node; opal_output(mca_mpool_sm_component.verbose, "mca_mpool_sm_init: shared memory size used: (%ld)", mpool_module->sm_size); if (NULL == (mpool_module->sm_common_module = mca_common_sm_module_attach(&resources->bs_meta_buf, sizeof(mca_common_sm_module_t), 8))) { opal_output(mca_mpool_sm_component.verbose, "mca_mpool_sm_init: " "unable to create shared memory mapping (%s)", resources->bs_meta_buf.seg_name); free(mpool_module); free(procs); return NULL; } free(procs); /* setup allocator */ mpool_module->sm_allocator = allocator_component->allocator_init(true, mca_common_sm_seg_alloc, NULL, &(mpool_module->super)); if (NULL == mpool_module->sm_allocator) { opal_output(0, "mca_mpool_sm_init: unable to initialize allocator"); free(mpool_module); return NULL; } return &mpool_module->super; }