diff --git a/CMakeLists.txt b/CMakeLists.txt index 04a73d8..4cf61b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,8 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) option(BUILD_DEBUG "Builds the program with extensive error checking" OFF) option(BUILD_STANDALONE "Builds the standalone Astaroth" ON) option(BUILD_RT_VISUALIZATION "Builds the module for real-time visualization using SDL2" OFF) -option(BUILD_C_API_TEST "Builds a C program to test whether the API is conformant" ON) +option(BUILD_C_API_TEST "Builds a C program to test whether the API is conformant" OFF) +option(BUILD_MPI_TEST "Builds a C program to test whether MPI works" OFF) option(DOUBLE_PRECISION "Generates double precision code" OFF) option(MULTIGPU_ENABLED "If enabled, uses all the available GPUs" ON) option(ALTER_CONF "If enabled, loads astaroth.conf from the build directory" OFF) @@ -60,3 +61,7 @@ endif () if (BUILD_C_API_TEST) add_subdirectory(src/ctest) endif () + +if (BUILD_MPI_TEST) + add_subdirectory(src/mpitest) +endif () diff --git a/src/mpitest/CMakeLists.txt b/src/mpitest/CMakeLists.txt new file mode 100644 index 0000000..c64105d --- /dev/null +++ b/src/mpitest/CMakeLists.txt @@ -0,0 +1,12 @@ +############################################## +## CMakeLists.txt for the MPI test ## +############################################## + +set(CMAKE_C_STANDARD 11) +set(CMAKE_C_STANDARD_REQUIRED ON) + +find_package(MPI REQUIRED) + +add_executable(mpitest main.c) +target_include_directories(mpitest PRIVATE ${MPI_C_INCLUDE_PATH}) +target_link_libraries(mpitest PRIVATE ${MPI_C_LIBRARIES} astaroth_core) diff --git a/src/mpitest/README.txt b/src/mpitest/README.txt new file mode 100644 index 0000000..1547b08 --- /dev/null +++ b/src/mpitest/README.txt @@ -0,0 +1 @@ +This directory is used to test MPI with Astaroth. diff --git a/src/mpitest/main.c b/src/mpitest/main.c new file mode 100644 index 0000000..a07522e --- /dev/null +++ b/src/mpitest/main.c @@ -0,0 +1,51 @@ +/* + Copyright (C) 2014-2019, Johannes Pekkilae, Miikka Vaeisalae. + + This file is part of Astaroth. + + Astaroth is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Astaroth is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Astaroth. If not, see . +*/ +#include +#include + +#include "astaroth.h" + +#include + +int +main(void) +{ + MPI_Init(NULL, NULL); + + int num_processes, process_id; + MPI_Comm_size(MPI_COMM_WORLD, &num_processes); + MPI_Comm_rank(MPI_COMM_WORLD, &process_id); + + char processor_name[MPI_MAX_PROCESSOR_NAME]; + int name_len; + MPI_Get_processor_name(processor_name, &name_len); + printf("Processor %s. Process %d of %d.\n", processor_name, process_id, num_processes); + + AcMeshInfo info = { + .int_params[AC_nx] = 128, + .int_params[AC_ny] = 64, + .int_params[AC_nz] = 32, + }; + acInit(info); + acIntegrate(0.1f); + acQuit(); + + MPI_Finalize(); + return EXIT_SUCCESS; +}