From 45363e494fc2ff414cebb9a7ec349894c52c9250 Mon Sep 17 00:00:00 2001 From: Luca Date: Wed, 29 Apr 2026 15:24:14 +0200 Subject: [PATCH 1/3] chore: update submodules --- examples/cholesky/source/nosv.cpp | 4 +++- examples/energySaver/cpp/nosv.cpp | 4 ++-- examples/jacobi3d/source/grid.cpp | 30 +++++++++++++++++++++++---- examples/jacobi3d/source/jacobi3d.hpp | 15 +++++++------- examples/jacobi3d/source/nosv.cpp | 2 +- examples/jacobi3d/source/pthreads.cpp | 2 +- examples/resourceList/cpp/nosv.cpp | 2 +- extern/HiCR | 2 +- include/taskr/runtime.hpp | 1 + meson.build | 2 +- 10 files changed, 45 insertions(+), 19 deletions(-) diff --git a/examples/cholesky/source/nosv.cpp b/examples/cholesky/source/nosv.cpp index a3ac487..18fbb2b 100644 --- a/examples/cholesky/source/nosv.cpp +++ b/examples/cholesky/source/nosv.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -82,7 +83,8 @@ int main(int argc, char **argv) // Initializing Pthreads-based compute manager to run tasks in parallel HiCR::backend::nosv::ComputeManager computeManager; - HiCR::backend::pthreads::CommunicationManager communicationManager; + auto core = HiCR::backend::pthreads::Core(computeResources.size()); + HiCR::backend::pthreads::CommunicationManager communicationManager(core); // Creating taskr object nlohmann::json taskrConfig; diff --git a/examples/energySaver/cpp/nosv.cpp b/examples/energySaver/cpp/nosv.cpp index f94ad14..d2ed450 100644 --- a/examples/energySaver/cpp/nosv.cpp +++ b/examples/energySaver/cpp/nosv.cpp @@ -92,10 +92,10 @@ int main(int argc, char **argv) taskr.setTaskCallbackHandler(HiCR::tasking::Task::callback_t::onTaskFinish, [&taskr](taskr::Task *task) { delete task; }); // Creating task work function - auto workFunction = taskr::Function([&iterations](taskr::Task *task) { workFc(iterations); }); + auto workFunction = taskr::Function(&computeManager, [&iterations](taskr::Task *task) { workFc(iterations); }); // Creating task wait function - auto waitFunction = taskr::Function([&taskr, &secondsDelay](taskr::Task *task) { waitFc(&taskr, secondsDelay); }); + auto waitFunction = taskr::Function(&computeManager, [&taskr, &secondsDelay](taskr::Task *task) { waitFc(&taskr, secondsDelay); }); // Creating a single wait task that suspends all workers except for one auto waitTask1 = new taskr::Task(0, &waitFunction); diff --git a/examples/jacobi3d/source/grid.cpp b/examples/jacobi3d/source/grid.cpp index 3264a91..d0649f3 100644 --- a/examples/jacobi3d/source/grid.cpp +++ b/examples/jacobi3d/source/grid.cpp @@ -393,12 +393,14 @@ bool Grid::initialize() // Creating producer and consumer channels t.X0SendChannel = std::make_unique(*_communicationManager, + *_communicationManager, sendGlobalTokenBufferSlot, sendProducerCoordinationBuffer->getSourceLocalMemorySlot(), sendConsumerCoordinationBuffer, sizeof(double) * bufferSizeX, CHANNEL_DEPTH); t.X0RecvChannel = std::make_unique(*_communicationManager, + *_communicationManager, recvGlobalTokenBufferSlot, recvConsumerCoordinationBuffer->getSourceLocalMemorySlot(), recvProducerCoordinationBuffer, @@ -423,12 +425,14 @@ bool Grid::initialize() // Creating producer and consumer channels t.X1SendChannel = std::make_unique(*_communicationManager, + *_communicationManager, sendGlobalTokenBufferSlot, sendProducerCoordinationBuffer->getSourceLocalMemorySlot(), sendConsumerCoordinationBuffer, sizeof(double) * bufferSizeX, CHANNEL_DEPTH); t.X1RecvChannel = std::make_unique(*_communicationManager, + *_communicationManager, recvGlobalTokenBufferSlot, recvConsumerCoordinationBuffer->getSourceLocalMemorySlot(), recvProducerCoordinationBuffer, @@ -453,12 +457,14 @@ bool Grid::initialize() // Creating producer and consumer channels t.Y0SendChannel = std::make_unique(*_communicationManager, + *_communicationManager, sendGlobalTokenBufferSlot, sendProducerCoordinationBuffer->getSourceLocalMemorySlot(), sendConsumerCoordinationBuffer, sizeof(double) * bufferSizeY, CHANNEL_DEPTH); t.Y0RecvChannel = std::make_unique(*_communicationManager, + *_communicationManager, recvGlobalTokenBufferSlot, recvConsumerCoordinationBuffer->getSourceLocalMemorySlot(), recvProducerCoordinationBuffer, @@ -483,12 +489,14 @@ bool Grid::initialize() // Creating producer and consumer channels t.Y1SendChannel = std::make_unique(*_communicationManager, + *_communicationManager, sendGlobalTokenBufferSlot, sendProducerCoordinationBuffer->getSourceLocalMemorySlot(), sendConsumerCoordinationBuffer, sizeof(double) * bufferSizeY, CHANNEL_DEPTH); t.Y1RecvChannel = std::make_unique(*_communicationManager, + *_communicationManager, recvGlobalTokenBufferSlot, recvConsumerCoordinationBuffer->getSourceLocalMemorySlot(), recvProducerCoordinationBuffer, @@ -513,12 +521,14 @@ bool Grid::initialize() // Creating producer and consumer channels t.Z0SendChannel = std::make_unique(*_communicationManager, + *_communicationManager, sendGlobalTokenBufferSlot, sendProducerCoordinationBuffer->getSourceLocalMemorySlot(), sendConsumerCoordinationBuffer, sizeof(double) * bufferSizeZ, CHANNEL_DEPTH); t.Z0RecvChannel = std::make_unique(*_communicationManager, + *_communicationManager, recvGlobalTokenBufferSlot, recvConsumerCoordinationBuffer->getSourceLocalMemorySlot(), recvProducerCoordinationBuffer, @@ -543,12 +553,14 @@ bool Grid::initialize() // Creating producer and consumer channels t.Z1SendChannel = std::make_unique(*_communicationManager, + *_communicationManager, sendGlobalTokenBufferSlot, sendProducerCoordinationBuffer->getSourceLocalMemorySlot(), sendConsumerCoordinationBuffer, sizeof(double) * bufferSizeZ, CHANNEL_DEPTH); t.Z1RecvChannel = std::make_unique(*_communicationManager, + *_communicationManager, recvGlobalTokenBufferSlot, recvConsumerCoordinationBuffer->getSourceLocalMemorySlot(), recvProducerCoordinationBuffer, @@ -582,11 +594,21 @@ bool Grid::initialize() // Creating channel if (processId == 0) - residualConsumerChannel = std::make_unique( - *_communicationManager, residualGlobalTokenBufferSlot, residualCoordinationBufferSlot, residualGlobalCoordinationBufferSlot, sizeof(double), processCount); + residualConsumerChannel = std::make_unique(*_communicationManager, + *_communicationManager, + residualGlobalTokenBufferSlot, + residualCoordinationBufferSlot, + residualGlobalCoordinationBufferSlot, + sizeof(double), + processCount); if (processId != 0) - residualProducerChannel = std::make_unique( - *_communicationManager, residualGlobalTokenBufferSlot, residualCoordinationBufferSlot, residualGlobalCoordinationBufferSlot, sizeof(double), processCount); + residualProducerChannel = std::make_unique(*_communicationManager, + *_communicationManager, + residualGlobalTokenBufferSlot, + residualCoordinationBufferSlot, + residualGlobalCoordinationBufferSlot, + sizeof(double), + processCount); } free(globalRankX); diff --git a/examples/jacobi3d/source/jacobi3d.hpp b/examples/jacobi3d/source/jacobi3d.hpp index def6204..8685f0b 100644 --- a/examples/jacobi3d/source/jacobi3d.hpp +++ b/examples/jacobi3d/source/jacobi3d.hpp @@ -22,6 +22,7 @@ #include "task.hpp" void jacobi3d(HiCR::InstanceManager *instanceManager, + HiCR::ComputeManager *computeManager, taskr::Runtime &taskr, Grid *g, size_t gDepth = 1, @@ -41,15 +42,15 @@ void jacobi3d(HiCR::InstanceManager *instanceManager, if (success == false) instanceManager->abort(-1); // Creating grid processing functions - g->resetFc = std::make_unique([&g](taskr::Task *task) { g->reset(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k); }); + g->resetFc = std::make_unique(computeManager, [&g](taskr::Task *task) { g->reset(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k); }); g->computeFc = - std::make_unique([&g](taskr::Task *task) { g->compute(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k, ((Task *)task)->iteration); }); + std::make_unique(computeManager, [&g](taskr::Task *task) { g->compute(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k, ((Task *)task)->iteration); }); g->receiveFc = - std::make_unique([&g](taskr::Task *task) { g->receive(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k, ((Task *)task)->iteration); }); - g->unpackFc = std::make_unique([&g](taskr::Task *task) { g->unpack(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k, ((Task *)task)->iteration); }); - g->packFc = std::make_unique([&g](taskr::Task *task) { g->pack(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k, ((Task *)task)->iteration); }); - g->sendFc = std::make_unique([&g](taskr::Task *task) { g->send(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k, ((Task *)task)->iteration); }); - g->localResidualFc = std::make_unique( + std::make_unique(computeManager, [&g](taskr::Task *task) { g->receive(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k, ((Task *)task)->iteration); }); + g->unpackFc = std::make_unique(computeManager, [&g](taskr::Task *task) { g->unpack(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k, ((Task *)task)->iteration); }); + g->packFc = std::make_unique(computeManager, [&g](taskr::Task *task) { g->pack(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k, ((Task *)task)->iteration); }); + g->sendFc = std::make_unique(computeManager, [&g](taskr::Task *task) { g->send(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k, ((Task *)task)->iteration); }); + g->localResidualFc = std::make_unique(computeManager, [&g](taskr::Task *task) { g->calculateLocalResidual(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k, ((Task *)task)->iteration); }); // Task map diff --git a/examples/jacobi3d/source/nosv.cpp b/examples/jacobi3d/source/nosv.cpp index 7b91c3a..a7e8916 100644 --- a/examples/jacobi3d/source/nosv.cpp +++ b/examples/jacobi3d/source/nosv.cpp @@ -131,7 +131,7 @@ void jacobiDriver(HiCR::InstanceManager *instanceManager, HiCR::CommunicationMan auto g = std::make_unique(myInstanceId, N, nIters, gDepth, pt, lt, &taskr, memoryManager, topologyManager.get(), communicationManager); // running the Jacobi3D example - jacobi3d(instanceManager, taskr, g.get(), gDepth, N, nIters, pt, lt); + jacobi3d(instanceManager, &computeManager, taskr, g.get(), gDepth, N, nIters, pt, lt); #ifdef _TASKR_DISTRIBUTED_ENGINE_MPI // Finalizing instances diff --git a/examples/jacobi3d/source/pthreads.cpp b/examples/jacobi3d/source/pthreads.cpp index cf2364e..3a9f9d2 100644 --- a/examples/jacobi3d/source/pthreads.cpp +++ b/examples/jacobi3d/source/pthreads.cpp @@ -122,7 +122,7 @@ void jacobiDriver(HiCR::InstanceManager *instanceManager, HiCR::CommunicationMan auto g = std::make_unique(myInstanceId, N, nIters, gDepth, pt, lt, &taskr, memoryManager, topologyManager.get(), communicationManager); // running the Jacobi3D example - jacobi3d(instanceManager, taskr, g.get(), gDepth, N, nIters, pt, lt); + jacobi3d(instanceManager, &boostComputeManager, taskr, g.get(), gDepth, N, nIters, pt, lt); } #ifdef _TASKR_DISTRIBUTED_ENGINE_LPF diff --git a/examples/resourceList/cpp/nosv.cpp b/examples/resourceList/cpp/nosv.cpp index 67c32f9..b82a4e8 100644 --- a/examples/resourceList/cpp/nosv.cpp +++ b/examples/resourceList/cpp/nosv.cpp @@ -89,7 +89,7 @@ int main(int argc, char **argv) taskr::Runtime taskr(&computeManager, &computeManager, selectedComputeResources); // Creating task function - auto taskFunction = taskr::Function([&iterations](taskr::Task *task) { work(iterations); }); + auto taskFunction = taskr::Function(&computeManager, [&iterations](taskr::Task *task) { work(iterations); }); // Adding multiple compute tasks printf("Running %lu work tasks with %lu processing units...\n", workTaskCount, coreSubset.size()); diff --git a/extern/HiCR b/extern/HiCR index cf98e54..6eb59ea 160000 --- a/extern/HiCR +++ b/extern/HiCR @@ -1 +1 @@ -Subproject commit cf98e54dac453b1465ad59921f547b20ab057719 +Subproject commit 6eb59ea9e63461c847ec06a2dc7819ba41f509fc diff --git a/include/taskr/runtime.hpp b/include/taskr/runtime.hpp index e53b6c9..c90720b 100644 --- a/include/taskr/runtime.hpp +++ b/include/taskr/runtime.hpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include diff --git a/meson.build b/meson.build index 47d28d5..7f72229 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project('TaskR', [ 'cpp', 'c'], subproject_dir : 'extern', default_options : [ - 'cpp_std=c++17', + 'cpp_std=c++20', 'buildtype=release' ], version: '1.0.0' From a283c854e9a768fba02ce4e06122fd0dd24b0880 Mon Sep 17 00:00:00 2001 From: Luca Date: Wed, 29 Apr 2026 15:25:52 +0200 Subject: [PATCH 2/3] style: format files --- examples/cholesky/source/nosv.cpp | 2 +- examples/jacobi3d/source/jacobi3d.hpp | 23 +++++++++++++---------- include/taskr/runtime.hpp | 1 - 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/examples/cholesky/source/nosv.cpp b/examples/cholesky/source/nosv.cpp index 18fbb2b..2f412a9 100644 --- a/examples/cholesky/source/nosv.cpp +++ b/examples/cholesky/source/nosv.cpp @@ -83,7 +83,7 @@ int main(int argc, char **argv) // Initializing Pthreads-based compute manager to run tasks in parallel HiCR::backend::nosv::ComputeManager computeManager; - auto core = HiCR::backend::pthreads::Core(computeResources.size()); + auto core = HiCR::backend::pthreads::Core(computeResources.size()); HiCR::backend::pthreads::CommunicationManager communicationManager(core); // Creating taskr object diff --git a/examples/jacobi3d/source/jacobi3d.hpp b/examples/jacobi3d/source/jacobi3d.hpp index 8685f0b..2b3f0ff 100644 --- a/examples/jacobi3d/source/jacobi3d.hpp +++ b/examples/jacobi3d/source/jacobi3d.hpp @@ -42,16 +42,19 @@ void jacobi3d(HiCR::InstanceManager *instanceManager, if (success == false) instanceManager->abort(-1); // Creating grid processing functions - g->resetFc = std::make_unique(computeManager, [&g](taskr::Task *task) { g->reset(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k); }); - g->computeFc = - std::make_unique(computeManager, [&g](taskr::Task *task) { g->compute(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k, ((Task *)task)->iteration); }); - g->receiveFc = - std::make_unique(computeManager, [&g](taskr::Task *task) { g->receive(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k, ((Task *)task)->iteration); }); - g->unpackFc = std::make_unique(computeManager, [&g](taskr::Task *task) { g->unpack(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k, ((Task *)task)->iteration); }); - g->packFc = std::make_unique(computeManager, [&g](taskr::Task *task) { g->pack(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k, ((Task *)task)->iteration); }); - g->sendFc = std::make_unique(computeManager, [&g](taskr::Task *task) { g->send(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k, ((Task *)task)->iteration); }); - g->localResidualFc = std::make_unique(computeManager, - [&g](taskr::Task *task) { g->calculateLocalResidual(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k, ((Task *)task)->iteration); }); + g->resetFc = std::make_unique(computeManager, [&g](taskr::Task *task) { g->reset(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k); }); + g->computeFc = std::make_unique( + computeManager, [&g](taskr::Task *task) { g->compute(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k, ((Task *)task)->iteration); }); + g->receiveFc = std::make_unique( + computeManager, [&g](taskr::Task *task) { g->receive(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k, ((Task *)task)->iteration); }); + g->unpackFc = std::make_unique(computeManager, + [&g](taskr::Task *task) { g->unpack(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k, ((Task *)task)->iteration); }); + g->packFc = std::make_unique(computeManager, + [&g](taskr::Task *task) { g->pack(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k, ((Task *)task)->iteration); }); + g->sendFc = std::make_unique(computeManager, + [&g](taskr::Task *task) { g->send(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k, ((Task *)task)->iteration); }); + g->localResidualFc = std::make_unique( + computeManager, [&g](taskr::Task *task) { g->calculateLocalResidual(task, ((Task *)task)->i, ((Task *)task)->j, ((Task *)task)->k, ((Task *)task)->iteration); }); // Task map std::map> _taskMap; diff --git a/include/taskr/runtime.hpp b/include/taskr/runtime.hpp index c90720b..2186465 100644 --- a/include/taskr/runtime.hpp +++ b/include/taskr/runtime.hpp @@ -373,7 +373,6 @@ class Runtime */ __INLINE__ void await() { - // Verify taskr is correctly running if (_state != state_t::running) HICR_THROW_LOGIC("Trying to wait for TaskR, but it was not running"); From 96deee0a9b6f1c74085a7ddf7381f7461d540a1b Mon Sep 17 00:00:00 2001 From: Luca Date: Thu, 30 Apr 2026 10:31:10 +0200 Subject: [PATCH 3/3] feat: update pytaskr --- examples/abcTasks/python/abcTasks.py | 6 +++--- examples/conditionVariable/python/conditionVariableWait.py | 4 ++-- .../python/conditionVariableWaitCondition.py | 4 ++-- .../conditionVariable/python/conditionVariableWaitFor.py | 4 ++-- .../python/conditionVariableWaitForCondition.py | 4 ++-- examples/energySaver/python/energySaver.py | 4 ++-- examples/fibonacci/meson.build | 2 +- examples/fibonacci/python/fibonacci.py | 6 +++--- examples/fibonacci/python/fibonacci_mutex.py | 6 +++--- examples/manyParallel/python/manyParallel.py | 2 +- examples/matmul/meson.build | 2 +- examples/matmul/python/matmul.py | 4 ++-- examples/multiJob/python/job1.py | 6 +++--- examples/multiJob/python/job2.py | 6 +++--- examples/mutex/meson.build | 2 +- examples/mutex/python/mutex.py | 2 +- examples/pendingOperation/python/pendingOperation.py | 2 +- examples/resourceList/python/main.py | 2 +- examples/simple/python/simple.py | 2 +- examples/sleepsort/python/main.py | 2 +- examples/suspend/python/suspend.py | 2 +- examples/workerSpecific/python/workerSpecific.py | 2 +- include/pytaskr/pyruntime.hpp | 6 +++++- include/pytaskr/pytaskr.cpp | 5 ++++- 24 files changed, 47 insertions(+), 40 deletions(-) diff --git a/examples/abcTasks/python/abcTasks.py b/examples/abcTasks/python/abcTasks.py index 854b660..28f6a78 100644 --- a/examples/abcTasks/python/abcTasks.py +++ b/examples/abcTasks/python/abcTasks.py @@ -6,9 +6,9 @@ def abcTasks(runtime): # Create the taskr Tasks - taskAfc = taskr.Function(lambda task : print(f"Task A {task.getTaskId()}")) - taskBfc = taskr.Function(lambda task : print(f"Task B {task.getTaskId()}")) - taskCfc = taskr.Function(lambda task : print(f"Task C {task.getTaskId()}")) + taskAfc = taskr.Function(runtime, lambda task : print(f"Task A {task.getTaskId()}")) + taskBfc = taskr.Function(runtime, lambda task : print(f"Task B {task.getTaskId()}")) + taskCfc = taskr.Function(runtime, lambda task : print(f"Task C {task.getTaskId()}")) # Initializing taskr runtime.initialize() diff --git a/examples/conditionVariable/python/conditionVariableWait.py b/examples/conditionVariable/python/conditionVariableWait.py index 0ed4fd1..79e2069 100644 --- a/examples/conditionVariable/python/conditionVariableWait.py +++ b/examples/conditionVariable/python/conditionVariableWait.py @@ -40,7 +40,7 @@ def fc(task): print("Thread 1: I have been notified") # Creating task functions - waitFc = taskr.Function(fc) + waitFc = taskr.Function(runtime, fc) def fc(task): nonlocal value @@ -53,7 +53,7 @@ def fc(task): task.suspend() print("task.suspend()", flush=True) - notifyFc = taskr.Function(fc) + notifyFc = taskr.Function(runtime, fc) task1 = taskr.Task(0, waitFc) task2 = taskr.Task(1, notifyFc) diff --git a/examples/conditionVariable/python/conditionVariableWaitCondition.py b/examples/conditionVariable/python/conditionVariableWaitCondition.py index a2dccb4..cd01c9f 100644 --- a/examples/conditionVariable/python/conditionVariableWaitCondition.py +++ b/examples/conditionVariable/python/conditionVariableWaitCondition.py @@ -48,7 +48,7 @@ def fc(task): print("Thread 1: The condition (value == 2) is satisfied now") # Creating task functions - thread1Fc = taskr.Function(fc) + thread1Fc = taskr.Function(runtime, fc) def fc(task): nonlocal value @@ -69,7 +69,7 @@ def fc(task): print("Thread 2: Notifying anybody interested") cv.notifyOne(task) - thread2Fc = taskr.Function(fc) + thread2Fc = taskr.Function(runtime, fc) task1 = taskr.Task(0, thread1Fc) task2 = taskr.Task(1, thread2Fc) diff --git a/examples/conditionVariable/python/conditionVariableWaitFor.py b/examples/conditionVariable/python/conditionVariableWaitFor.py index e6ff425..f77d40f 100644 --- a/examples/conditionVariable/python/conditionVariableWaitFor.py +++ b/examples/conditionVariable/python/conditionVariableWaitFor.py @@ -71,7 +71,7 @@ def fc(task): print(f"Thread 1: I've exited by timeout (as expected in {elapsedTime}us >= {timeoutTimeUs}us)") # Creating task functions - waitFc = taskr.Function(fc) + waitFc = taskr.Function(runtime, fc) def fc(task): nonlocal value @@ -82,7 +82,7 @@ def fc(task): cv.notifyOne(task) task.suspend() - notifyFc = taskr.Function(fc) + notifyFc = taskr.Function(runtime, fc) task1 = taskr.Task(0, waitFc) task2 = taskr.Task(1, notifyFc) diff --git a/examples/conditionVariable/python/conditionVariableWaitForCondition.py b/examples/conditionVariable/python/conditionVariableWaitForCondition.py index 296904e..7eb4d1d 100644 --- a/examples/conditionVariable/python/conditionVariableWaitForCondition.py +++ b/examples/conditionVariable/python/conditionVariableWaitForCondition.py @@ -86,7 +86,7 @@ def fc(task): mutex.unlock(task) # Creating task functions - thread1Fc = taskr.Function(fc) + thread1Fc = taskr.Function(runtime, fc) def fc(task): nonlocal value @@ -115,7 +115,7 @@ def fc(task): task.suspend() - thread2Fc = taskr.Function(fc) + thread2Fc = taskr.Function(runtime, fc) task1 = taskr.Task(0, thread1Fc) task2 = taskr.Task(1, thread2Fc) diff --git a/examples/energySaver/python/energySaver.py b/examples/energySaver/python/energySaver.py index ef234fd..780ee4e 100644 --- a/examples/energySaver/python/energySaver.py +++ b/examples/energySaver/python/energySaver.py @@ -31,10 +31,10 @@ def waitFc(taskr, secondsDelay): def energySaver(runtime, workTaskCount, secondsDelay, iterations): # Creating task work function - workFunction = taskr.Function(lambda task : workFc(iterations)) + workFunction = taskr.Function(runtime, lambda task : workFc(iterations)) # Creating task wait function - waitFunction = taskr.Function(lambda task : waitFc(runtime, secondsDelay)) + waitFunction = taskr.Function(runtime, lambda task : waitFc(runtime, secondsDelay)) # Creating a single wait task that suspends all workers except for one waitTask1 = taskr.Task(0, waitFunction) diff --git a/examples/fibonacci/meson.build b/examples/fibonacci/meson.build index 5c40d13..1f2b080 100644 --- a/examples/fibonacci/meson.build +++ b/examples/fibonacci/meson.build @@ -19,7 +19,7 @@ endif if get_option('buildPyTaskR') and get_option('buildTests') test('pyTaskR', py, - args : [ 'python/main.py'], + args : [ meson.current_source_dir() / 'python/main.py'], is_parallel : false, env: ['PYTHONPATH=' + meson.project_build_root() + '/include/pytaskr/'], suite: testSuite, diff --git a/examples/fibonacci/python/fibonacci.py b/examples/fibonacci/python/fibonacci.py index b14e9a6..da0a7a7 100644 --- a/examples/fibonacci/python/fibonacci.py +++ b/examples/fibonacci/python/fibonacci.py @@ -42,8 +42,8 @@ def Fc2(task): nonlocal result2 result2 = fibonacci(task, x - 2) - fibFc1 = taskr.Function(Fc1) - fibFc2 = taskr.Function(Fc2) + fibFc1 = taskr.Function(_runtime, fc1) + fibFc2 = taskr.Function(_runtime, fc2) # Creating two new tasks subTask1 = taskr.Task(_taskCounter.value, fibFc1) @@ -78,7 +78,7 @@ def Fc(task): nonlocal result result = fibonacci(task, initialValue) - initialFc = taskr.Function(Fc) + initialFc = taskr.Function(_runtime, fc) # Now creating tasks and their dependency graph initialTask = taskr.Task(_taskCounter.value, initialFc) diff --git a/examples/fibonacci/python/fibonacci_mutex.py b/examples/fibonacci/python/fibonacci_mutex.py index 3bd0c5a..2ecb64a 100644 --- a/examples/fibonacci/python/fibonacci_mutex.py +++ b/examples/fibonacci/python/fibonacci_mutex.py @@ -43,8 +43,8 @@ def Fc2(task): nonlocal result2 result2 = fibonacci(task, x - 2) - fibFc1 = taskr.Function(Fc1) - fibFc2 = taskr.Function(Fc2) + fibFc1 = taskr.Function(_runtime, Fc1) + fibFc2 = taskr.Function(_runtime, Fc2) # Creating two new tasks subTask1 = taskr.Task(_taskCounter, fibFc1) @@ -83,7 +83,7 @@ def Fc(task): nonlocal result result = fibonacci(task, initialValue) - initialFc = taskr.Function(Fc) + initialFc = taskr.Function(runtime, Fc) # Now creating tasks and their dependency graph initialTask = taskr.Task(_taskCounter, initialFc) diff --git a/examples/manyParallel/python/manyParallel.py b/examples/manyParallel/python/manyParallel.py index 2e50518..75d2cf3 100644 --- a/examples/manyParallel/python/manyParallel.py +++ b/examples/manyParallel/python/manyParallel.py @@ -19,7 +19,7 @@ def manyParallel(runtime, branchCount, taskCount): # Creating the execution units (functions that the tasks will run) - taskfc = taskr.Function(lambda task : None) + taskfc = taskr.Function(runtime, lambda task : None) # Initializing taskr runtime.initialize() diff --git a/examples/matmul/meson.build b/examples/matmul/meson.build index 94ec388..7841b24 100644 --- a/examples/matmul/meson.build +++ b/examples/matmul/meson.build @@ -9,7 +9,7 @@ if get_option('buildPyTaskR') and get_option('buildTests') test('pyTaskR', py, - args : [ 'python/main.py' ], + args : [ meson.current_source_dir() / 'python/main.py' ], is_parallel : false, env: ['PYTHONPATH=' + meson.project_build_root() + '/include/pytaskr/:' + meson.project_build_root() + '/examples/matmul/'], suite: testSuite, diff --git a/examples/matmul/python/matmul.py b/examples/matmul/python/matmul.py index 07848ca..3b6e4f6 100644 --- a/examples/matmul/python/matmul.py +++ b/examples/matmul/python/matmul.py @@ -25,7 +25,7 @@ def matmul_cpp_Driver(runtime): # Initializing taskr runtime.initialize() - taskfc = taskr.Function(cpp_matmul.cpp_matmul) + taskfc = taskr.Function(runtime, cpp_matmul.cpp_matmul) # Adding to tasks to taskr for i in range(NTASKS): @@ -65,7 +65,7 @@ def matmul_numpy(task): A = B @ C - taskfc = taskr.Function(matmul_numpy) + taskfc = taskr.Function(runtime, matmul_numpy) # Adding to tasks to taskr for i in range(NTASKS): diff --git a/examples/multiJob/python/job1.py b/examples/multiJob/python/job1.py index 88e836f..03a0561 100644 --- a/examples/multiJob/python/job1.py +++ b/examples/multiJob/python/job1.py @@ -23,9 +23,9 @@ def job1(runtime): tasks = [None] * (3 * ITERATIONS) # Creating the execution units (functions that the tasks will run) - taskAfc = taskr.Function(lambda task : print(f"Job 1 - Task A {task.getTaskId()}")) - taskBfc = taskr.Function(lambda task : print(f"Job 1 - Task B {task.getTaskId()}")) - taskCfc = taskr.Function(lambda task : print(f"Job 1 - Task C {task.getTaskId()}")) + taskAfc = taskr.Function(runtime, lambda task : print(f"Job 1 - Task A {task.getTaskId()}")) + taskBfc = taskr.Function(runtime, lambda task : print(f"Job 1 - Task B {task.getTaskId()}")) + taskCfc = taskr.Function(runtime, lambda task : print(f"Job 1 - Task C {task.getTaskId()}")) # Now creating tasks for i in range(ITERATIONS): diff --git a/examples/multiJob/python/job2.py b/examples/multiJob/python/job2.py index 7fef2a3..60a1167 100644 --- a/examples/multiJob/python/job2.py +++ b/examples/multiJob/python/job2.py @@ -23,9 +23,9 @@ def job2(runtime): tasks = [None] * (3 * ITERATIONS) # Creating the execution units (functions that the tasks will run) - taskAfc = taskr.Function(lambda task : print(f"Job 1 - Task A {task.getTaskId()}")) - taskBfc = taskr.Function(lambda task : print(f"Job 1 - Task B {task.getTaskId()}")) - taskCfc = taskr.Function(lambda task : print(f"Job 1 - Task C {task.getTaskId()}")) + taskAfc = taskr.Function(runtime, lambda task : print(f"Job 1 - Task A {task.getTaskId()}")) + taskBfc = taskr.Function(runtime, lambda task : print(f"Job 1 - Task B {task.getTaskId()}")) + taskCfc = taskr.Function(runtime, lambda task : print(f"Job 1 - Task C {task.getTaskId()}")) # Now creating tasks for i in range(ITERATIONS): diff --git a/examples/mutex/meson.build b/examples/mutex/meson.build index e2f582b..0b92557 100644 --- a/examples/mutex/meson.build +++ b/examples/mutex/meson.build @@ -19,7 +19,7 @@ endif if get_option('buildPyTaskR') and get_option('buildTests') test('pyTaskR', py, - args : [ 'python/main.py' ], + args : [ meson.current_source_dir() / 'python/main.py' ], is_parallel : false, env: ['PYTHONPATH=' + meson.project_build_root() + '/include/pytaskr/'], suite: testSuite, diff --git a/examples/mutex/python/mutex.py b/examples/mutex/python/mutex.py index 999a092..17da504 100644 --- a/examples/mutex/python/mutex.py +++ b/examples/mutex/python/mutex.py @@ -36,7 +36,7 @@ def fc(task): m.unlock(task) # Create the taskr Tasks - taskfc = taskr.Function(fc) + taskfc = taskr.Function(runtime, fc) # Creating the execution units (functions that the tasks will run) for i in range(_CONCURRENT_TASKS): diff --git a/examples/pendingOperation/python/pendingOperation.py b/examples/pendingOperation/python/pendingOperation.py index 1f0d066..8ff5419 100644 --- a/examples/pendingOperation/python/pendingOperation.py +++ b/examples/pendingOperation/python/pendingOperation.py @@ -57,7 +57,7 @@ def pendingOperation(runtime): fc = lambda task : heavyTask(task) # Create the taskr Tasks - taskfc = taskr.Function(fc) + taskfc = taskr.Function(runtime, fc) # Now creating heavy many tasks task for i in range(100): diff --git a/examples/resourceList/python/main.py b/examples/resourceList/python/main.py index a73a5a0..ca9cc3f 100644 --- a/examples/resourceList/python/main.py +++ b/examples/resourceList/python/main.py @@ -41,7 +41,7 @@ def main(): t = taskr.create("threading", coreSubset) # Creating task function - taskFunction = taskr.Function(lambda task : workTask.work(iterations)) + taskFunction = taskr.Function(t, lambda task : workTask.work(iterations)) # Adding multiple compute tasks print(f"Running {workTaskCount} work tasks with {len(coreSubset)} processing units...") diff --git a/examples/simple/python/simple.py b/examples/simple/python/simple.py index 1f36937..a69fe8d 100644 --- a/examples/simple/python/simple.py +++ b/examples/simple/python/simple.py @@ -23,7 +23,7 @@ def simple(runtime): # Create tasks fc = lambda task : print(f"Hello, I am task {task.getTaskId()}") - taskfc = taskr.Function(fc) + taskfc = taskr.Function(runtime, fc) # Adding to tasks to taskr for i in range(NTASKS): diff --git a/examples/sleepsort/python/main.py b/examples/sleepsort/python/main.py index d526e65..331ea9a 100644 --- a/examples/sleepsort/python/main.py +++ b/examples/sleepsort/python/main.py @@ -43,7 +43,7 @@ def fc(task): sorted_array.append(value) - taskfc = taskr.Function(fc) + taskfc = taskr.Function(t, fc) for i in range(n): t.addTask(taskr.Task(i, taskfc)) diff --git a/examples/suspend/python/suspend.py b/examples/suspend/python/suspend.py index d8c0b70..f3a230f 100644 --- a/examples/suspend/python/suspend.py +++ b/examples/suspend/python/suspend.py @@ -28,7 +28,7 @@ def fc(task): for _ in range(NSUSPENDS): task.suspend() # Creating the execution units (functions that the tasks will run) - taskfc = taskr.Function(fc) + taskfc = taskr.Function(runtime, fc) # Initializing taskr runtime.initialize() diff --git a/examples/workerSpecific/python/workerSpecific.py b/examples/workerSpecific/python/workerSpecific.py index aead39a..e7298e0 100644 --- a/examples/workerSpecific/python/workerSpecific.py +++ b/examples/workerSpecific/python/workerSpecific.py @@ -58,7 +58,7 @@ def workerSpecific(runtime, workerCount): runtime.setTaskCallbackHandler(taskr.TaskCallback.onTaskSuspend, lambda task : runtime.resumeTask(task)) # Creating the execution units (functions that the tasks will run) - workTaskfc = taskr.Function(lambda task : workFc(task)) + workTaskfc = taskr.Function(runtime, lambda task : workFc(task)) # Initializing taskr runtime.initialize() diff --git a/include/pytaskr/pyruntime.hpp b/include/pytaskr/pyruntime.hpp index e1d81b8..9962b21 100644 --- a/include/pytaskr/pyruntime.hpp +++ b/include/pytaskr/pyruntime.hpp @@ -259,7 +259,11 @@ class PyRuntime /** * */ - __INLINE__ void addService(taskr::service_t *service) { _runtime->addService(service); } + __INLINE__ void addService(taskr::Service *service) { _runtime->addService(service); } + + __INLINE__ HiCR::ComputeManager *getExecutionStateComputeManager() { return _executionStateComputeManager.get(); } + + __INLINE__ HiCR::ComputeManager *getProcessingUnitComputeManager() { return _processingUnitComputeManager.get(); } private: diff --git a/include/pytaskr/pytaskr.cpp b/include/pytaskr/pytaskr.cpp index 462fe6c..98be6d4 100644 --- a/include/pytaskr/pytaskr.cpp +++ b/include/pytaskr/pytaskr.cpp @@ -51,7 +51,10 @@ PYBIND11_MODULE(taskr, m) .def("addService", &PyRuntime::addService); // TaskR's Function class - py::class_(m, "Function").def(py::init(), py::arg("fc")); + py::class_(m, "Function") + .def(py::init([](PyRuntime &runtime, function_t fc) { return std::make_unique(runtime.getExecutionStateComputeManager(), std::move(fc)); }), + py::arg("runtime"), + py::arg("fc")); // TaskR's Task class py::class_(m, "Task")