diff --git a/ompi/mca/bcol/basesmuma/bcol_basesmuma.h b/ompi/mca/bcol/basesmuma/bcol_basesmuma.h index 40dd2aa472..511378a828 100644 --- a/ompi/mca/bcol/basesmuma/bcol_basesmuma.h +++ b/ompi/mca/bcol/basesmuma/bcol_basesmuma.h @@ -18,6 +18,7 @@ #include "ompi_config.h" #include "ompi/mca/bcol/bcol.h" +#include "ompi/mca/bcol/base/base.h" #include "ompi/mca/mpool/mpool.h" #include "ompi/request/request.h" #include "ompi/proc/proc.h" diff --git a/ompi/mca/bcol/basesmuma/bcol_basesmuma_component.c b/ompi/mca/bcol/basesmuma/bcol_basesmuma_component.c index 1d0d473449..7ec449ba64 100644 --- a/ompi/mca/bcol/basesmuma/bcol_basesmuma_component.c +++ b/ompi/mca/bcol/basesmuma/bcol_basesmuma_component.c @@ -25,6 +25,9 @@ #include "ompi/mca/bcol/base/base.h" #include "bcol_basesmuma.h" + +#define ROUND_UP_POW2(x, y) (((x) + ((y) - 1)) & ~((y) - 1)) + /* * Public string showing the coll ompi_sm V2 component version number */ @@ -241,7 +244,7 @@ static int basesmuma_open(void) */ ret=opal_progress_register(bcol_basesmuma_progress); if (MPI_SUCCESS != ret) { - opal_output(0, "failed to register the progress function\n"); + opal_output(ompi_bcol_base_framework.framework_output, "failed to register the progress function"); } return ret; @@ -270,7 +273,7 @@ static int mca_bcol_basesmuma_deregister_ctl_sm(mca_bcol_basesmuma_component_t * /* unmap the shared memory file */ ret=munmap((void *) sm_ctl_structs->map_addr, sm_ctl_structs->map_size); if( 0 > ret) { - opal_output (0, "Failed to munmap the shared memory file %s \n", + opal_output (ompi_bcol_base_framework.framework_output, "Failed to munmap the shared memory file %s", sm_ctl_structs->map_path); return OMPI_ERROR; } @@ -282,7 +285,7 @@ static int mca_bcol_basesmuma_deregister_ctl_sm(mca_bcol_basesmuma_component_t * #if 0 ret = remove(sm_ctl_structs->map_path); if( 0 > ret) { - opal_output (0, "Failed to remove the shared memory file %s. reason = %s\n", + opal_output (ompi_bcol_base_framework.framework_output, "Failed to remove the shared memory file %s. reason = %s", sm_ctl_structs->map_path, strerror (errno)); return OMPI_ERROR; } @@ -314,13 +317,13 @@ static int basesmuma_close(void) /* deregister the progress function */ ret=opal_progress_unregister(bcol_basesmuma_progress); if (MPI_SUCCESS != ret) { - opal_output(0, "failed to unregister the progress function\n"); + opal_output(ompi_bcol_base_framework.framework_output, "failed to unregister the progress function"); } /* remove the control structure backing file */ ret=mca_bcol_basesmuma_deregister_ctl_sm(&mca_bcol_basesmuma_component); if (MPI_SUCCESS != ret) { - opal_output(0, "failed to remove control structure backing file\n"); + opal_output(ompi_bcol_base_framework.framework_output, "failed to remove control structure backing file"); } /* remove the network contexts - only one network context defined for @@ -367,6 +370,7 @@ int mca_bcol_basesmuma_allocate_sm_ctl_memory(mca_bcol_basesmuma_component_t *cs int name_length, ret; size_t ctl_length; char *name, *ctl_mem; + size_t page_size = getpagesize (); /* set the file name */ name_length=asprintf(&name, @@ -396,12 +400,12 @@ int mca_bcol_basesmuma_allocate_sm_ctl_memory(mca_bcol_basesmuma_component_t *cs ctl_length+=cs->my_scratch_shared_memory_size; /* round up to multiple of page size */ - ctl_length=(ctl_length-1)/getpagesize()+1; - ctl_length*=getpagesize(); + ctl_length = ROUND_UP_POW2(ctl_length, page_size); /* allocate memory that will be mmaped */ ctl_mem=(char *)valloc(ctl_length); if( !ctl_mem) { + opal_output (ompi_bcol_base_framework.framework_output, "failed to allocate bcol/basesmuma control memory"); return OMPI_ERR_OUT_OF_RESOURCE; } @@ -409,7 +413,8 @@ int mca_bcol_basesmuma_allocate_sm_ctl_memory(mca_bcol_basesmuma_component_t *cs cs->sm_ctl_structs=bcol_basesmuma_smcm_mem_reg(ctl_mem, ctl_length,getpagesize(),name); if( !cs->sm_ctl_structs) { - opal_output (0, "In mca_bcol_basesmuma_allocate_sm_ctl_memory failed to allocathe backing file %s\n", name); + opal_output (ompi_bcol_base_framework.framework_output, + "In mca_bcol_basesmuma_allocate_sm_ctl_memory failed to allocathe backing file %s\n", name); ret=OMPI_ERR_OUT_OF_RESOURCE; goto Error; } diff --git a/ompi/mca/bcol/basesmuma/bcol_basesmuma_mem_mgmt.c b/ompi/mca/bcol/basesmuma/bcol_basesmuma_mem_mgmt.c index 1f5e9a7356..246fbdde19 100644 --- a/ompi/mca/bcol/basesmuma/bcol_basesmuma_mem_mgmt.c +++ b/ompi/mca/bcol/basesmuma/bcol_basesmuma_mem_mgmt.c @@ -60,7 +60,7 @@ int mca_bcol_basesmuma_register_sm(void *context_data, void *base, size_t size, sm_reg->data_seg_alignment, sm_reg->file_name); if(NULL == sm_reg->sm_mmap) { - opal_output (0, "Bcol_basesmuma memory registration error \n"); + opal_output (ompi_bcol_base_framework.framework_output, "Bcol_basesmuma memory registration error"); return OMPI_ERROR; } @@ -96,7 +96,7 @@ int mca_bcol_basesmuma_deregister_sm(void *context_data, void *reg) /* unmap the shared memory file */ ret = munmap((void *) sm_reg->base_addr, sm_reg->size); if( 0 > ret) { - opal_output (0, "Failed to munmap the shared memory file %s\n",sm_reg->file_name); + opal_output (ompi_bcol_base_framework.framework_output, "Failed to munmap the shared memory file %s",sm_reg->file_name); return OMPI_ERROR; } @@ -106,7 +106,7 @@ int mca_bcol_basesmuma_deregister_sm(void *context_data, void *reg) /* remove the file */ ret = remove(sm_reg->file_name); if( 0 > ret) { - opal_output (0, "Failed to remove the shared memory file %s. reason = %s\n", + opal_output (ompi_bcol_base_framework.framework_output, "Failed to remove the shared memory file %s. reason = %s", sm_reg->file_name, strerror (errno)); return OMPI_ERROR; } diff --git a/ompi/mca/bcol/basesmuma/bcol_basesmuma_module.c b/ompi/mca/bcol/basesmuma/bcol_basesmuma_module.c index 160a5e32a1..2a72b24e71 100644 --- a/ompi/mca/bcol/basesmuma/bcol_basesmuma_module.c +++ b/ompi/mca/bcol/basesmuma/bcol_basesmuma_module.c @@ -385,7 +385,7 @@ mca_bcol_basesmuma_comm_query(mca_sbgp_base_module_t *module, int *num_modules) sizeof(mca_bcol_base_module_t *)); if( !sm_modules ) { - opal_output (0, "In base_bcol_masesmuma_setup_library_buffers failed to allocate memory for sm_modules\n"); + opal_output (ompi_bcol_base_framework.framework_output, "In base_bcol_masesmuma_setup_library_buffers failed to allocate memory for sm_modules\n"); return NULL; } @@ -396,7 +396,7 @@ mca_bcol_basesmuma_comm_query(mca_sbgp_base_module_t *module, int *num_modules) module->group_size,module->my_index, &(sm_module->recursive_doubling_tree)); if(OMPI_SUCCESS != ret) { - opal_output (0, "Error setting up recursive_doubling_tree \n"); + opal_output (ompi_bcol_base_framework.framework_output, "Error setting up recursive_doubling_tree \n"); return NULL; } @@ -406,7 +406,7 @@ mca_bcol_basesmuma_comm_query(mca_sbgp_base_module_t *module, int *num_modules) ret=netpatterns_setup_narray_tree(cs->radix_fanin, my_rank,module->group_size,&(sm_module->fanin_node)); if(OMPI_SUCCESS != ret) { - opal_output (0, "Error setting up fanin tree \n"); + opal_output (ompi_bcol_base_framework.framework_output, "Error setting up fanin tree \n"); return NULL; } @@ -415,7 +415,7 @@ mca_bcol_basesmuma_comm_query(mca_sbgp_base_module_t *module, int *num_modules) ret=netpatterns_setup_narray_tree(cs->radix_fanout, my_rank,module->group_size,&(sm_module->fanout_node)); if(OMPI_SUCCESS != ret) { - opal_output (0, "Error setting up fanout tree \n"); + opal_output (ompi_bcol_base_framework.framework_output, "Error setting up fanout tree \n"); return NULL; } @@ -491,7 +491,7 @@ mca_bcol_basesmuma_comm_query(mca_sbgp_base_module_t *module, int *num_modules) sm_module->super.sbgp_partner_module->group_size, &(sm_module->scatter_kary_tree)); if(OMPI_SUCCESS != ret) { - opal_output (0, "In base_bcol_masesmuma_setup_library_buffers and scatter k-ary tree setup failed \n"); + opal_output (ompi_bcol_base_framework.framework_output, "In base_bcol_masesmuma_setup_library_buffers and scatter k-ary tree setup failed \n"); return NULL; } @@ -499,7 +499,7 @@ mca_bcol_basesmuma_comm_query(mca_sbgp_base_module_t *module, int *num_modules) ret=base_bcol_basesmuma_setup_library_buffers(sm_module, cs); if(OMPI_SUCCESS != ret) { - opal_output (0, "In base_bcol_masesmuma_setup_library_buffers and mpool was not successfully setup!\n"); + opal_output (ompi_bcol_base_framework.framework_output, "In base_bcol_masesmuma_setup_library_buffers and mpool was not successfully setup!\n"); return NULL; } @@ -523,12 +523,12 @@ mca_bcol_basesmuma_comm_query(mca_sbgp_base_module_t *module, int *num_modules) cs->payload_base_fname, (int)getpid()); if( 0 > name_length ) { - opal_output (0, "Failed to assign the shared memory payload file a name\n"); + opal_output (ompi_bcol_base_framework.framework_output, "Failed to assign the shared memory payload file a name\n"); return NULL; } /* make sure name is not too long */ if ( OPAL_PATH_MAX < (name_length-1) ) { - opal_output (0, "Shared memory file name is too long!\n"); + opal_output (ompi_bcol_base_framework.framework_output, "Shared memory file name is too long!\n"); return NULL; } /* set the name and alignment characteristics */ @@ -624,7 +624,7 @@ mca_bcol_basesmuma_comm_query(mca_sbgp_base_module_t *module, int *num_modules) /* blocking recursive double barrier test */ /* { - opal_output (0, "BBB About to hit the barrier test\n"); + opal_output (ompi_bcol_base_framework.framework_output, "BBB About to hit the barrier test\n"); int rc; bcol_function_args_t bogus; rc = bcol_basesmuma_rd_barrier_init(&(sm_module->super)); diff --git a/ompi/mca/bcol/basesmuma/bcol_basesmuma_setup.c b/ompi/mca/bcol/basesmuma/bcol_basesmuma_setup.c index cbfd8877fa..aa06ec2c74 100644 --- a/ompi/mca/bcol/basesmuma/bcol_basesmuma_setup.c +++ b/ompi/mca/bcol/basesmuma/bcol_basesmuma_setup.c @@ -144,7 +144,7 @@ int base_bcol_basesmuma_exchange_offsets( } /* pack up the data into the allgather send buffer */ if (NULL == send_buffer || NULL == recv_buffer) { - opal_output (0, "Cannot allocate memory for sbuffer or rbuffer\n"); + opal_output (ompi_bcol_base_framework.framework_output, "Cannot allocate memory for sbuffer or rbuffer\n"); ret = OMPI_ERROR; goto exit_ERROR; } @@ -157,7 +157,7 @@ int base_bcol_basesmuma_exchange_offsets( &(sm_bcol_module->super.sbgp_partner_module->my_index),1,OPAL_UINT32); if (OMPI_SUCCESS != ret) { - opal_output (0, "Error packing my_index!!\n"); + opal_output (ompi_bcol_base_framework.framework_output, "Error packing my_index!!\n"); goto exit_ERROR; } @@ -171,7 +171,7 @@ int base_bcol_basesmuma_exchange_offsets( * structures. */ if (OMPI_SUCCESS != (ret = ompi_rte_allgather_list(&peers, send_buffer, recv_buffer))) { - opal_output (0, "ompi_rte_allgather_list returned error %d\n", ret); + opal_output (ompi_bcol_base_framework.framework_output, "ompi_rte_allgather_list returned error %d\n", ret); goto exit_ERROR; } @@ -179,7 +179,7 @@ int base_bcol_basesmuma_exchange_offsets( pcnt=1; ret = opal_dss.unpack(recv_buffer,&dummy, &pcnt, OPAL_INT32); if (OMPI_SUCCESS != ret) { - opal_output (0, "unpack returned error %d for dummy\n",ret); + opal_output (ompi_bcol_base_framework.framework_output, "unpack returned error %d for dummy\n",ret); goto exit_ERROR; } @@ -194,7 +194,7 @@ int base_bcol_basesmuma_exchange_offsets( pcnt=1; ret = opal_dss.unpack(recv_buffer,&index_in_group, &pcnt, OPAL_UINT32); if (OMPI_SUCCESS != ret) { - opal_output (0, "unpack returned error %d for remote index_in_group\n",ret); + opal_output (ompi_bcol_base_framework.framework_output, "unpack returned error %d for remote index_in_group\n",ret); goto exit_ERROR; } @@ -202,7 +202,7 @@ int base_bcol_basesmuma_exchange_offsets( pcnt=1; ret = opal_dss.unpack(recv_buffer,&rem_mem_offset, &pcnt, OPAL_UINT64); if (OMPI_SUCCESS != ret) { - opal_output (0, "unpack returned error %d for remote memory offset\n",ret); + opal_output (ompi_bcol_base_framework.framework_output, "unpack returned error %d for remote memory offset\n",ret); goto exit_ERROR; } @@ -398,7 +398,7 @@ int base_bcol_basesmuma_setup_ctl_struct( malloc(sizeof(void *)* sm_bcol_module->super.sbgp_partner_module->group_size); if( !sm_bcol_module->shared_memory_scratch_space ) { - opal_output (0, "Cannot allocate memory for shared_memory_scratch_space.\n"); + opal_output (ompi_bcol_base_framework.framework_output, "Cannot allocate memory for shared_memory_scratch_space.\n"); ret = OMPI_ERR_OUT_OF_RESOURCE; goto exit_ERROR; } @@ -422,7 +422,7 @@ int base_bcol_basesmuma_setup_ctl_struct( ctl_mgmt->ctl_buffs_mgmt=(mem_bank_management_t *) malloc(sizeof(mem_bank_management_t)*n_ctl); if( !ctl_mgmt->ctl_buffs_mgmt ) { - opal_output (0, "Cannot allocate memory for ctl_buffs_mgmt. ret = %d\n",ret); + opal_output (ompi_bcol_base_framework.framework_output, "Cannot allocate memory for ctl_buffs_mgmt. ret = %d\n",ret); ret = OMPI_ERROR; goto exit_ERROR; } @@ -483,7 +483,7 @@ int base_bcol_basesmuma_setup_library_buffers( if(!cs->sm_ctl_structs) { ret = mca_bcol_basesmuma_allocate_sm_ctl_memory(cs); if(OMPI_SUCCESS != ret) { - opal_output (0, "In bcol_comm_query mca_bcol_basesmuma_allocate_sm_ctl_memory failed\n"); + opal_output (ompi_bcol_base_framework.framework_output, "In bcol_comm_query mca_bcol_basesmuma_allocate_sm_ctl_memory failed\n"); return ret; } /* diff --git a/ompi/mca/bcol/basesmuma/bcol_basesmuma_smcm.c b/ompi/mca/bcol/basesmuma/bcol_basesmuma_smcm.c index e69af4b891..060bdb754e 100644 --- a/ompi/mca/bcol/basesmuma/bcol_basesmuma_smcm.c +++ b/ompi/mca/bcol/basesmuma/bcol_basesmuma_smcm.c @@ -100,7 +100,7 @@ bcol_basesmuma_smcm_mmap_t* bcol_basesmuma_smcm_create_mmap(int fd, size_t size, /* is addr past end of file ? */ if((unsigned char*)seg + size < addr) { - opal_output(0, "bcol_basesmuma_smcm_mmap_init: " + opal_output (ompi_bcol_base_framework.framework_output, "bcol_basesmuma_smcm_mmap_init: " "memory region too small len %lu addr %p\n", (unsigned long)size, addr); return NULL; @@ -174,7 +174,7 @@ int bcol_basesmuma_smcm_allgather_connection( signal(SIGABRT, SIG_DFL); /* sanity check */ if (strlen(input.file_name) > SM_BACKING_FILE_NAME_MAX_LEN-1) { - opal_output (0, "backing file name too long: %s len :: %d\n", + opal_output (ompi_bcol_base_framework.framework_output, "backing file name too long: %s len :: %d\n", input.file_name, (int) strlen(input.file_name)); return OMPI_ERR_BAD_PARAM; } @@ -219,7 +219,7 @@ int bcol_basesmuma_smcm_allgather_connection( sm_bcol_module->super.sbgp_partner_module->group_list, sm_bcol_module->super.sbgp_partner_module->group_comm); if( OMPI_SUCCESS != rc ) { - opal_output (0, "failed in comm_allgather_pml. Error code: %d\n", rc); + opal_output (ompi_bcol_base_framework.framework_output, "failed in comm_allgather_pml. Error code: %d\n", rc); goto Error; } @@ -286,7 +286,7 @@ int bcol_basesmuma_smcm_allgather_connection( */ fd = open(temp->sm_file.file_name, O_RDWR, 0600); if (0 > fd) { - opal_output (0, "SMCM Allgather failed to open sm backing file %s. errno = %d\n", temp->sm_file.file_name, errno); + opal_output (ompi_bcol_base_framework.framework_output, "SMCM Allgather failed to open sm backing file %s. errno = %d\n", temp->sm_file.file_name, errno); rc = OMPI_ERROR; goto Error; } @@ -297,7 +297,7 @@ int bcol_basesmuma_smcm_allgather_connection( temp->sm_file.size_ctl_structure, getpagesize()); if (NULL == temp->sm_mmap) { - opal_output (0, "mmapping failed to map remote peer's file\n"); + opal_output (ompi_bcol_base_framework.framework_output, "mmapping failed to map remote peer's file\n"); OBJ_RELEASE(temp); rc = OMPI_ERROR; goto Error; @@ -364,10 +364,10 @@ bcol_basesmuma_smcm_mmap_t *bcol_basesmuma_smcm_mem_reg(void *in_ptr, fd = open(file_name, O_CREAT|O_RDWR,0600); if (fd < 0) { - opal_output(0, "basesmuma shared memory allocation open failed with errno: %d\n", + opal_output (ompi_bcol_base_framework.framework_output, "basesmuma shared memory allocation open failed with errno: %d\n", errno); } else if (0 != ftruncate(fd,length)) { - opal_output(0, "basesmuma shared memory allocation ftruncate failed with errno: %d\n", + opal_output (ompi_bcol_base_framework.framework_output, "basesmuma shared memory allocation ftruncate failed with errno: %d\n", errno); } else { @@ -421,7 +421,7 @@ bcol_basesmuma_smcm_mmap_t * bcol_basesmuma_smcm_reg_mmap(void *in_ptr, /* is addr past the end of the file? */ if ((unsigned char *) seg+length < myaddr) { - opal_output(0, "mca_bcol_basesmuma_sm_alloc_mmap: memory region too small len %lu add %p\n", + opal_output (ompi_bcol_base_framework.framework_output, "mca_bcol_basesmuma_sm_alloc_mmap: memory region too small len %lu add %p\n", (unsigned long) length, myaddr); return NULL; }