Commit 976c2748 authored by Brian Panneton's avatar Brian Panneton

Updated DSM from Jerome Soumagne.

parent 5e080056
......@@ -16,8 +16,6 @@ set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
option(XDMF_BUILD_DSM OFF)
mark_as_advanced(CLEAR Boost_INCLUDE_DIR)
find_package(Boost REQUIRED)
if(Boost_FOUND)
......@@ -30,38 +28,36 @@ mark_as_advanced(CLEAR HDF5_hdf5_LIBRARY_DEBUG)
mark_as_advanced(CLEAR HDF5_hdf5_LIBRARY_RELEASE)
find_package(HDF5 REQUIRED)
if(HDF5_FOUND)
include_directories(${HDF5_INCLUDE_DIRS})
mark_as_advanced(FORCE HDF5_C_INCLUDE_DIR)
mark_as_advanced(FORCE HDF5_hdf5_LIBRARY_DEBUG)
mark_as_advanced(FORCE HDF5_hdf5_LIBRARY_RELEASE)
include_directories(${HDF5_INCLUDE_DIR})
# set(HDF5_LIBRARIES hdf5)
option(HDF5_IS_PARALLEL "Whether or not HDF5 has parallel IO support." OFF)
if(HDF5_IS_PARALLEL)
find_package(MPI REQUIRED)
if(MPI_FOUND)
include_directories(${MPI_INCLUDE_PATH})
endif(MPI_FOUND)
option(XDMF_BUILD_DSM OFF)
if(XDMF_BUILD_DSM)
find_package(H5FDdsm REQUIRED NO_MODULE)
if(H5FDdsm_FOUND)
include_directories(${H5FD_DSM_INCLUDE_DIR})
set(H5FD_DSM_LIBRARIES H5FDdsm)
else(H5FDdsm_FOUND)
message(SEND_ERROR
"Cannot find HDF5 DSM! Please set H5FDdsm_DIR and configure again.")
endif(H5FDdsm_FOUND)
endif(XDMF_BUILD_DSM)
endif(HDF5_IS_PARALLEL)
get_filename_component(HDF5_ROOT "${HDF5_INCLUDE_DIR}/../" REALPATH)
set(HDF5_BINARY_DIRS ${HDF5_ROOT}/bin ${HDF5_ROOT}/dll)
set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${HDF5_LIBRARIES})
set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${HDF5_LIBRARIES} ${H5FD_DSM_LIBRARIES})
set(XDMF_HDF5_BINARY_DIRS ${HDF5_BINARY_DIRS} PARENT_SCOPE)
set(XDMF_BINARIES ${XDMF_BINARIES} ${HDF5_BINARY_DIRS})
endif(HDF5_FOUND)
if(XDMF_BUILD_DSM)
find_path(HDF5DSM_DIR include/H5FDdsm.h)
if(HDF5DSM_DIR AND EXISTS ${HDF5DSM_DIR}/include/H5FDdsm.h)
include_directories(${HDF5DSM_DIR}/include)
find_library(HDF5DSM_LIBRARIES H5FDdsm ${HDF5DSM_DIR}/lib)
else(HDF5DSM_DIR AND EXISTS ${HDF5DSM_DIR}/include/H5FDdsm.h)
message(SEND_ERROR
"Cannot find HDF5DSM! Please set HDF5DSM_DIR and configure again.")
endif(HDF5DSM_DIR AND EXISTS ${HDF5DSM_DIR}/include/H5FDdsm.h)
find_package(MPI REQUIRED)
if(MPI_FOUND)
include_directories(${MPI_INCLUDE_PATH})
endif(MPI_FOUND)
endif(XDMF_BUILD_DSM)
find_package(LibXml2 REQUIRED)
if(LIBXML2_FOUND)
......@@ -100,9 +96,7 @@ endif(XDMF_BUILD_DSM)
add_library(XdmfCore ${XdmfCoreSources})
target_link_libraries(XdmfCore
${HDF5_hdf5_LIBRARY}
${HDF5DSM_LIBRARIES}
${LIBXML2_LIBRARIES})
${XDMF_LIBRARIES})
if(WIN32)
add_definitions(-D_HDF5USEDLL_ -D_HDF5USEHLDLL_)
......
......@@ -6,37 +6,30 @@
int main(int argc, char *argv[])
{
MPI_Init(&argc, &argv);
int rank, size;
int rank, size, provided, dsmSize = 16;
MPI_Comm comm = MPI_COMM_WORLD;
MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
MPI_Comm_rank(comm, &rank);
MPI_Comm_size(comm, &size);
// Create DSM Server
H5FDdsmManager * dsmServer = new H5FDdsmManager();
dsmServer->SetCommunicator(comm);
dsmServer->SetLocalBufferSizeMBytes(16);
dsmServer->SetDsmCommType(H5FD_DSM_COMM_SOCKET);
dsmServer->SetDsmIsServer(1);
dsmServer->SetServerHostName("default");
dsmServer->SetServerPort(22000);
dsmServer->CreateDSM();
dsmServer->PublishDSM();
// Create DSM Client
H5FDdsmManager * dsmClient = new H5FDdsmManager();
dsmClient->SetGlobalDebug(0);
dsmClient->SetCommunicator(comm);
dsmClient->SetDsmIsServer(0);
dsmClient->ReadDSMConfigFile();
dsmClient->CreateDSM();
if (rank == 0) {
if (provided != MPI_THREAD_MULTIPLE) {
std::cout << "# MPI_THREAD_MULTIPLE not set, you may need to recompile your "
<< "MPI distribution with threads enabled" << std::endl;
}
else {
std::cout << "# MPI_THREAD_MULTIPLE is OK" << std::endl;
}
}
// Connect to Server
dsmClient->ConnectDSM();
// Create DSM
H5FDdsmManager * dsmManager = new H5FDdsmManager();
dsmManager->SetCommunicator(comm);
dsmManager->SetLocalBufferSizeMBytes(dsmSize / size);
dsmManager->CreateDSM();
H5FDdsmBuffer * dsmBuffer = dsmClient->GetDSMHandle();
H5FDdsmBuffer * dsmBuffer = dsmManager->GetDSMHandle();
H5FD_dsm_set_mode(H5FD_DSM_MANUAL_SERVER_UPDATE, dsmBuffer);
......@@ -51,6 +44,7 @@ int main(int argc, char *argv[])
}
// Create Array
// Array should be distributed among processes
shared_ptr<XdmfArray> array = XdmfArray::New();
array->initialize<int>(0);
array->pushBack(0);
......@@ -73,14 +67,9 @@ int main(int argc, char *argv[])
assert(array->getValue<int>(i) == readArray->getValue<int>(i));
}
// Return to Server
H5FD_dsm_server_update(dsmBuffer);
// Closes ports or MPI communicators
dsmServer->UnpublishDSM();
delete dsmClient;
delete dsmServer;
// Wait for everyone to have finished reading
MPI_Barrier(comm);
delete dsmManager;
MPI_Finalize();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment