Initial MPI

This commit is contained in:
2023-10-29 20:50:54 -03:00
parent abedae2247
commit c032d066f0
5 changed files with 33 additions and 9 deletions

12
flake.lock generated
View File

@@ -5,11 +5,11 @@
"systems": "systems" "systems": "systems"
}, },
"locked": { "locked": {
"lastModified": 1689068808, "lastModified": 1694529238,
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", "rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -20,11 +20,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1690031011, "lastModified": 1696193975,
"narHash": "sha256-kzK0P4Smt7CL53YCdZCBbt9uBFFhE0iNvCki20etAf4=", "narHash": "sha256-mnQjUcYgp9Guu3RNVAB2Srr1TqKcPpRXmJf4LJk6KRY=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "12303c652b881435065a98729eb7278313041e49", "rev": "fdd898f8f79e8d2f99ed2ab6b3751811ef683242",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@@ -15,7 +15,7 @@
in in
{ {
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
packages = with pkgs; [ gcc cmake clang gnuplot llvmPackages.openmp bc ]; packages = with pkgs; [ gcc cmake clang gnuplot llvmPackages.openmp bc boost openmpi ];
}; };
}); });
} }

View File

@@ -16,6 +16,10 @@
#include "md/Space.hpp" #include "md/Space.hpp"
#include "md/System.hpp" #include "md/System.hpp"
#include <boost/mpi/communicator.hpp>
#include <boost/mpi/environment.hpp>
namespace mpi = boost::mpi;
int main() { int main() {
std::cout << "kk eae men" << std::endl; std::cout << "kk eae men" << std::endl;
@@ -44,5 +48,11 @@ int main() {
std::cout << "Getting neighboring cells of index 0" << std::endl; std::cout << "Getting neighboring cells of index 0" << std::endl;
Cell neighboringCells = space.getNeighboringCells(0); Cell neighboringCells = space.getNeighboringCells(0);
mpi::environment env;
mpi::communicator world;
std::cout << "Hello, world! I am process " << world.rank() << " of " << world.size() << "."
<< std::endl;
return 0; return 0;
} }

View File

@@ -1,5 +1,7 @@
# Copyright (c) 2023 jun <https://git.firmwarejun.net/jun/MolecularDynamics2> # Copyright (c) 2023 jun <https://git.firmwarejun.net/jun/MolecularDynamics2>
cmake_minimum_required(VERSION 3.25.2)
project(md) project(md)
add_library(md add_library(md
@@ -8,3 +10,11 @@ add_library(md
AtomsGenerator.cpp AtomsGenerator.cpp
System.cpp System.cpp
Space.cpp) Space.cpp)
find_package(MPI REQUIRED)
include_directories(${MPI_CXX_INCLUDE_PATH})
target_link_libraries(md ${MPI_CXX_LIBRARIES})
find_package(Boost REQUIRED COMPONENTS mpi)
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(md ${Boost_LIBRARIES})

View File

@@ -15,6 +15,8 @@
#include "Atom.hpp" #include "Atom.hpp"
#include <boost/mpi/datatype.hpp>
class Space; class Space;
/** /**
@@ -127,3 +129,5 @@ public:
*/ */
Cell getNeighboringCells(int x, int y, int z) const; Cell getNeighboringCells(int x, int y, int z) const;
}; };
BOOST_IS_MPI_DATATYPE(Cell);