From 43db0b6ad97a6a5626e546534f028dcff693b5f1 Mon Sep 17 00:00:00 2001 From: L Laniewski-Wollk Date: Wed, 20 Dec 2023 22:18:35 +1000 Subject: [PATCH 01/11] Removing legacy python integration --- src/Geometry.cpp.Rt | 76 +---------- src/Handlers/cbPythonCall.cpp | 231 ---------------------------------- src/Handlers/cbPythonCall.h | 17 --- src/config.h.in | 3 - src/config.mk.in | 1 - src/configure.ac | 55 -------- src/main.cpp | 7 -- 7 files changed, 1 insertion(+), 389 deletions(-) delete mode 100644 src/Handlers/cbPythonCall.cpp delete mode 100644 src/Handlers/cbPythonCall.h diff --git a/src/Geometry.cpp.Rt b/src/Geometry.cpp.Rt index ff8c56954..6cc9444d9 100644 --- a/src/Geometry.cpp.Rt +++ b/src/Geometry.cpp.Rt @@ -1,8 +1,4 @@ #include "Consts.h" -#ifdef EMBEDED_PYTHON - #include - #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION -#endif - #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION - #include -#endif -#include "cbPythonCall.h" -std::string cbPythonCall::xmlname = "CallPython"; -#include "../HandlerFactory.h" - -int cbPythonCall::Init () { - Callback::Init(); - static bool firstTime = true; - if (firstTime){ - firstTime = false; - #ifdef EMBEDED_PYTHON - - char const* syspythonpath = getenv( "PYTHONPATH" ); - - std::string oldpath; - - if ( syspythonpath == NULL ) { - // Big problem... - } else { - oldpath = std::string( syspythonpath ); - } - pugi::xml_attribute pn_pythonpath = node.attribute("pythonpath"); - - oldpath.resize (oldpath.size()+1,':'); - oldpath.resize (oldpath.size()+1,'.'); - - if (pn_pythonpath){ - oldpath.resize (oldpath.size()+1,':'); - oldpath.append(pn_pythonpath.value()); - } - setenv("PYTHONPATH",oldpath.c_str(),1); - debug1("PYTHONPATH set to %s", oldpath.c_str() ); - - Py_Initialize(); - _import_array(); - #else - ERROR("No Python support at compile time (./configure ... --enable-python)"); - return -1; - #endif - } - return 0; - } - - -int cbPythonCall::DoIt () { - - pugi::xml_attribute module = node.attribute("module"); - pugi::xml_attribute function = node.attribute("function"); - pugi::xml_attribute comp = node.attribute("densities"); - pugi::xml_attribute quan = node.attribute("quantities"); - - - name_set components, quantities; - if(comp){ - components.add_from_string(comp.value(),','); - } - if(quan){ - quantities.add_from_string(quan.value(),','); - } - Callback::DoIt(); - - if (!module || !function || (!comp && !quan)) { - error("Missing params in PythonCall"); - } - - std::vector buffers; - - -#ifdef EMBEDED_PYTHON - -////BEGIN PYTHON HANDLING - - - PyObject *pModule, *pOffsets, *pFunc, *pGlobalSize; - PyObject *pValue, *pArgs; - - //pName = PyString_FromString(module.value()); - /* Error checking of pName left out */ - - pModule = PyImport_ImportModule(module.value()); - //Py_DECREF(pName); - - if (pModule != NULL) { - int buff_id = 0; - pFunc = PyObject_GetAttrString( pModule, function.value() ); - /* pFunc is a new reference */ - - if (pFunc && PyCallable_Check(pFunc)) { - - const int extra_args = 4; - pArgs = PyTuple_New(components.size()+quantities.size()+extra_args); - buffers.resize( components.size()+quantities.size() ); - long int offsets[3] = {-1,-1,-1}; - - for (name_set::iterator it = components.begin(); it!=components.end(); ++it){ - const char * component = it->c_str(); - - PyObject* pInputData; - real_t * buffer; - long int dims[3]; - - long int size = solver->getComponentIntoBuffer(component, buffer, dims, offsets ); - - if (sizeof(real_t) == sizeof(float) ) { - pInputData = PyArray_SimpleNewFromData(3, dims, NPY_FLOAT, buffer); - } else if (sizeof(real_t) == sizeof(double) ){ - pInputData = PyArray_SimpleNewFromData(3, dims, NPY_DOUBLE, buffer); - } - - buffers[buff_id] = buffer; - - //pInputData reference is stolen here - PyTuple_SetItem(pArgs, buff_id+extra_args, pInputData); - - buff_id ++; - } - - - for (name_set::iterator it = quantities.begin(); it!=quantities.end(); ++it){ - const char * quantity = it->c_str(); - - PyObject* pInputData; - real_t * buffer; - long int dims[4]; - - long int size = solver->getQuantityIntoBuffer(quantity, buffer, dims, offsets ); - - if (sizeof(real_t) == sizeof(float) ) { - pInputData = PyArray_SimpleNewFromData(4, dims, NPY_FLOAT, buffer); - } else if (sizeof(real_t) == sizeof(double) ){ - pInputData = PyArray_SimpleNewFromData(4, dims, NPY_DOUBLE, buffer); - } - - buffers[buff_id] = buffer; - - //pInputData reference is stolen here - PyTuple_SetItem(pArgs, buff_id+extra_args, pInputData); - buff_id++; - } - - - - - - pOffsets = PyTuple_New(3); - for (int k=0; k < 3; k++){ - PyTuple_SetItem(pOffsets, k, PyLong_FromLong(offsets[k])); - } - - pGlobalSize = PyTuple_New(3); - PyTuple_SetItem(pGlobalSize, 0, PyLong_FromLong(solver->info.region.nx)); - PyTuple_SetItem(pGlobalSize, 1, PyLong_FromLong(solver->info.region.ny)); - PyTuple_SetItem(pGlobalSize, 2, PyLong_FromLong(solver->info.region.nz)); - - //first one defines number of extra arguments used - PyTuple_SetItem(pArgs, 0, PyLong_FromLong( extra_args )); - PyTuple_SetItem(pArgs, 1, pOffsets); - PyTuple_SetItem(pArgs, 2, PyLong_FromLong( solver->iter )); - PyTuple_SetItem(pArgs, 3, pGlobalSize ); - - pValue = PyObject_CallObject(pFunc, pArgs); - Py_DECREF(pArgs); - long ret_value = 999; - if (pValue != NULL) { - ret_value = PyLong_AsLong(pValue); - Py_DECREF(pValue); - } - - - output("Result of Python call: %ld\n",ret_value); - if (ret_value != 0) { - Py_DECREF(pFunc); - Py_DECREF(pModule); - PyErr_Print(); - error("PythonCall failed\n"); - return 1; - } - - } - else { - if (PyErr_Occurred()) { - PyErr_Print(); - error("PythonCall: Cannot find function \"%s\"\n", function.value()); - } - } - Py_XDECREF(pFunc); - Py_DECREF(pModule); - - int all_buff = buff_id; - buff_id = 0; - - for (name_set::iterator it = components.begin(); it!=components.end(); ++it){ - const char * component = it->c_str(); - for (int k =0; k < 10; k++){ - debug1("PythonCall after,comp %s, buffer %d, value %d: %f\n",component,buff_id,k, buffers[buff_id][k]); - } - int status = solver->loadComponentFromBuffer(component, buffers[buff_id]); - buff_id++; - } - for (; buff_id <= all_buff; buff_id++){ - // delete [] buffers[buff_id]; - } - - } - else { - PyErr_Print(); - error("PythonCall: Failed to load \"%s\"\n", module.value()); - return 1; - } - - -// Py_Finalize(); -//END PYTHON HANDLING -#else - ERROR("No Python support at compile time (./configure ... --enable-python)"); - return -1; -#endif - - - - return 0; - }; - - -// Register the handler (basing on xmlname) in the Handler Factory -template class HandlerFactory::Register< GenericAsk< cbPythonCall > >; diff --git a/src/Handlers/cbPythonCall.h b/src/Handlers/cbPythonCall.h deleted file mode 100644 index 3ab342eb3..000000000 --- a/src/Handlers/cbPythonCall.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef CBPYTHONCALL_H -#define CBPYTHONCALL_H - -#include "../CommonHandler.h" - -#include "vHandler.h" -#include "Callback.h" - -class cbPythonCall : public Callback { - std::string fn; - public: - static std::string xmlname; -int Init (); -int DoIt (); -}; - -#endif // CBPYTHONCALL_H diff --git a/src/config.h.in b/src/config.h.in index 53aa387ac..98fd8aa8b 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -83,9 +83,6 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION -/* Build-in python support */ -#undef EMBEDED_PYTHON - /* If to use the C++11 chrono */ #undef USE_STEADY_CLOCK diff --git a/src/config.mk.in b/src/config.mk.in index ddc60527b..98fd1fea2 100644 --- a/src/config.mk.in +++ b/src/config.mk.in @@ -10,7 +10,6 @@ PV_BUILD = @PV_BUILD@ PV_BUILD_INC = @PV_BUILD_INC@ PV_VERSION = @PV_VERSION@ WITH_CATALYST = @WITH_CATALYST@ -EMBEDED_PYTHON = @EMBEDED_PYTHON@ WITH_LAMMPS = @WITH_LAMMPS@ diff --git a/src/configure.ac b/src/configure.ac index 08c6794ea..f45001d28 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -133,18 +133,6 @@ AC_ARG_ENABLE([debug-kernel], AS_HELP_STRING([--with-debug-kernel], [enable NVCC pos compile stats for debug (lots of output!)])) -AC_ARG_WITH([python], - AS_HELP_STRING([--with-python], - [Enable CallPython handler, requires python-dev])) - -AC_ARG_WITH([python_config], - AS_HELP_STRING([--with-python-config], - [Set python-config binary to call])) - -AC_ARG_WITH([python_bin], - AS_HELP_STRING([--with-python-bin], - [Set python binary to call])) - AC_ARG_WITH([x-block], AS_HELP_STRING([--with-x-block], [Set the block size in the x direction (X_BLOCK) (default=32)])) @@ -548,48 +536,6 @@ if test "x${with_hdf5}" != "xno"; then fi fi - -if test "x${with_python}" == "xyes"; then - - AC_CHECK_PROG(python_bin,"${with_python_bin}","${with_python_bin}",python3) - AC_CHECK_PROG(python_config,"${with_python_config}","${with_python_config}",${python_bin}-config) - - AC_MSG_NOTICE([python config: ${python_config}]) - AC_MSG_NOTICE([python: ${python_bin}]) - - - AC_MSG_CHECKING([python embandinng: linker flags]) - - if ${python_config} --ldflags --embed; then - PF=$(${python_config} --ldflags --embed) - else - PF=$(${python_config} --ldflags) - fi - - LDFLAGS="${LDFLAGS} ${PF}" - - AC_MSG_RESULT([${PF}]) - - AC_MSG_CHECKING([Python - numpy additional include path]) - PYINC="$(${python_bin} -c 'import numpy; print(numpy.get_include())')" - CPPFLAGS="${CPPFLAGS} -I${PYINC}" - AC_MSG_RESULT([${PYINC}]) - - AC_MSG_CHECKING([Python Embandinng: compiler flags]) -# PF=$($python_config --cflags) - PF=$($python_config --includes) - CPPFLAGS="${CPPFLAGS} ${PF}" - - PF=$($python_config --prefix) - - LDFLAGS="${LDFLAGS} -L${PF}/lib" - EMBEDED_PYTHON=1 - AC_MSG_RESULT([${PF}]) - AC_DEFINE([EMBEDED_PYTHON], [1], [Using Python support]) -fi - - - NLOPT="" AS_CASE([x${with_nlopt}],[xyes],[want_nlopt="yes"],[xno],[want_nlopt="no"],[x],[want_nlopt="maybe"],[want_nlopt="yes" @@ -1007,7 +953,6 @@ AC_SUBST(WITH_R) AC_SUBST(TAPENADE) AC_SUBST(PV_VERSION) AC_SUBST(RTOPT) -AC_SUBST(EMBEDED_PYTHON) AC_SUBST(X_BLOCK) AC_SUBST(WARPSIZE) AC_SUBST(X_MOD) diff --git a/src/main.cpp b/src/main.cpp index 2c96008d6..5b7aed727 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,10 +4,6 @@ #include "Consts.h" -#ifdef EMBEDED_PYTHON -#include -#endif - #include "Global.h" #include #include "Region.h" @@ -412,9 +408,6 @@ int main ( int argc, char * argv[] ) return -1; } } - #ifdef EMBEDED_PYTHON - Py_Finalize(); - #endif // Finish and clean up debug2("CudaFree ...\n"); From f13a7f65fd4885e81190c5ffdb629bb97e7a8311 Mon Sep 17 00:00:00 2001 From: L Laniewski-Wollk Date: Wed, 20 Dec 2023 23:11:05 +1000 Subject: [PATCH 02/11] Removing legacy python integration test --- tests/external | 2 +- tools/tests.sh | 30 ++++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/tests/external b/tests/external index 7a0eba632..00555d40a 160000 --- a/tests/external +++ b/tests/external @@ -1 +1 @@ -Subproject commit 7a0eba6321ec50bdfeefadbe5f2fc0d4cf615d49 +Subproject commit 00555d40a538c69d4efb5266f954885f4fc6e107 diff --git a/tools/tests.sh b/tools/tests.sh index ccd7486d5..e6a4472d7 100755 --- a/tools/tests.sh +++ b/tools/tests.sh @@ -130,13 +130,34 @@ then exit 0 fi -if test -z "$*" + +TESTS_ARG="$*" +if test -z "$TESTS_ARG" then - TESTS=$(cd tests/external/$MODEL; ls *.test 2>/dev/null) -else - TESTS="$*" + TESTS_ARG="." fi +TESTS="" +DIR="tests/external/$MODEL" +for t in $TESTS_ARG +do + ADD="" + if test -f "$DIR/$t" + then + ADD="$t" + elif test -f "$DIR/$t.test" + then + ADD="$t.test" + elif test -d "$DIR/$t" + then + ADD="$(cd $DIR; ls $t/*.test 2>/dev/null)" + else + echo "Test not found: $t" + exit -1 + fi + TESTS="$TESTS $ADD" +done + if test -z "$TESTS" then echo "No tests for model $MODEL (WARNING: there is a directory tests/external/$MODEL)" @@ -186,6 +207,7 @@ function testModel { do TEST="${t%.test}" t="$TEST.test" + TEST=$(echo $TEST | sed 's|^[.]/||g' | sed 's|/|-|g') TDIR="test-$MODEL-$TEST-$1" test -d "$TDIR" && rm -r "$TDIR" RESULT="OK" From 6827cd24b5ad36ccc4951a373358095f9c895e73 Mon Sep 17 00:00:00 2001 From: L Laniewski-Wollk Date: Wed, 20 Dec 2023 23:33:20 +1000 Subject: [PATCH 03/11] Correcting const in memcpy2D --- src/cross.cu | 2 +- src/cross.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cross.cu b/src/cross.cu index f6683502b..62dee9461 100644 --- a/src/cross.cu +++ b/src/cross.cu @@ -11,7 +11,7 @@ uint3 CpuBlock, CpuThread, CpuSize; -void memcpy2D(void * dst_, int dpitch, void * src_, int spitch, int width, int height) { +void memcpy2D(void * dst_, int dpitch, const void * src_, int spitch, int width, int height) { char * dst = (char*) dst_, *src = (char*) src_; for (int i=0; i(args)...); } - void memcpy2D(void * dst_, int dpitch, void * src_, int spitch, int width, int height); + void memcpy2D(void * dst_, int dpitch, const void * src_, int spitch, int width, int height); template inline T data_cast(const P& x) { static_assert(sizeof(T)==sizeof(P),"Wrong sizes in data_cast"); From cd6fddb3863bd13f242ae62809269202e398a9d7 Mon Sep 17 00:00:00 2001 From: L Laniewski-Wollk Date: Thu, 21 Dec 2023 13:06:31 +1000 Subject: [PATCH 04/11] Correcting flag overwrite in RunR --- src/Handlers/cbRunR.cpp | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/Handlers/cbRunR.cpp b/src/Handlers/cbRunR.cpp index c3be43ab8..edc1def54 100644 --- a/src/Handlers/cbRunR.cpp +++ b/src/Handlers/cbRunR.cpp @@ -342,25 +342,22 @@ class rGeometry : public rWrapper { Rcpp::IntegerVector v(v_); lbRegion reg = solver->lattice->region; size_t size = reg.sizeL(); - { - flag_t * NodeType = new flag_t[size]; - solver->lattice->GetFlags(reg, NodeType); - for (const Model::NodeTypeGroupFlag& it : solver->lattice->model->nodetypegroupflags) { - bool some_na = false; - for (size_t i=0;ilattice->GetFlags(reg, NodeType); + const Model::NodeTypeGroupFlag& it = solver->lattice->model->nodetypegroupflags.by_name(name); + bool some_na = false; + for (size_t i=0;ilattice->FlagOverwrite(NodeType, reg); - delete[] NodeType; } + if (some_na) { + ERROR("Some NA in Geometry (%s) assignment", it.name.c_str()); + } + solver->lattice->FlagOverwrite(NodeType, reg); + delete[] NodeType; return; } From a9ece375c068e85ed5896d7b84e8de55a1c82a8b Mon Sep 17 00:00:00 2001 From: L Laniewski-Wollk Date: Thu, 21 Dec 2023 16:03:50 +1000 Subject: [PATCH 05/11] Correcting SETTINGZONES in RunR --- src/Handlers/cbRunR.cpp | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/src/Handlers/cbRunR.cpp b/src/Handlers/cbRunR.cpp index edc1def54..9b1b633a8 100644 --- a/src/Handlers/cbRunR.cpp +++ b/src/Handlers/cbRunR.cpp @@ -344,7 +344,12 @@ class rGeometry : public rWrapper { size_t size = reg.sizeL(); flag_t * NodeType = new flag_t[size]; solver->lattice->GetFlags(reg, NodeType); - const Model::NodeTypeGroupFlag& it = solver->lattice->model->nodetypegroupflags.by_name(name); + Model::NodeTypeGroupFlag it = solver->lattice->model->nodetypegroupflags.by_name(name); + if (!it) it = solver->lattice->model->settingzones; + if (name != it.name) { + ERROR("Geometry component not found: %s\n", name.c_str()); + return; + } bool some_na = false; for (size_t i=0;ilattice->model->nodetypegroupflags.by_name(name); - if (it) { // Geometry components + Model::NodeTypeGroupFlag it = solver->lattice->model->nodetypegroupflags.by_name(name); + if (!it) it = solver->lattice->model->settingzones; + if (name != it.name) { + ERROR("Geometry component not found: %s\n", name.c_str()); + return rNull; + } flag_t * NodeType = new flag_t[size]; solver->lattice->GetFlags(reg, NodeType); Rcpp::IntegerVector small(size); @@ -407,22 +416,28 @@ SEXP Dollar(std::string name) { for (size_t i=0;i> it.shift); } - Rcpp::CharacterVector levels(it.max+1); - levels[0] = "None"; - for (const Model::NodeTypeFlag& it2 : solver->lattice->model->nodetypeflags) { - if (it2.group_id == it.id) { - int idx = it2.flag >> it.shift; - if (idx < levels.size()) levels[idx] = it2.name; + + if (name == "SETTINGZONES") { + Rcpp::CharacterVector levels(solver->geometry->SettingZones.size()); + for (const auto it2 : solver->geometry->SettingZones) { + levels[it2.second] = it2.first; + } + small.attr("levels") = levels; + } else { + Rcpp::CharacterVector levels(it.max+1); + levels[0] = "None"; + for (const Model::NodeTypeFlag& it2 : solver->lattice->model->nodetypeflags) { + if (it2.group_id == it.id) { + int idx = it2.flag >> it.shift; + if (idx < levels.size()) levels[idx] = it2.name; + } } + small.attr("levels") = levels; } - small.attr("levels") = levels; small.attr("class") = "factor"; delete[] NodeType; return small; } - ERROR("R: Unknown component of Geometry"); - return Rcpp::IntegerVector(0); -} virtual Rcpp::CharacterVector Names() { Rcpp::CharacterVector ret; ret.push_back("dx"); From 7b4fc4f3622b3704413ef31450199390f95ce81b Mon Sep 17 00:00:00 2001 From: L Laniewski-Wollk Date: Tue, 2 Jan 2024 13:05:14 +1000 Subject: [PATCH 06/11] New rinside tests --- .github/workflows/rinside.yaml | 62 ++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/rinside.yaml diff --git a/.github/workflows/rinside.yaml b/.github/workflows/rinside.yaml new file mode 100644 index 000000000..c91a8380e --- /dev/null +++ b/.github/workflows/rinside.yaml @@ -0,0 +1,62 @@ +name: RInside + +on: [ push, pull_request ] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + model: + - d2q9 + precision: + - float + - double + arch: + - cpu + - cuda + - hip + reticulate: + - true + - false + test: + - true + - false + exclude: + - arch: "cuda" + test: true + - arch: "hip" + test: true + - reticulate: true + test: false + steps: + - name: Git checkout + uses: actions/checkout@v3 + - name: Install dependencies + uses: ./.github/actions/install + with: + r: true + rdep: true + openmpi: true + rinside: true + reticulate: ${{ matrix.reticulate }} + cuda: ${{ matrix.arch == 'cuda' }} + hip: ${{ matrix.arch == 'hip' }} + - name: Configure + uses: ./.github/actions/configure + with: + gpu: ${{ matrix.arch == 'cuda' }} + hip: ${{ matrix.arch == 'hip' }} + cuda_arch: sm_60 + rinside: true + paranoid: true + precision: ${{ matrix.precision }} + - name: Compile + uses: ./.github/actions/compile + with: + model: ${{ matrix.model }} + - name: Run tests + uses: ./.github/actions/test + with: + model: ${{ matrix.model }} From 7e6315b1d95e172813e712fd47c37a2887ae92b7 Mon Sep 17 00:00:00 2001 From: L Laniewski-Wollk Date: Tue, 2 Jan 2024 13:39:50 +1000 Subject: [PATCH 07/11] rinside tests --- .github/actions/test/action.yaml | 6 +++++- .github/workflows/rinside.yaml | 13 +++++++------ tests/external | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/actions/test/action.yaml b/.github/actions/test/action.yaml index 26ace19f8..ae7bc3a8c 100644 --- a/.github/actions/test/action.yaml +++ b/.github/actions/test/action.yaml @@ -4,9 +4,13 @@ inputs: model: description: model to compile default: 'd2q9' + tests: + description: what tests to run + default: '' + runs: using: 'composite' steps: - shell: bash name: Run tests - run: tools/tests.sh ${{ inputs.model }} + run: tools/tests.sh ${{ inputs.model }} ${{ inputs.tests }} diff --git a/.github/workflows/rinside.yaml b/.github/workflows/rinside.yaml index c91a8380e..340dc3da9 100644 --- a/.github/workflows/rinside.yaml +++ b/.github/workflows/rinside.yaml @@ -17,9 +17,6 @@ jobs: - cpu - cuda - hip - reticulate: - - true - - false test: - true - false @@ -28,7 +25,9 @@ jobs: test: true - arch: "hip" test: true - - reticulate: true + - precision: "float" + test: true + - precision: "double" test: false steps: - name: Git checkout @@ -40,7 +39,7 @@ jobs: rdep: true openmpi: true rinside: true - reticulate: ${{ matrix.reticulate }} + reticulate: ${{ matrix.test }} cuda: ${{ matrix.arch == 'cuda' }} hip: ${{ matrix.arch == 'hip' }} - name: Configure @@ -56,7 +55,9 @@ jobs: uses: ./.github/actions/compile with: model: ${{ matrix.model }} - - name: Run tests + - if: matrix.test + name: Run tests uses: ./.github/actions/test with: model: ${{ matrix.model }} + tests: rinside diff --git a/tests/external b/tests/external index 00555d40a..2db8a6b38 160000 --- a/tests/external +++ b/tests/external @@ -1 +1 @@ -Subproject commit 00555d40a538c69d4efb5266f954885f4fc6e107 +Subproject commit 2db8a6b38b7b83d931f434dda00cbf23a1bf1b4c From 2303d39ba0fcb02dedff0a2ff579106e89a7c990 Mon Sep 17 00:00:00 2001 From: L Laniewski-Wollk Date: Tue, 2 Jan 2024 13:47:04 +1000 Subject: [PATCH 08/11] adding default hip version in install action --- .github/actions/install/action.yaml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/actions/install/action.yaml b/.github/actions/install/action.yaml index 691fd206f..d616da551 100644 --- a/.github/actions/install/action.yaml +++ b/.github/actions/install/action.yaml @@ -130,20 +130,26 @@ runs: shell: bash name: "Installing CUDA" run: | - GPU="${{ inputs.cuda }}" - if test "$GPU" == "true" + VER="${{ inputs.cuda }}" + if test "$VER" == "true" then - GPU="11.7" + VER="11.7" fi - tools/install.sh ${{inputs.options}} cuda $GPU - CUDA_PATH=/usr/local/cuda-$GPU + tools/install.sh ${{inputs.options}} cuda $VER + CUDA_PATH=/usr/local/cuda-$VER echo "$CUDA_PATH/bin" >>$GITHUB_PATH echo "LD_LIBRARY_PATH=$CUDA_PATH/lib64:$LD_LIBRARY_PATH" >>$GITHUB_ENV echo "CUDA_PATH=$CUDA_PATH" >>$GITHUB_OUTPUT - if: inputs.hip != 'false' name: "Installing ROCm/HIP" shell: bash - run: tools/install.sh ${{inputs.options}} hip ${{ inputs.hip }} + run: | + VER="${{ inputs.hip }}" + if test "$VER" == "true" + then + VER="5.4.1" + fi + tools/install.sh ${{inputs.options}} hip $VER - if: inputs.openmpi != 'false' name: "Installing OpenMPI" shell: bash From 9e1d870edd3a1c4a45c5a5ed54b2afc377d7e6d1 Mon Sep 17 00:00:00 2001 From: L Laniewski-Wollk Date: Tue, 2 Jan 2024 13:54:58 +1000 Subject: [PATCH 09/11] Fixing paranoid error in RunR --- src/Handlers/cbRunR.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Handlers/cbRunR.cpp b/src/Handlers/cbRunR.cpp index 9b1b633a8..b88de668c 100644 --- a/src/Handlers/cbRunR.cpp +++ b/src/Handlers/cbRunR.cpp @@ -419,7 +419,7 @@ SEXP Dollar(std::string name) { if (name == "SETTINGZONES") { Rcpp::CharacterVector levels(solver->geometry->SettingZones.size()); - for (const auto it2 : solver->geometry->SettingZones) { + for (const auto& it2 : solver->geometry->SettingZones) { levels[it2.second] = it2.first; } small.attr("levels") = levels; From 9995364a93b79c9fe041ddd30e4f1392c7c927d6 Mon Sep 17 00:00:00 2001 From: L Laniewski-Wollk Date: Tue, 2 Jan 2024 14:26:17 +1000 Subject: [PATCH 10/11] Running rinside tests only for cpu and double --- .github/workflows/rinside.yaml | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/.github/workflows/rinside.yaml b/.github/workflows/rinside.yaml index 340dc3da9..d049ce092 100644 --- a/.github/workflows/rinside.yaml +++ b/.github/workflows/rinside.yaml @@ -17,21 +17,15 @@ jobs: - cpu - cuda - hip - test: - - true - - false - exclude: - - arch: "cuda" - test: true - - arch: "hip" - test: true - - precision: "float" - test: true + include: - precision: "double" - test: false + arch: "cpu" + test: true steps: - name: Git checkout uses: actions/checkout@v3 + with: + submodules: ${{ matrix.test }} - name: Install dependencies uses: ./.github/actions/install with: From 449c875e04ba22381fc00a81fa19954b0ed47667 Mon Sep 17 00:00:00 2001 From: L Laniewski-Wollk Date: Tue, 2 Jan 2024 22:49:33 +1000 Subject: [PATCH 11/11] Correcting RunR for float --- src/Handlers/cbRunR.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Handlers/cbRunR.cpp b/src/Handlers/cbRunR.cpp index b88de668c..2032e477d 100644 --- a/src/Handlers/cbRunR.cpp +++ b/src/Handlers/cbRunR.cpp @@ -108,13 +108,15 @@ class rFields : public rWrapper { return Rcpp::NumericVector(0); } lbRegion reg = solver->lattice->region; - Rcpp::NumericVector ret(reg.size()); + std::vector vec; + vec.resize(reg.size()); + solver->lattice->Get_Field(it.id, &vec[0]); + Rcpp::NumericVector ret(vec.begin(),vec.end()); Rcpp::IntegerVector retdim(3); retdim[0] = reg.nx; retdim[1] = reg.ny; retdim[2] = reg.nz; ret.attr("dim") = retdim; - solver->lattice->Get_Field(it.id, &ret[0]); return ret; } @@ -129,7 +131,8 @@ class rFields : public rWrapper { ERROR("Wrong size of the parameter field!"); return; } - solver->lattice->Set_Field(it.id,&v[0]); + std::vector vec(v.begin(),v.end()); + solver->lattice->Set_Field(it.id,&vec[0]); return; } Rcpp::CharacterVector Names() {