Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Python/Plugins/CMakeLists.txt
Comment thread
paradajzblond marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ endmacro()
add_plugin_binding_if(Gnn Acts::PluginGnn ACTS_BUILD_PLUGIN_GNN)
add_plugin_binding_if(Covfie Acts::PluginCovfie ACTS_BUILD_PLUGIN_TRACCC)
add_plugin_binding_if(Detray Acts::PluginDetray ACTS_BUILD_PLUGIN_TRACCC)
add_plugin_binding_if(Vecmem Acts::PluginDetray ACTS_BUILD_PLUGIN_TRACCC)
add_plugin_binding_if(DD4hep ActsPluginDD4hep ACTS_BUILD_PLUGIN_DD4HEP)
add_plugin_binding_if(Geant4 ActsPluginGeant4 ACTS_BUILD_PLUGIN_GEANT4)
add_plugin_binding_if(GeoModel Acts::PluginGeoModel ACTS_BUILD_PLUGIN_GEOMODEL)
Expand All @@ -56,5 +55,13 @@ add_plugin_binding_if(Svg Acts::PluginActSVG ACTS_BUILD_PLUGIN_ACTSVG)
add_plugin_binding_if(TGeo Acts::PluginRoot ACTS_BUILD_PLUGIN_ROOT)
add_plugin_binding_if(Root Acts::PluginRoot ACTS_BUILD_PLUGIN_ROOT)

# ---- Traccc: host always, device gated ----
add_plugin_binding_if(TracccHost "traccc::core;traccc::device_common;traccc::io" ACTS_BUILD_PLUGIN_TRACCC)
add_plugin_binding_if(TracccCuda "traccc::cuda" ACTS_BUILD_PLUGIN_TRACCC AND ACTS_ENABLE_CUDA)

# ---- Vecmem: host always, device gated ----
add_plugin_binding_if(VecmemHost vecmem::core ACTS_BUILD_PLUGIN_TRACCC)
add_plugin_binding_if(VecmemCuda "vecmem::cuda;traccc::cuda" ACTS_BUILD_PLUGIN_TRACCC AND ACTS_ENABLE_CUDA)

# Propagate the list of built plugins to the parent scope
set(_plugins_built "${_plugins_built}" PARENT_SCOPE)
27 changes: 27 additions & 0 deletions Python/Plugins/src/TracccCuda.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// This file is part of the ACTS project.
//
// Copyright (C) 2016 CERN for the benefit of the ACTS project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

#include "ActsPython/Utilities/Helpers.hpp"
#include "ActsPython/Utilities/Macros.hpp"

#include <memory>
#include <string>

#include <traccc/cuda/utils/stream.hpp>
#include <traccc/utils/memory_resource.hpp>

namespace py = pybind11;
using namespace pybind11::literals;

PYBIND11_MODULE(ActsPluginsPythonBindingsTraccc, traccc) {
auto cuda = traccc.def_submodule("cuda", "CUDA backend bindings");

py::class_<traccc::cuda::stream, std::shared_ptr<traccc::cuda::stream>>(
cuda, "stream")
.def(py::init<>());
}
33 changes: 33 additions & 0 deletions Python/Plugins/src/TracccHost.cpp
Comment thread
paradajzblond marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// This file is part of the ACTS project.
//
// Copyright (C) 2016 CERN for the benefit of the ACTS project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

#include "ActsPython/Utilities/Helpers.hpp"
#include "ActsPython/Utilities/Macros.hpp"

#include <memory>
#include <string>

#include <traccc/utils/memory_resource.hpp>

namespace py = pybind11;
using namespace pybind11::literals;

PYBIND11_MODULE(ActsPluginsPythonBindingsTraccc, traccc) {
auto host = traccc.def_submodule("host", "CPU backend bindings");

// ---- traccc types ----
py::class_<traccc::memory_resource, std::shared_ptr<traccc::memory_resource>>(
host, "memory_resource")
.def(py::init([](vecmem::memory_resource& main,
vecmem::memory_resource* host) {
return std::make_shared<traccc::memory_resource>(main, host);
}),
py::arg("main"), py::arg("host") = nullptr,
py::keep_alive<1, 2>(), // keep main alive
py::keep_alive<1, 3>()); // keep host alive
}
49 changes: 49 additions & 0 deletions Python/Plugins/src/VecmemCuda.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// This file is part of the ACTS project.
//
// Copyright (C) 2016 CERN for the benefit of the ACTS project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

#include "ActsPython/Utilities/Helpers.hpp"
#include "ActsPython/Utilities/Macros.hpp"

#include <memory>
#include <string>

#include <traccc/cuda/utils/stream.hpp>
#include <traccc/utils/memory_resource.hpp>
#include <vecmem/memory/cuda/device_memory_resource.hpp>
#include <vecmem/memory/cuda/host_memory_resource.hpp>
#include <vecmem/memory/host_memory_resource.hpp>
#include <vecmem/utils/copy.hpp>
#include <vecmem/utils/cuda/async_copy.hpp>

namespace py = pybind11;
using namespace pybind11::literals;

PYBIND11_MODULE(ActsPluginsPythonBindingsVecmem, vecmem) {
auto cuda = vecmem.def_submodule("cuda", "CUDA backend bindings");

py::class_<vecmem::cuda::host_memory_resource, vecmem::memory_resource,
std::shared_ptr<vecmem::cuda::host_memory_resource>>(
cuda, "host_memory_resource")
.def(py::init<>());

py::class_<vecmem::cuda::device_memory_resource, vecmem::memory_resource,
std::shared_ptr<vecmem::cuda::device_memory_resource>>(
cuda, "device_memory_resource")
.def(py::init<>());

py::class_<traccc::cuda::stream, std::shared_ptr<traccc::cuda::stream>>(
cuda, "stream")
.def(py::init<>());

py::class_<vecmem::cuda::async_copy, vecmem::copy,
std::shared_ptr<vecmem::cuda::async_copy>>(cuda, "async_copy")
.def(py::init([](traccc::cuda::stream& s) {
return std::make_shared<vecmem::cuda::async_copy>(s.cudaStream());
}),
py::arg("stream"), py::keep_alive<1, 2>());
}
25 changes: 14 additions & 11 deletions Python/Plugins/src/Vecmem.cpp → Python/Plugins/src/VecmemHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@
#include <string>

#include <vecmem/memory/host_memory_resource.hpp>
#include <vecmem/memory/memory_resource.hpp>
#include <vecmem/utils/copy.hpp>

namespace py = pybind11;
using namespace pybind11::literals;

PYBIND11_MODULE(ActsPluginsPythonBindingsVecmem, vecmem) {
{
py::class_<vecmem::memory_resource,
std::shared_ptr<vecmem::memory_resource>>(vecmem,
"MemoryResource");

py::class_<vecmem::host_memory_resource, vecmem::memory_resource,
std::shared_ptr<vecmem::host_memory_resource>>(
vecmem, "HostMemoryResource")
.def(py::init<>());
}
auto host = vecmem.def_submodule("host", "CPU backend bindings");

py::class_<vecmem::memory_resource, std::shared_ptr<vecmem::memory_resource>>(
host, "memory_resource");

py::class_<vecmem::copy, std::shared_ptr<vecmem::copy>>(vecmem, "copy");

py::class_<vecmem::host_memory_resource, vecmem::memory_resource,
std::shared_ptr<vecmem::host_memory_resource>>(
host, "host_memory_resource")
.def(py::init<>());
py::class_<vecmem::copy, std::shared_ptr<vecmem::copy>>(host, "copy")
.def(py::init<>());
}
Loading