Skip to content

Commit fc40456

Browse files
Allowing specifying a compute manager when creating a function
1 parent ff6ed60 commit fc40456

File tree

24 files changed

+100
-66
lines changed

24 files changed

+100
-66
lines changed

docs/Doxyfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,7 @@ RECURSIVE = YES
10491049

10501050
EXCLUDE = ../include/hicr/common/atomic_queue \
10511051
../include/taskr/extern \
1052+
../include/pytaskr \
10521053
../include/hicr/common/parallel_hashmap \
10531054
../include/hicr/common/atomic_queue
10541055

examples/abcTasks/cpp/abcTasks.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ void abcTasks(taskr::Runtime &taskr)
2727
taskr.setTaskCallbackHandler(HiCR::tasking::Task::callback_t::onTaskFinish, [&taskr](taskr::Task *task) { delete task; });
2828

2929
// Creating the execution units (functions that the tasks will run)
30-
auto taskAfc = taskr::Function([](taskr::Task *task) { printf("Task A %ld\n", task->getTaskId()); });
31-
auto taskBfc = taskr::Function([](taskr::Task *task) { printf("Task B %ld\n", task->getTaskId()); });
32-
auto taskCfc = taskr::Function([](taskr::Task *task) { printf("Task C %ld\n", task->getTaskId()); });
30+
auto taskAfc = taskr::Function(taskr.getTaskComputeManager(), [](taskr::Task *task) { printf("Task A %ld\n", task->getTaskId()); });
31+
auto taskBfc = taskr::Function(taskr.getTaskComputeManager(), [](taskr::Task *task) { printf("Task B %ld\n", task->getTaskId()); });
32+
auto taskCfc = taskr::Function(taskr.getTaskComputeManager(), [](taskr::Task *task) { printf("Task C %ld\n", task->getTaskId()); });
3333

3434
// Initializing taskr
3535
taskr.initialize();

examples/cholesky/source/cholesky.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void cholesky(taskr::Runtime &taskr, std::vector<std::vector<std::shared_ptr<HiC
9292
{
9393
// Diagonal Block factorization
9494
pointer0 = (double *)blockMatrix[i][i]->getPointer();
95-
auto potrfExecutionUnit = new taskr::Function([=](taskr::Task *task) { potrf(pointer0, blockSize, blockSize); });
95+
auto potrfExecutionUnit = new taskr::Function(_taskr->getTaskComputeManager(), [=](taskr::Task *task) { potrf(pointer0, blockSize, blockSize); });
9696
auto potrfTask = new taskr::Task(_taskCounter->fetch_add(1), potrfExecutionUnit);
9797
addTaskDependency(potrfTask, i, i);
9898
updateDependencyGrid(potrfTask, i, i);
@@ -103,7 +103,7 @@ void cholesky(taskr::Runtime &taskr, std::vector<std::vector<std::shared_ptr<HiC
103103
{
104104
pointer0 = (double *)blockMatrix[i][i]->getPointer();
105105
pointer1 = (double *)blockMatrix[i][j]->getPointer();
106-
auto trsmExecutionUnit = new taskr::Function([=](taskr::Task *task) { trsm(pointer0, pointer1, blockSize, blockSize); });
106+
auto trsmExecutionUnit = new taskr::Function(_taskr->getTaskComputeManager(), [=](taskr::Task *task) { trsm(pointer0, pointer1, blockSize, blockSize); });
107107
auto trsmTask = new taskr::Task(_taskCounter->fetch_add(1), trsmExecutionUnit);
108108
addTaskDependency(trsmTask, i, i);
109109
addTaskDependency(trsmTask, i, j);
@@ -119,7 +119,7 @@ void cholesky(taskr::Runtime &taskr, std::vector<std::vector<std::shared_ptr<HiC
119119
pointer0 = (double *)blockMatrix[i][k]->getPointer();
120120
pointer1 = (double *)blockMatrix[i][j]->getPointer();
121121
pointer2 = (double *)blockMatrix[k][j]->getPointer();
122-
auto gemmExecutionUnit = new taskr::Function([=](taskr::Task *task) { gemm(pointer0, pointer1, pointer2, blockSize, blockSize); });
122+
auto gemmExecutionUnit = new taskr::Function(_taskr->getTaskComputeManager(), [=](taskr::Task *task) { gemm(pointer0, pointer1, pointer2, blockSize, blockSize); });
123123
auto gemmTask = new taskr::Task(_taskCounter->fetch_add(1), gemmExecutionUnit);
124124
addTaskDependency(gemmTask, i, j);
125125
addTaskDependency(gemmTask, i, k);
@@ -130,7 +130,7 @@ void cholesky(taskr::Runtime &taskr, std::vector<std::vector<std::shared_ptr<HiC
130130

131131
pointer0 = (double *)blockMatrix[i][j]->getPointer();
132132
pointer1 = (double *)blockMatrix[j][j]->getPointer();
133-
auto syrkExecutionUnit = new taskr::Function([=](taskr::Task *task) { syrk(pointer0, pointer1, blockSize, blockSize); });
133+
auto syrkExecutionUnit = new taskr::Function(_taskr->getTaskComputeManager(), [=](taskr::Task *task) { syrk(pointer0, pointer1, blockSize, blockSize); });
134134
auto syrkTask = new taskr::Task(_taskCounter->fetch_add(1), syrkExecutionUnit);
135135
addTaskDependency(syrkTask, i, j);
136136
addTaskDependency(syrkTask, j, j);

examples/cholesky/source/init.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void initMatrix(double *__restrict__ matrix, uint32_t dimension)
3838
// Get randomized numbers
3939
for (int i = 0; i < n; i++)
4040
{
41-
auto executionUnit = new taskr::Function([=](taskr::Task *task) { dlarnv_(&intONE, (int32_t *)&ISEED[0], &n, &matrix[i * n]); });
41+
auto executionUnit = new taskr::Function(_taskr->getTaskComputeManager(), [=](taskr::Task *task) { dlarnv_(&intONE, (int32_t *)&ISEED[0], &n, &matrix[i * n]); });
4242
auto task = new taskr::Task(_taskCounter->fetch_add(1), executionUnit);
4343
_taskr->addTask(task);
4444
}
@@ -48,7 +48,7 @@ void initMatrix(double *__restrict__ matrix, uint32_t dimension)
4848

4949
for (int i = 0; i < n; i++)
5050
{
51-
auto executionUnit = new taskr::Function([=](taskr::Task *task) {
51+
auto executionUnit = new taskr::Function(_taskr->getTaskComputeManager(), [=](taskr::Task *task) {
5252
for (int j = 0; j <= i; j++)
5353
{
5454
// Make the matrix simmetrical

examples/cholesky/source/verify.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ bool areMatrixEqual(double *__restrict__ expected, double *__restrict__ actual,
3434

3535
for (uint32_t i = 0; i < matrixSize; i++)
3636
{
37-
auto executionUnit = new taskr::Function([=, &equal](taskr::Task *task) {
37+
auto executionUnit = new taskr::Function(_taskr->getTaskComputeManager(), [=, &equal](taskr::Task *task) {
3838
for (uint32_t j = 0; j <= i; j++)
3939
{
4040
if (equal.load() == false) { break; }

examples/conditionVariable/cpp/conditionVariableWait.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void conditionVariableWait(taskr::Runtime &taskr)
3232
taskr::ConditionVariable cv;
3333

3434
// Creating task functions
35-
auto waitFc = taskr::Function([&](taskr::Task *task) {
35+
auto waitFc = taskr::Function(taskr.getTaskComputeManager(), [&](taskr::Task *task) {
3636
// Waiting for the other task's notification
3737
printf("Thread 1: I wait for a notification\n");
3838
mutex.lock(task);
@@ -42,7 +42,7 @@ void conditionVariableWait(taskr::Runtime &taskr)
4242
printf("Thread 1: I have been notified\n");
4343
});
4444

45-
auto notifyFc = taskr::Function([&](taskr::Task *task) {
45+
auto notifyFc = taskr::Function(taskr.getTaskComputeManager(), [&](taskr::Task *task) {
4646
// Notifying the other task
4747
printf("Thread 2: Notifying anybody interested\n");
4848
while (value != 1)

examples/conditionVariable/cpp/conditionVariableWaitCondition.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void conditionVariableWaitCondition(taskr::Runtime &taskr)
3232
taskr::ConditionVariable cv;
3333

3434
// Creating task functions
35-
auto thread1Fc = taskr::Function([&](taskr::Task *task) {
35+
auto thread1Fc = taskr::Function(taskr.getTaskComputeManager(), [&](taskr::Task *task) {
3636
// Using lock to update the value
3737
mutex.lock(task);
3838
printf("Thread 1: I go first and set value to 1\n");
@@ -55,7 +55,7 @@ void conditionVariableWaitCondition(taskr::Runtime &taskr)
5555
printf("Thread 1: The condition (value == 2) is satisfied now\n");
5656
});
5757

58-
auto thread2Fc = taskr::Function([&](taskr::Task *task) {
58+
auto thread2Fc = taskr::Function(taskr.getTaskComputeManager(), [&](taskr::Task *task) {
5959
// Waiting for the other thread to set the first value
6060
printf("Thread 2: First, I'll wait for the value to become 1\n");
6161
mutex.lock(task);

examples/conditionVariable/cpp/conditionVariableWaitFor.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void conditionVariableWaitFor(taskr::Runtime &taskr)
3838
constexpr size_t forever = 1000 * 1000 * 1000;
3939

4040
// Creating task functions
41-
auto waitFc = taskr::Function([&](taskr::Task *task) {
41+
auto waitFc = taskr::Function(taskr.getTaskComputeManager(), [&](taskr::Task *task) {
4242
// Waiting for the other task's notification
4343
printf("Thread 1: I wait for a notification (Waiting for an hour) \n");
4444
{
@@ -78,7 +78,7 @@ void conditionVariableWaitFor(taskr::Runtime &taskr)
7878
}
7979
});
8080

81-
auto notifyFc = taskr::Function([&](taskr::Task *task) {
81+
auto notifyFc = taskr::Function(taskr.getTaskComputeManager(), [&](taskr::Task *task) {
8282
// Notifying the other task
8383
printf("Thread 2: Notifying anybody interested (only once)\n");
8484
while (value != 1)

examples/conditionVariable/cpp/conditionVariableWaitForCondition.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void conditionVariableWaitForCondition(taskr::Runtime &taskr)
3838
constexpr size_t forever = 1000 * 1000 * 1000;
3939

4040
// Creating task functions
41-
auto thread1Fc = taskr::Function([&](taskr::Task *task) {
41+
auto thread1Fc = taskr::Function(taskr.getTaskComputeManager(), [&](taskr::Task *task) {
4242
// Using lock to update the value
4343
printf("Thread 1: I go first and set value to 1\n");
4444
mutex.lock(task);
@@ -95,7 +95,7 @@ void conditionVariableWaitForCondition(taskr::Runtime &taskr)
9595
mutex.unlock(task);
9696
});
9797

98-
auto thread2Fc = taskr::Function([&](taskr::Task *task) {
98+
auto thread2Fc = taskr::Function(taskr.getTaskComputeManager(), [&](taskr::Task *task) {
9999
// Waiting for the other thread to set the first value
100100
printf("Thread 2: First, I'll wait for the value to become 1\n");
101101
mutex.lock(task);

examples/energySaver/cpp/pthreads.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ int main(int argc, char **argv)
8585
taskr.setTaskCallbackHandler(HiCR::tasking::Task::callback_t::onTaskFinish, [&taskr](taskr::Task *task) { delete task; });
8686

8787
// Creating task work function
88-
auto workFunction = taskr::Function([&iterations](taskr::Task *task) { workFc(iterations); });
88+
auto workFunction = taskr::Function(taskr.getTaskComputeManager(), [&iterations](taskr::Task *task) { workFc(iterations); });
8989

9090
// Creating task wait function
91-
auto waitFunction = taskr::Function([&taskr, &secondsDelay](taskr::Task *task) { waitFc(&taskr, secondsDelay); });
91+
auto waitFunction = taskr::Function(taskr.getTaskComputeManager(), [&taskr, &secondsDelay](taskr::Task *task) { waitFc(&taskr, secondsDelay); });
9292

9393
// Creating a single wait task that suspends all workers except for one
9494
auto waitTask1 = new taskr::Task(0, &waitFunction);

0 commit comments

Comments
 (0)