Dear Deal.II developers,
Greetings!
I am a new user of Deal.II. Currently I would like to test the hello world
program on Utilities::MPI.
A minimum working example is attached to this email.
However, when I run the command "mpirun -np 5 ./MPI_TEST", I get the
following message,
Hello world from process 0 of 1
Hello world from process 0 of 1
Hello world from process 0 of 1
Hello world from process 0 of 1
Hello world from process 0 of 1
It seems that 5 cpu cores are used, however, they seemed to have the same
rank.
Besides, my operating system is Ubuntu 16.04. Looking forward to hearing
from you soon. Thank you!
Best Regards,
Yang Liu
--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see
https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/dealii/CAEmspPAS%3DSgYOdUOU8twH7OAr%3DTFJiJrEDJFRB3M9fJk14hgLQ%40mail.gmail.com.
##
# CMake script for the step-6 tutorial program:
##
# Set the name of the project and target:
SET(TARGET "MPI_TEST")
# Declare all source files the target consists of. Here, this is only
# the one step-X.cc file, but as you expand your project you may wish
# to add other source files as well. If your project becomes much larger,
# you may want to either replace the following statement by something like
# FILE(GLOB_RECURSE TARGET_SRC "source/*.cc")
# FILE(GLOB_RECURSE TARGET_INC "include/*.h")
# SET(TARGET_SRC ${TARGET_SRC} ${TARGET_INC})
# or switch altogether to the large project CMakeLists.txt file discussed
# in the "CMake in user projects" page accessible from the "User info"
# page of the documentation.
SET(TARGET_SRC
${TARGET}.cc
)
# Usually, you will not need to modify anything beyond this point...
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
FIND_PACKAGE(deal.II 9.1.0 QUIET
HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}
)
IF(NOT ${MPI_FOUND})
MESSAGE(FATAL_ERROR "\n"
"*** Could not locate a (sufficiently recent) version of MPI. ***\n\n"
)
ENDIF()
IF(NOT ${deal.II_FOUND})
MESSAGE(FATAL_ERROR "\n"
"*** Could not locate a (sufficiently recent) version of deal.II. ***\n\n"
"You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to
cmake\n"
"or set an environment variable \"DEAL_II_DIR\" that contains this path."
)
ENDIF()
DEAL_II_INITIALIZE_CACHED_VARIABLES()
PROJECT(${TARGET})
DEAL_II_INVOKE_AUTOPILOT()
#include <deal.II/base/mpi.h>
#include <deal.II/base/conditional_ostream.h>
#include <fstream>
using namespace dealii;
template <int dim>
class MPI_TEST
{
public:
MPI_TEST();
void print_test();
private:
MPI_Comm mpi_communicator;
const unsigned int n_mpi_processes;
const unsigned int this_mpi_process;
ConditionalOStream pcout;
};
template <int dim>
void MPI_TEST<dim>::print_test()
{
for (unsigned int i = this_mpi_process; i < n_mpi_processes; ++i)
{
std::cout << "Hello world from process " << this_mpi_process << " of " << n_mpi_processes << std::endl;
}
}
template <int dim>
MPI_TEST<dim>::MPI_TEST()
: mpi_communicator(MPI_COMM_WORLD)
, n_mpi_processes(Utilities::MPI::n_mpi_processes(mpi_communicator))
, this_mpi_process(Utilities::MPI::this_mpi_process(mpi_communicator))
, pcout(std::cout, (this_mpi_process == 0))
{}
int main(int argc, char ** argv)
{
MPI_TEST<2> hw_mpi;
Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
hw_mpi.print_test();
return 0;
}