Skip to content

Commit

Permalink
add parallelization backend attribute to python interface
Browse files Browse the repository at this point in the history
  • Loading branch information
schuhmaj committed Dec 10, 2024
1 parent a3bf30c commit 9479f4a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ include(clang_format)
if (${POLYHEDRAL_GRAVITY_PARALLELIZATION} STREQUAL "TBB")
include(tbb)
thrust_set_TBB_target(TBB::tbb)
add_compile_definitions(POLYHEDRAL_GRAVITY_TBB)
elseif (${POLYHEDRAL_GRAVITY_PARALLELIZATION} STREQUAL "OMP")
add_compile_definitions(POLYHEDRAL_GRAVITY_OMP)
endif ()

# Thrust set-up i.e. the parallelization library, create targets according to the users specification
Expand Down
5 changes: 5 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@
#include "polyhedralGravity/model/GravityModel.h"
#include "polyhedralGravity/output/Logging.h"
#include "polyhedralGravity/output/CSVWriter.h"
#include "polyhedralGravity/Version.h"

int main(int argc, char *argv[]) {
using namespace polyhedralGravity;

SPDLOG_LOGGER_INFO(PolyhedralGravityLogger::DEFAULT_LOGGER.getLogger(), "Polyhedral Gravity Model Version " + std::string(POLYHEDRAL_GRAVITY_VERSION));
SPDLOG_LOGGER_INFO(PolyhedralGravityLogger::DEFAULT_LOGGER.getLogger(), "Polyhedral Gravity Model Parallelization Backend: " + std::string(POLYHEDRAL_GRAVITY_PARALLELIZATION));

if (argc != 2) {
SPDLOG_LOGGER_INFO(PolyhedralGravityLogger::DEFAULT_LOGGER.getLogger(), "Wrong program call! "
"Please use the program like this:\n"
Expand Down
14 changes: 14 additions & 0 deletions src/polyhedralGravity/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,19 @@ namespace polyhedralGravity {
*/
constexpr std::string_view POLYHEDRAL_GRAVITY_VERSION = "3.2.1";

/**
* The API parallelization backend of the polyhedral gravity model's interface.
* This value depends on the CMake configuration.
*/
constexpr std::string_view POLYHEDRAL_GRAVITY_PARALLELIZATION =
#ifdef POLYHEDRAL_GRAVITY_TBB
"TBB"
#elifdef POLYHEDRAL_GRAVITY_OMP
"OMP"
#else
"CPP"
#endif
;


}// namespace polyhedralGravity
1 change: 1 addition & 0 deletions src/polyhedralGravityPython/PolyhedralGravityPython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ PYBIND11_MODULE(polyhedral_gravity, m) {
Accordingly, the second derivative tensor is defined as the derivative of :math:`\textbf{g}`.
)mydelimiter";
m.attr("__version__") = POLYHEDRAL_GRAVITY_VERSION;
m.attr("__parallelization__") = POLYHEDRAL_GRAVITY_PARALLELIZATION;

py::enum_<NormalOrientation>(m, "NormalOrientation", R"mydelimiter(
The orientation of the plane unit normals of the polyhedron.
Expand Down

0 comments on commit 9479f4a

Please sign in to comment.