From becef215d833394cbf60bee341e399ea16004ba6 Mon Sep 17 00:00:00 2001 From: jun Date: Fri, 6 Oct 2023 08:45:34 -0300 Subject: [PATCH] Initial MPI --- flake.lock | 12 ++++++------ flake.nix | 2 +- src/main.cpp | 10 ++++++++++ src/md/CMakeLists.txt | 12 +++++++++++- src/md/Space.hpp | 6 +++++- 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/flake.lock b/flake.lock index 33e17d1..be350f2 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1689068808, - "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", "owner": "numtide", "repo": "flake-utils", - "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", "type": "github" }, "original": { @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1690031011, - "narHash": "sha256-kzK0P4Smt7CL53YCdZCBbt9uBFFhE0iNvCki20etAf4=", + "lastModified": 1696193975, + "narHash": "sha256-mnQjUcYgp9Guu3RNVAB2Srr1TqKcPpRXmJf4LJk6KRY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "12303c652b881435065a98729eb7278313041e49", + "rev": "fdd898f8f79e8d2f99ed2ab6b3751811ef683242", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 44079d7..0c126f4 100644 --- a/flake.nix +++ b/flake.nix @@ -15,7 +15,7 @@ in { 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 ]; }; }); } \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 1fe9f6a..2f621f1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -16,6 +16,10 @@ #include "md/Space.hpp" #include "md/System.hpp" +#include +#include +namespace mpi = boost::mpi; + int main() { std::cout << "kk eae men" << std::endl; @@ -44,5 +48,11 @@ int main() { std::cout << "Getting neighboring cells of index 0" << std::endl; 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; } \ No newline at end of file diff --git a/src/md/CMakeLists.txt b/src/md/CMakeLists.txt index 4190bdf..e30e878 100644 --- a/src/md/CMakeLists.txt +++ b/src/md/CMakeLists.txt @@ -1,5 +1,7 @@ # Copyright (c) 2023 jun +cmake_minimum_required(VERSION 3.25.2) + project(md) add_library(md @@ -7,4 +9,12 @@ add_library(md Atom.cpp AtomsGenerator.cpp System.cpp - Space.cpp) \ No newline at end of file + 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}) diff --git a/src/md/Space.hpp b/src/md/Space.hpp index 6892eb0..645a1e4 100644 --- a/src/md/Space.hpp +++ b/src/md/Space.hpp @@ -15,6 +15,8 @@ #include "Atom.hpp" +#include + class Space; /** @@ -126,4 +128,6 @@ public: * @return Cell */ Cell getNeighboringCells(int x, int y, int z) const; -}; \ No newline at end of file +}; + +BOOST_IS_MPI_DATATYPE(Cell); \ No newline at end of file