static void sb_mmap_free(void) { int ret = munmap((void *) sb.sb_addr, sb.sb_length); if(-1 == ret) V_OUTPUT_ERR("pml_v: protocol_pessimsit: sender_based_finalize: munmap (%p): %s", (void *) sb.sb_addr, strerror(errno)); }
static void sb_mmap_file_close(void) { int ret = close(sb.sb_fd); if(-1 == ret) V_OUTPUT_ERR("pml_v: protocol_pessimist: sender_based_finalize: close (%d): %s", sb.sb_fd, strerror(errno)); }
static int mca_pml_v_component_close(void) { int ret; /* Save original PML before making any changes */ mca_pml_v.host_pml_component = mca_pml_base_selected_component; mca_pml_v.host_pml = mca_pml; mca_pml_v.host_request_fns = ompi_request_functions; /* Do not load anything if no FT protocol is selected */ if(! mca_vprotocol_base_include_list[0]) return mca_pml_v_component_parasite_close(); V_OUTPUT_VERBOSE(500, "component_close: I don't want to be unloaded now."); ret = mca_base_component_repository_retain_component("pml", "v"); if(OPAL_SUCCESS != ret) { V_OUTPUT_ERR("pml_v: component_close: can't retain myself. If Open MPI is build static you can ignore this error. Otherwise it should crash soon."); } /* Mark that we have changed something */ snprintf(mca_pml_base_selected_component.pmlm_version.mca_component_name, MCA_BASE_MAX_TYPE_NAME_LEN, "%s]v%s", mca_pml_v.host_pml_component.pmlm_version.mca_component_name, mca_vprotocol_component.pmlm_version.mca_component_name); /* Replace finalize */ mca_pml_base_selected_component.pmlm_finalize = mca_pml_v_component_parasite_finalize; /* Make sure we get initialized if some Vprotocol is enabled */ mca_pml.pml_enable = mca_pml_v_enable; return OMPI_SUCCESS; }
/******************************************************************************* * MCA level functions - parasite setup */ static int mca_pml_v_component_open(void) { char *output; int verbose; int priority; char *vprotocol_include_list; int rc; priority = mca_pml_v_param_register_int("priority", -1); output = mca_pml_v_param_register_string("output", "stderr"); verbose = mca_pml_v_param_register_int("verbose", 0); mca_base_param_reg_string_name("vprotocol", NULL, "Specify a specific vprotocol to use", false, false, "", &vprotocol_include_list); pml_v_output_open(output, verbose); free(output); if(-1 != priority) V_OUTPUT_ERR("pml_v: Overriding priority setting (%d) with -1. The PML V should NEVER be the selected component; even when enabling fault tolerance.", priority); V_OUTPUT_VERBOSE(500, "loaded"); rc = mca_vprotocol_base_open(vprotocol_include_list); if (NULL != vprotocol_include_list) { free (vprotocol_include_list); } return rc; }
static void sb_mmap_alloc(void) { #if defined(__WINDOWS__) sb.sb_map = CreateFileMapping(sb.sb_fd, NULL, PAGE_READWRITE, 0, (DWORD)sb.sb_offset + sb.sb_length, NULL); if(NULL == sb.sb_map) { V_OUTPUT_ERR("pml_v: vprotocol_pessimist: sender_based_alloc: CreateFileMapping : %s", GetLastError()); ompi_mpi_abort(MPI_COMM_NULL, MPI_ERR_NO_SPACE, false); } sb.sb_addr = (uintptr_t) MapViewOfFile(sb.sb_map, FILE_MAP_ALL_ACCESS, 0, sb.sb_offset, sb.sb_length); if(NULL == (void*)sb.sb_addr) { V_OUTPUT_ERR("pml_v: vprotocol_pessimist: sender_based_alloc: mmap: %s", GetLastError()); CloseHandle(sb.sb_map); CloseHandle(sb.sb_fd); ompi_mpi_abort(MPI_COMM_NULL, MPI_ERR_NO_SPACE, false); } #else #ifndef MAP_NOCACHE # define MAP_NOCACHE 0 #endif if(-1 == ftruncate(sb.sb_fd, sb.sb_offset + sb.sb_length)) { V_OUTPUT_ERR("pml_v: vprotocol_pessimist: sender_based_alloc: ftruncate: %s", strerror(errno)); close(sb.sb_fd); ompi_mpi_abort(MPI_COMM_NULL, MPI_ERR_NO_SPACE, false); } sb.sb_addr = (uintptr_t) mmap((void *) sb.sb_addr, sb.sb_length, PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_NOCACHE, sb.sb_fd, sb.sb_offset); if(((uintptr_t) -1) == sb.sb_addr) { V_OUTPUT_ERR("pml_v: vprotocol_pessimist: sender_based_alloc: mmap: %s", strerror(errno)); close(sb.sb_fd); ompi_mpi_abort(MPI_COMM_NULL, MPI_ERR_NO_SPACE, false); } #endif }
static int sb_mmap_file_open(const char *path) { sb.sb_fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0600); if(-1 == sb.sb_fd) { V_OUTPUT_ERR("pml_v: vprotocol_pessimist: sender_based_init: open (%s): %s", path, strerror(errno)); return OPAL_ERR_FILE_OPEN_FAILURE; } return OPAL_SUCCESS; }
static void sb_mmap_file_close(void) { #if defined(__WINDOWS__) CloseHandle(sb.sb_fd); #else int ret = close(sb.sb_fd); if(-1 == ret) V_OUTPUT_ERR("pml_v: protocol_pessimist: sender_based_finalize: close (%d): %s", sb.sb_fd, strerror(errno)); #endif }
static void sb_mmap_free(void) { #if defined(__WINDOWS__) UnmapViewOfFile( (LPCVOID)sb.sb_addr); CloseHandle(sb.sb_map); #else int ret = munmap((void *) sb.sb_addr, sb.sb_length); if(-1 == ret) V_OUTPUT_ERR("pml_v: protocol_pessimsit: sender_based_finalize: munmap (%p): %s", (void *) sb.sb_addr, strerror(errno)); #endif }
static int sb_mmap_file_open(const char *path) { #if defined(__WINDOWS__) sb.sb_fd = CreateFile(path, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if(INVALID_HANDLE_VALUE == sb.sb_fd) { V_OUTPUT_ERR("pml_v: vprotocol_pessimist: sender_based_init: open (%s): %s", path, GetLastError()); return OPAL_ERR_FILE_OPEN_FAILURE; } return OPAL_SUCCESS; #else sb.sb_fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0600); if(-1 == sb.sb_fd) { V_OUTPUT_ERR("pml_v: vprotocol_pessimist: sender_based_init: open (%s): %s", path, strerror(errno)); return OPAL_ERR_FILE_OPEN_FAILURE; } return OPAL_SUCCESS; #endif }
static void sb_mmap_alloc(void) { #ifndef MAP_NOCACHE # define MAP_NOCACHE 0 #endif if(-1 == ftruncate(sb.sb_fd, sb.sb_offset + sb.sb_length)) { V_OUTPUT_ERR("pml_v: vprotocol_pessimist: sender_based_alloc: ftruncate: %s", strerror(errno)); close(sb.sb_fd); ompi_mpi_abort(MPI_COMM_NULL, MPI_ERR_NO_SPACE); } sb.sb_addr = (uintptr_t) mmap((void *) sb.sb_addr, sb.sb_length, PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_NOCACHE, sb.sb_fd, sb.sb_offset); if(((uintptr_t) -1) == sb.sb_addr) { V_OUTPUT_ERR("pml_v: vprotocol_pessimist: sender_based_alloc: mmap: %s", strerror(errno)); close(sb.sb_fd); ompi_mpi_abort(MPI_COMM_NULL, MPI_ERR_NO_SPACE); } }