Skip to content

Commit 57c0569

Browse files
committed
[Bindings] Add ExecParams bindings
Signed-off-by: Jean-Nicolas Brunet <[email protected]>
1 parent 5a1748f commit 57c0569

File tree

5 files changed

+86
-1
lines changed

5 files changed

+86
-1
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/******************************************************************************
2+
* SofaPython3 plugin *
3+
* (c) 2021 CNRS, University of Lille, INRIA *
4+
* *
5+
* This program is free software; you can redistribute it and/or modify it *
6+
* under the terms of the GNU Lesser General Public License as published by *
7+
* the Free Software Foundation; either version 2.1 of the License, or (at *
8+
* your option) any later version. *
9+
* *
10+
* This program is distributed in the hope that it will be useful, but WITHOUT *
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
13+
* for more details. *
14+
* *
15+
* You should have received a copy of the GNU Lesser General Public License *
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
17+
*******************************************************************************
18+
* Contact information: [email protected] *
19+
******************************************************************************/
20+
21+
#include <SofaPython3/Sofa/Core/Binding_ExecParams.h>
22+
#include <sofa/core/ExecParams.h>
23+
24+
namespace py { using namespace pybind11; }
25+
26+
namespace sofapython3 {
27+
28+
void moduleAddExecParams(py::module& m) {
29+
using namespace sofa::core;
30+
py::class_<ExecParams> c (m, "ExecParams", "Class gathering parameters use by most components methods, and transmitted by all visitors");
31+
c.def(py::init());
32+
33+
py::enum_<ExecParams::ExecMode> (c, "ExecMode")
34+
.value("EXEC_NONE", ExecParams::ExecMode::EXEC_NONE)
35+
.value("EXEC_DEFAULT", ExecParams::ExecMode::EXEC_DEFAULT)
36+
.value("EXEC_DEBUG", ExecParams::ExecMode::EXEC_DEBUG)
37+
.value("EXEC_GPU", ExecParams::ExecMode::EXEC_GPU)
38+
.value("EXEC_GRAPH", ExecParams::ExecMode::EXEC_GRAPH)
39+
.export_values()
40+
;
41+
42+
// Public properties/methods
43+
c.def("checkValidStorage", &ExecParams::checkValidStorage);
44+
c.def("execMode", &ExecParams::execMode, "Mode of execution requested");
45+
c.def("threadID", &ExecParams::threadID, "Index of current thread (0 corresponding to the only thread in sequential mode, or first thread in parallel mode)");
46+
c.def("nbThreads", &ExecParams::nbThreads, "Number of threads currently known to Sofa");
47+
c.def("update", &ExecParams::update, "Make sure this instance is up-to-date relative to the current thread");
48+
c.def("setExecMode", &ExecParams::setExecMode, "Request a specific mode of execution");
49+
c.def("setThreadID", &ExecParams::setThreadID, "Specify the index of the current thread");
50+
51+
}
52+
53+
} // namespace sofapython3
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/******************************************************************************
2+
* SofaPython3 plugin *
3+
* (c) 2021 CNRS, University of Lille, INRIA *
4+
* *
5+
* This program is free software; you can redistribute it and/or modify it *
6+
* under the terms of the GNU Lesser General Public License as published by *
7+
* the Free Software Foundation; either version 2.1 of the License, or (at *
8+
* your option) any later version. *
9+
* *
10+
* This program is distributed in the hope that it will be useful, but WITHOUT *
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
13+
* for more details. *
14+
* *
15+
* You should have received a copy of the GNU Lesser General Public License *
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
17+
*******************************************************************************
18+
* Contact information: [email protected] *
19+
******************************************************************************/
20+
21+
#pragma once
22+
#include <pybind11/pybind11.h>
23+
24+
namespace sofapython3 {
25+
26+
void moduleAddExecParams(pybind11::module &m);
27+
28+
} /// namespace sofapython3

bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_MechanicalParams.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace sofapython3 {
2828

2929
void moduleAddMechanicalParams(py::module& m) {
3030
using namespace sofa::core;
31-
py::class_<MechanicalParams> c (m, "MechanicalParams", doc::mechanicalparams::MechanicalParamsClass);
31+
py::class_<MechanicalParams, ExecParams> c (m, "MechanicalParams", doc::mechanicalparams::MechanicalParamsClass);
3232
c.def(py::init());
3333

3434
// Dt

bindings/Sofa/src/SofaPython3/Sofa/Core/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ set(HEADER_FILES
1818
${CMAKE_CURRENT_SOURCE_DIR}/Binding_Controller_doc.h
1919
${CMAKE_CURRENT_SOURCE_DIR}/Binding_DataEngine.h
2020
${CMAKE_CURRENT_SOURCE_DIR}/Binding_DataEngine_doc.h
21+
${CMAKE_CURRENT_SOURCE_DIR}/Binding_ExecParams.h
2122
${CMAKE_CURRENT_SOURCE_DIR}/Binding_ForceField.h
2223
${CMAKE_CURRENT_SOURCE_DIR}/Binding_ForceField_doc.h
2324
${CMAKE_CURRENT_SOURCE_DIR}/Binding_ObjectFactory.h
@@ -63,6 +64,7 @@ set(SOURCE_FILES
6364
${CMAKE_CURRENT_SOURCE_DIR}/Data/Binding_DataString.cpp
6465
${CMAKE_CURRENT_SOURCE_DIR}/Data/Binding_DataLink.cpp
6566
${CMAKE_CURRENT_SOURCE_DIR}/Data/Binding_DataVectorString.cpp
67+
${CMAKE_CURRENT_SOURCE_DIR}/Binding_ExecParams.cpp
6668
${CMAKE_CURRENT_SOURCE_DIR}/Binding_ForceField.cpp
6769
${CMAKE_CURRENT_SOURCE_DIR}/Binding_ObjectFactory.cpp
6870
${CMAKE_CURRENT_SOURCE_DIR}/Binding_MechanicalParams.cpp

bindings/Sofa/src/SofaPython3/Sofa/Core/Submodule_Core.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ using sofa::helper::logging::Message;
3434
#include <SofaPython3/Sofa/Core/Binding_Context.h>
3535
#include <SofaPython3/Sofa/Core/Binding_Controller.h>
3636
#include <SofaPython3/Sofa/Core/Binding_DataEngine.h>
37+
#include <SofaPython3/Sofa/Core/Binding_ExecParams.h>
3738
#include <SofaPython3/Sofa/Core/Binding_ObjectFactory.h>
3839
#include <SofaPython3/Sofa/Core/Binding_MechanicalParams.h>
3940
#include <SofaPython3/Sofa/Core/Binding_MultiVecId.h>
@@ -135,6 +136,7 @@ PYBIND11_MODULE(Core, core)
135136
moduleAddContext(core);
136137
moduleAddController(core);
137138
moduleAddDataEngine(core);
139+
moduleAddExecParams(core);
138140
moduleAddForceField(core);
139141
moduleAddObjectFactory(core);
140142
moduleAddMechanicalParams(core);

0 commit comments

Comments
 (0)