Include mpi in CMakeLists
This commit is contained in:
parent
234342f2de
commit
40ae4ad7f9
@ -25,12 +25,18 @@ set(CMAKE_CXX_EXTENSIONS OFF)
|
|||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
# -------
|
# -------
|
||||||
option(ENABLE_CLANG_TIDY "Enable to add clang tidy." OFF)
|
option(ENABLE_CLANG_TIDY "Enable to add clang tidy." OFF)
|
||||||
option(ENABLE_TESTING "Unit testing build" OFF)
|
option(ENABLE_TESTING "Unit testing build" OFF)
|
||||||
option(CODE_COVERAGE "Collect coverage from test library" OFF)
|
option(CODE_COVERAGE "Collect coverage from test library" OFF)
|
||||||
|
option(MPI_ENABLED "Enable MPI options" ON)
|
||||||
|
|
||||||
|
if (MPI_ENABLED)
|
||||||
|
find_package(MPI REQUIRED)
|
||||||
|
message("MPI_CXX_LIBRARIES=${MPI_CXX_LIBRARIES}")
|
||||||
|
message("MPI_CXX_INCLUDE_DIRS=${MPI_CXX_INCLUDE_DIRS}")
|
||||||
|
endif (MPI_ENABLED)
|
||||||
|
|
||||||
# Boost Library
|
# Boost Library
|
||||||
set(Boost_USE_STATIC_LIBS OFF)
|
set(Boost_USE_STATIC_LIBS OFF)
|
||||||
|
10
README.md
10
README.md
@ -8,6 +8,16 @@ Bayesian Network Classifier with libtorch from scratch
|
|||||||
|
|
||||||
Before compiling BayesNet.
|
Before compiling BayesNet.
|
||||||
|
|
||||||
|
### MPI
|
||||||
|
|
||||||
|
In Linux just install openmpi & openmpi-devel packages.
|
||||||
|
|
||||||
|
In Mac OS X, install mpich with brew and if cmake doesn't find it, edit mpicxx wrapper to remove the ",-commons,use_dylibs" from final_ldflags
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vi /opt/homebrew/bin/mpicx
|
||||||
|
```
|
||||||
|
|
||||||
### boost library
|
### boost library
|
||||||
|
|
||||||
[Getting Started](<https://www.boost.org/doc/libs/1_83_0/more/getting_started/index.html>)
|
[Getting Started](<https://www.boost.org/doc/libs/1_83_0/more/getting_started/index.html>)
|
||||||
|
@ -141,18 +141,18 @@ void list_results(json& results, std::string& model)
|
|||||||
|
|
||||||
void initialize_mpi(struct platform::ConfigMPI& config)
|
void initialize_mpi(struct platform::ConfigMPI& config)
|
||||||
{
|
{
|
||||||
int provided;
|
// int provided;
|
||||||
// MPI_Init_thread(nullptr, nullptr, MPI_THREAD_MULTIPLE, &provided);
|
// MPI_Init_thread(nullptr, nullptr, MPI_THREAD_MULTIPLE, &provided);
|
||||||
// if (provided != MPI_THREAD_MULTIPLE) {
|
// if (provided != MPI_THREAD_MULTIPLE) {
|
||||||
// std::cerr << "MPI_Init_thread returned " << provided << " instead of " << MPI_THREAD_MULTIPLE << std::endl;
|
// std::cerr << "MPI_Init_thread returned " << provided << " instead of " << MPI_THREAD_MULTIPLE << std::endl;
|
||||||
// exit(1);
|
// exit(1);
|
||||||
// }
|
// }
|
||||||
MPI_Init(nullptr, nullptr);
|
// MPI_Init(nullptr, nullptr);
|
||||||
int rank, size;
|
// int rank, size;
|
||||||
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
// MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
||||||
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
// MPI_Comm_size(MPI_COMM_WORLD, &size);
|
||||||
config.mpi_rank = rank;
|
// config.mpi_rank = rank;
|
||||||
config.mpi_size = size;
|
// config.mpi_size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -213,8 +213,11 @@ int main(int argc, char** argv)
|
|||||||
} else {
|
} else {
|
||||||
if (compute) {
|
if (compute) {
|
||||||
if (program.get<bool>("mpi")) {
|
if (program.get<bool>("mpi")) {
|
||||||
initialize_mpi(mpi_config);
|
MPI_Init(nullptr, nullptr);
|
||||||
grid_search.setMPIConfig(mpi_config);
|
MPI_Comm_rank(MPI_COMM_WORLD, &config.rank);
|
||||||
|
MPI_Comm_size(MPI_COMM_WORLD, &config.size);
|
||||||
|
grid_search.go_mpi();
|
||||||
|
MPI_Finzalize();
|
||||||
} else {
|
} else {
|
||||||
grid_search.go();
|
grid_search.go();
|
||||||
std::cout << "Process took " << timer.getDurationString() << std::endl;
|
std::cout << "Process took " << timer.getDurationString() << std::endl;
|
||||||
|
Loading…
Reference in New Issue
Block a user