Skip to content
Merged
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
6 changes: 3 additions & 3 deletions examples/abcTasks/python/abcTasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 3 additions & 1 deletion examples/cholesky/source/nosv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <hwloc.h>
#include <chrono>
#include <pthread.h>
#include <hicr/backends/pthreads/core.hpp>
#include <hicr/backends/pthreads/communicationManager.hpp>
#include <hicr/backends/hwloc/memoryManager.hpp>
#include <hicr/backends/hwloc/topologyManager.hpp>
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions examples/conditionVariable/python/conditionVariableWait.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions examples/conditionVariable/python/conditionVariableWaitFor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions examples/energySaver/cpp/nosv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions examples/energySaver/python/energySaver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion examples/fibonacci/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions examples/fibonacci/python/fibonacci.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions examples/fibonacci/python/fibonacci_mutex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
30 changes: 26 additions & 4 deletions examples/jacobi3d/source/grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,14 @@ bool Grid::initialize()

// Creating producer and consumer channels
t.X0SendChannel = std::make_unique<HiCR::channel::fixedSize::SPSC::Producer>(*_communicationManager,
*_communicationManager,
sendGlobalTokenBufferSlot,
sendProducerCoordinationBuffer->getSourceLocalMemorySlot(),
sendConsumerCoordinationBuffer,
sizeof(double) * bufferSizeX,
CHANNEL_DEPTH);
t.X0RecvChannel = std::make_unique<HiCR::channel::fixedSize::SPSC::Consumer>(*_communicationManager,
*_communicationManager,
recvGlobalTokenBufferSlot,
recvConsumerCoordinationBuffer->getSourceLocalMemorySlot(),
recvProducerCoordinationBuffer,
Expand All @@ -423,12 +425,14 @@ bool Grid::initialize()

// Creating producer and consumer channels
t.X1SendChannel = std::make_unique<HiCR::channel::fixedSize::SPSC::Producer>(*_communicationManager,
*_communicationManager,
sendGlobalTokenBufferSlot,
sendProducerCoordinationBuffer->getSourceLocalMemorySlot(),
sendConsumerCoordinationBuffer,
sizeof(double) * bufferSizeX,
CHANNEL_DEPTH);
t.X1RecvChannel = std::make_unique<HiCR::channel::fixedSize::SPSC::Consumer>(*_communicationManager,
*_communicationManager,
recvGlobalTokenBufferSlot,
recvConsumerCoordinationBuffer->getSourceLocalMemorySlot(),
recvProducerCoordinationBuffer,
Expand All @@ -453,12 +457,14 @@ bool Grid::initialize()

// Creating producer and consumer channels
t.Y0SendChannel = std::make_unique<HiCR::channel::fixedSize::SPSC::Producer>(*_communicationManager,
*_communicationManager,
sendGlobalTokenBufferSlot,
sendProducerCoordinationBuffer->getSourceLocalMemorySlot(),
sendConsumerCoordinationBuffer,
sizeof(double) * bufferSizeY,
CHANNEL_DEPTH);
t.Y0RecvChannel = std::make_unique<HiCR::channel::fixedSize::SPSC::Consumer>(*_communicationManager,
*_communicationManager,
recvGlobalTokenBufferSlot,
recvConsumerCoordinationBuffer->getSourceLocalMemorySlot(),
recvProducerCoordinationBuffer,
Expand All @@ -483,12 +489,14 @@ bool Grid::initialize()

// Creating producer and consumer channels
t.Y1SendChannel = std::make_unique<HiCR::channel::fixedSize::SPSC::Producer>(*_communicationManager,
*_communicationManager,
sendGlobalTokenBufferSlot,
sendProducerCoordinationBuffer->getSourceLocalMemorySlot(),
sendConsumerCoordinationBuffer,
sizeof(double) * bufferSizeY,
CHANNEL_DEPTH);
t.Y1RecvChannel = std::make_unique<HiCR::channel::fixedSize::SPSC::Consumer>(*_communicationManager,
*_communicationManager,
recvGlobalTokenBufferSlot,
recvConsumerCoordinationBuffer->getSourceLocalMemorySlot(),
recvProducerCoordinationBuffer,
Expand All @@ -513,12 +521,14 @@ bool Grid::initialize()

// Creating producer and consumer channels
t.Z0SendChannel = std::make_unique<HiCR::channel::fixedSize::SPSC::Producer>(*_communicationManager,
*_communicationManager,
sendGlobalTokenBufferSlot,
sendProducerCoordinationBuffer->getSourceLocalMemorySlot(),
sendConsumerCoordinationBuffer,
sizeof(double) * bufferSizeZ,
CHANNEL_DEPTH);
t.Z0RecvChannel = std::make_unique<HiCR::channel::fixedSize::SPSC::Consumer>(*_communicationManager,
*_communicationManager,
recvGlobalTokenBufferSlot,
recvConsumerCoordinationBuffer->getSourceLocalMemorySlot(),
recvProducerCoordinationBuffer,
Expand All @@ -543,12 +553,14 @@ bool Grid::initialize()

// Creating producer and consumer channels
t.Z1SendChannel = std::make_unique<HiCR::channel::fixedSize::SPSC::Producer>(*_communicationManager,
*_communicationManager,
sendGlobalTokenBufferSlot,
sendProducerCoordinationBuffer->getSourceLocalMemorySlot(),
sendConsumerCoordinationBuffer,
sizeof(double) * bufferSizeZ,
CHANNEL_DEPTH);
t.Z1RecvChannel = std::make_unique<HiCR::channel::fixedSize::SPSC::Consumer>(*_communicationManager,
*_communicationManager,
recvGlobalTokenBufferSlot,
recvConsumerCoordinationBuffer->getSourceLocalMemorySlot(),
recvProducerCoordinationBuffer,
Expand Down Expand Up @@ -582,11 +594,21 @@ bool Grid::initialize()

// Creating channel
if (processId == 0)
residualConsumerChannel = std::make_unique<HiCR::channel::fixedSize::MPSC::locking::Consumer>(
*_communicationManager, residualGlobalTokenBufferSlot, residualCoordinationBufferSlot, residualGlobalCoordinationBufferSlot, sizeof(double), processCount);
residualConsumerChannel = std::make_unique<HiCR::channel::fixedSize::MPSC::locking::Consumer>(*_communicationManager,
*_communicationManager,
residualGlobalTokenBufferSlot,
residualCoordinationBufferSlot,
residualGlobalCoordinationBufferSlot,
sizeof(double),
processCount);
if (processId != 0)
residualProducerChannel = std::make_unique<HiCR::channel::fixedSize::MPSC::locking::Producer>(
*_communicationManager, residualGlobalTokenBufferSlot, residualCoordinationBufferSlot, residualGlobalCoordinationBufferSlot, sizeof(double), processCount);
residualProducerChannel = std::make_unique<HiCR::channel::fixedSize::MPSC::locking::Producer>(*_communicationManager,
*_communicationManager,
residualGlobalTokenBufferSlot,
residualCoordinationBufferSlot,
residualGlobalCoordinationBufferSlot,
sizeof(double),
processCount);
}

free(globalRankX);
Expand Down
Loading
Loading