Skip to content

Commit feb1945

Browse files
authored
update ci yml files (#12)
* update ci yml files * adding the command for building pybind11 in the CI * adding the command for building pybind11 in the CI * minor corrections * meson updated the yml codes * making the numpy example optional (easier for the CI's)
1 parent 22ed7e1 commit feb1945

File tree

9 files changed

+82
-18
lines changed

9 files changed

+82
-18
lines changed

.github/workflows/master-test-workflow.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,31 @@ jobs:
4040
with:
4141
submodules: 'true'
4242

43+
- name: Build Pybind11
44+
run: |
45+
cd extern/pybind11
46+
mkdir -p build
47+
cd build
48+
cmake .. -DPython_EXECUTABLE=/usr/bin/python3
49+
make check -j"$(nproc)"
50+
51+
mkdir -p mock_install/share/pkgconfig
52+
cat <<EOF > mock_install/share/pkgconfig/pybind11.pc
53+
prefix=$(pwd)/..
54+
includedir=\${prefix}/include
55+
56+
Name: pybind11
57+
Description: Seamless operability between C++11 and Python
58+
Version: 2.13.6
59+
Cflags: -I\${includedir}
60+
EOF
61+
62+
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$(pwd)/mock_install/share/pkgconfig" >> $GITHUB_ENV
63+
64+
export LD_PRELOAD=/usr/local/lib/libnosv.so
65+
4366
- name: Setup
44-
run: source /home/hicr/.bashrc && meson setup build -Dbuildtype=debug -Db_coverage=true -DdistributedEngine=mpi -DbuildTests=true -DbuildExamples=true -DcompileWarningsAsErrors=true
67+
run: source /home/hicr/.bashrc && meson setup build -Dbuildtype=debug -Db_coverage=true -DdistributedEngine=mpi -DbuildTests=true -DbuildExamples=true -DcompileWarningsAsErrors=true -DexecutionStateType=nosv,boost -DprocessingUnitType=nosv,pthreads -DbuildPyTaskR=true
4568

4669
- name: Compile
4770
run: source /home/hicr/.bashrc && meson compile -C build

.github/workflows/pr-development-workflow.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ jobs:
231231
docker run --name taskr --shm-size=1024M --privileged -v $PWD:/home/hicr/taskr -w /home/hicr/taskr -td ${{ env.DOCKERIMAGE }}:${{ inputs.arch }}-latest bash
232232
233233
- name: Setup
234-
run: docker exec -u hicr taskr bash -c "meson setup build -Dbuildtype=debug -Db_coverage=true -DdistributedEngine=mpi -DbuildTests=true -DbuildExamples=true -DcompileWarningsAsErrors=true"
234+
run: docker exec -u hicr taskr bash -c "meson setup build -Dbuildtype=debug -Db_coverage=true -DdistributedEngine=mpi -DbuildTests=true -DbuildExamples=true -DcompileWarningsAsErrors=true -DexecutionStateType=nosv,boost -DprocessingUnitType=nosv,pthreads -DbuildPyTaskR=true"
235235

236236
- name: Compile
237237
run: docker exec -u hicr taskr bash -c "meson compile -C build"
@@ -270,8 +270,31 @@ jobs:
270270
with:
271271
submodules: 'true'
272272

273+
- name: Build Pybind11
274+
run: |
275+
cd extern/pybind11
276+
mkdir -p build
277+
cd build
278+
cmake .. -DPython_EXECUTABLE=/usr/bin/python3
279+
make check -j"$(nproc)"
280+
281+
mkdir -p mock_install/share/pkgconfig
282+
cat <<EOF > mock_install/share/pkgconfig/pybind11.pc
283+
prefix=$(pwd)/..
284+
includedir=\${prefix}/include
285+
286+
Name: pybind11
287+
Description: Seamless operability between C++11 and Python
288+
Version: 2.13.6
289+
Cflags: -I\${includedir}
290+
EOF
291+
292+
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$(pwd)/mock_install/share/pkgconfig" >> $GITHUB_ENV
293+
294+
export LD_PRELOAD=/usr/local/lib/libnosv.so
295+
273296
- name: Setup
274-
run: source /home/hicr/.bashrc && meson setup build -Dbuildtype=debug -Db_coverage=true -DdistributedEngine=mpi -DbuildTests=true -DbuildExamples=true -DcompileWarningsAsErrors=true
297+
run: source /home/hicr/.bashrc && meson setup build -Dbuildtype=debug -Db_coverage=true -DdistributedEngine=mpi -DbuildTests=true -DbuildExamples=true -DcompileWarningsAsErrors=true -DexecutionStateType=nosv,boost -DprocessingUnitType=nosv,pthreads -DbuildPyTaskR=true
275298

276299
- name: Compile
277300
run: source /home/hicr/.bashrc && meson compile -C build

examples/matmul/python/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def main():
2727
# Running matmul example
2828
matmul_cpp_Driver(runtime)
2929

30-
matmul_numpy_Driver(runtime)
30+
# matmul_numpy_Driver(runtime)
3131

3232

3333
if __name__ == "__main__":

examples/matmul/python/matmul.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,22 @@
1919

2020
#include <taskr/taskr.hpp>
2121

22+
#ifdef ENABLE_INSTRUMENTATION
23+
#include <tracr.hpp>
24+
#endif
25+
2226
#define mytype float
2327

2428
/**
2529
* Compute mmm
2630
*/
2731
void matmul(taskr::Task *)
2832
{
29-
const size_t N = 1000;
33+
#ifdef ENABLE_INSTRUMENTATION
34+
INSTRUMENTATION_VMARKER_SET(MARK_COLOR_RED);
35+
#endif
36+
37+
const size_t N = 200;
3038

3139
// Allocate memory
3240
volatile mytype *A = (mytype *)calloc(1, N * N * sizeof(mytype));
@@ -56,6 +64,10 @@ void matmul(taskr::Task *)
5664
free((mytype *)A);
5765
free((mytype *)B);
5866
free((mytype *)C);
67+
68+
#ifdef ENABLE_INSTRUMENTATION
69+
INSTRUMENTATION_VMARKER_RESET();
70+
#endif
5971
}
6072

6173
PYBIND11_MODULE(cpp_matmul, m)

examples/matmul/python/matmul.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"""
1616

1717
import time
18-
import numpy as np
1918

2019
import taskr
2120
import cpp_matmul
@@ -45,15 +44,14 @@ def matmul_cpp_Driver(runtime):
4544

4645

4746

48-
49-
5047
def matmul_numpy_Driver(runtime):
48+
import numpy as np
5149
# Initializing taskr
5250
runtime.initialize()
5351

5452
def matmul_numpy(task):
5553
N = 1000
56-
A = np.zeros((N,N))
54+
A = np.empty((N,N))
5755
B = np.empty((N,N))
5856
C = np.empty((N,N))
5957

examples/simple/python/main.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
"""
16-
1716
import taskr
17+
1818
import simple
1919

20+
NWORKERS = 4
21+
2022
def main():
21-
# Initialize taskr with the wanted compute manager backend and number of PUs
22-
t = taskr.taskr(taskr.HiCRBackend.nosv, 2)
23+
# Initialize taskr with the wanted HiCR backend and number of Workers
24+
t = taskr.taskr(backend=taskr.HiCRBackend.nosv, num_workers=NWORKERS)
2325

2426
# Get the runtime
2527
runtime = t.get_runtime()

examples/simple/python/simple.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
"""
16-
1716
import taskr
1817

1918
NTASKS = 2
@@ -22,8 +21,8 @@ def simple(runtime):
2221
# Initializing taskr
2322
runtime.initialize()
2423

24+
# Create tasks
2525
fc = lambda task : print(f"Hello, I am task {task.getLabel()}")
26-
2726
taskfc = taskr.Function(fc)
2827

2928
# Adding to tasks to taskr

include/pytaskr/meson.build

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22
# Manually compile like this:
33
# c++ -O3 -Wall -shared -std=c++11 -fPIC $(python3-config --includes) -Iextern/pybind11/include example.cpp -o example$(python3-config --extension-suffix)
44

5-
py = import('python').find_installation(pure: false)
5+
python_mod = import('python')
6+
7+
py = python_mod.find_installation(pure: false)
8+
9+
if not py.found()
10+
py = python_mod.find_installation('/usr/bin/python3', pure: false)
11+
endif
12+
613
pybind11_dep = dependency('pybind11', required: true)
714

815
py.extension_module('taskr',

include/pytaskr/pytaskr.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ PYBIND11_MODULE(taskr, m)
4848
.def("setServiceWorkerCallbackHandler", &Runtime::setServiceWorkerCallbackHandler)
4949
.def("setTaskWorkerCallbackHandler", &Runtime::setTaskWorkerCallbackHandler)
5050
.def("initialize", &Runtime::initialize)
51-
.def("addTask", &Runtime::addTask, py::keep_alive<1, 2>()) // keep_alive as the task should be alive until runtime's destructor
51+
.def("addTask", &Runtime::addTask, py::keep_alive<1, 2>(), py::arg("task")) // keep_alive as the task should be alive until runtime's destructor
5252
.def("resumeTask", &Runtime::resumeTask)
5353
.def("run", &Runtime::run, py::call_guard<py::gil_scoped_release>())
5454
.def("await_", &Runtime::await, py::call_guard<py::gil_scoped_release>()) // Release GIL is important otherwise non-finished tasks are getting blocked
@@ -57,12 +57,12 @@ PYBIND11_MODULE(taskr, m)
5757
.def("addService", &Runtime::addService);
5858

5959
// TaskR's Function class
60-
py::class_<Function>(m, "Function").def(py::init<const function_t>());
60+
py::class_<Function>(m, "Function").def(py::init<const function_t>(), py::arg("fc"));
6161

6262
// TaskR's Task class
6363
py::class_<Task>(m, "Task")
6464
.def(py::init<Function *, const workerId_t>(), py::arg("fc"), py::arg("workerAffinity") = -1)
65-
.def(py::init<const label_t, Function *, const workerId_t>(), py::arg("label"), py::arg("fc"), py::arg("workerAffinity") = -1)
65+
.def(py::init<const label_t, Function *, const workerId_t>(), py::arg("label"), py::arg("taskfc"), py::arg("workerAffinity") = -1)
6666
.def("getLabel", &Task::getLabel)
6767
.def("setLabel", &Task::setLabel)
6868
.def("getWorkerAffinity", &Task::getWorkerAffinity)

0 commit comments

Comments
 (0)