Skip to content
Closed
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
3 changes: 2 additions & 1 deletion .github/workflows/master-test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ jobs:

- name: Build Pybind11
run: |
/usr/bin/python3 -m pip install --upgrade pip pytest
sudo apt-get update
sudo apt-get install -y python3-pytest

cd extern/pybind11
mkdir -p build
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/pr-development-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ jobs:

- name: Build Pybind11
run: |
/usr/bin/python3 -m pip install --upgrade pip pytest
sudo apt-get update
sudo apt-get install -y python3-pytest

cd extern/pybind11
mkdir -p build
Expand Down
14 changes: 7 additions & 7 deletions examples/abcTasks/cpp/abcTasks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ void abcTasks(taskr::Runtime &taskr)
taskr.setTaskCallbackHandler(HiCR::tasking::Task::callback_t::onTaskFinish, [&taskr](taskr::Task *task) { delete task; });

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

// Initializing taskr
taskr.initialize();
Expand All @@ -38,17 +38,17 @@ void abcTasks(taskr::Runtime &taskr)
for (size_t r = 0; r < REPETITIONS; r++)
{
// Calculating the base task id for this repetition
auto repetitionLabel = r * ITERATIONS * 3;
auto repetitionTaskId = r * ITERATIONS * 3;

// Our connection with the previous iteration is the last task C, null in the first iteration
taskr::Task *prevTaskC = nullptr;

// Each run consists of several iterations of ABC
for (size_t i = 0; i < ITERATIONS; i++)
{
auto taskA = new taskr::Task(repetitionLabel + i * 3 + 0, &taskAfc);
auto taskB = new taskr::Task(repetitionLabel + i * 3 + 1, &taskBfc);
auto taskC = new taskr::Task(repetitionLabel + i * 3 + 2, &taskCfc);
auto taskA = new taskr::Task(repetitionTaskId + i * 3 + 0, &taskAfc);
auto taskB = new taskr::Task(repetitionTaskId + i * 3 + 1, &taskBfc);
auto taskC = new taskr::Task(repetitionTaskId + i * 3 + 2, &taskCfc);

// Creating dependencies
if (i > 0) taskA->addDependency(prevTaskC);
Expand Down
14 changes: 7 additions & 7 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.getLabel()}"))
taskBfc = taskr.Function(lambda task : print(f"Task B {task.getLabel()}"))
taskCfc = taskr.Function(lambda task : print(f"Task C {task.getLabel()}"))
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()}"))

# Initializing taskr
runtime.initialize()
Expand All @@ -19,13 +19,13 @@ def abcTasks(runtime):
# Creating the execution units (functions that the tasks will run)
for r in range(REPETITIONS):
# Calculating the base task id for this repetition
repetitionLabel = r * ITERATIONS * 3
repetitionTaskId = r * ITERATIONS * 3

for i in range(ITERATIONS):

taskA = taskr.Task(repetitionLabel + i * 3 + 0, taskAfc)
taskB = taskr.Task(repetitionLabel + i * 3 + 1, taskBfc)
taskC = taskr.Task(repetitionLabel + i * 3 + 2, taskCfc)
taskA = taskr.Task(repetitionTaskId + i * 3 + 0, taskAfc)
taskB = taskr.Task(repetitionTaskId + i * 3 + 1, taskBfc)
taskC = taskr.Task(repetitionTaskId + i * 3 + 2, taskCfc)

# Creating dependencies
if i > 0: taskA.addDependency(prevTaskC)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ void conditionVariableWaitForCondition(taskr::Runtime &taskr)
{
printf("Thread 1: I wait (forever) for the value to turn 2\n");
mutex.lock(task);
bool wasNotified = cv.waitFor(task, mutex, [&]() { return value == 2; }, forever);
bool wasNotified = cv.waitFor(
task, mutex, [&]() { return value == 2; }, forever);
mutex.unlock(task);
if (wasNotified == false)
{
Expand All @@ -72,7 +73,8 @@ void conditionVariableWaitForCondition(taskr::Runtime &taskr)
printf("Thread 1: I wait (with timeout) for the value to turn 3 (won't happen)\n");
mutex.lock(task);
auto startTime = std::chrono::high_resolution_clock::now();
bool wasNotified = cv.waitFor(task, mutex, [&]() { return value == 3; }, timeoutTimeUs);
bool wasNotified = cv.waitFor(
task, mutex, [&]() { return value == 3; }, timeoutTimeUs);
auto currentTime = std::chrono::high_resolution_clock::now();
auto elapsedTime = (size_t)std::chrono::duration_cast<std::chrono::microseconds>(currentTime - startTime).count();
mutex.unlock(task);
Expand All @@ -99,7 +101,8 @@ void conditionVariableWaitForCondition(taskr::Runtime &taskr)
// Waiting for the other thread to set the first value
printf("Thread 2: First, I'll wait for the value to become 1\n");
mutex.lock(task);
bool wasNotified = cv.waitFor(task, mutex, [&]() { return value == 1; }, forever);
bool wasNotified = cv.waitFor(
task, mutex, [&]() { return value == 1; }, forever);
mutex.unlock(task);
if (wasNotified == false)
{
Expand Down
65 changes: 56 additions & 9 deletions examples/jacobi3d/meson.build
Original file line number Diff line number Diff line change
@@ -1,17 +1,64 @@
testSuite = [ 'examples', 'jacobi3d' ]

if 'boost' in get_option('executionStateType') and 'pthreads' in get_option('processingUnitType')
threading = executable('threading', [ 'source/pthreads.cpp', 'source/grid.cpp' ], dependencies: [ TaskRBuildDep ], cpp_args: [ TaskRDistributedCppFlag ] )
if distributedEngine == 'mpi'
TaskRDistributedCppFlag = '-D_TASKR_DISTRIBUTED_ENGINE_MPI'

if get_option('buildTests')
test('threading', threading, args : [ '-n', '64', '-i', '10' ], suite: testSuite, workdir: threading.path() + '.p' )
mpirunExecutable = HiCRProject.get_variable('mpirunExecutable')

if 'boost' in get_option('executionStateType') and 'pthreads' in get_option('processingUnitType')
threading = executable('threading', [ 'source/pthreads.cpp', 'source/grid.cpp' ], dependencies: [ TaskRBuildDep ], cpp_args: [ TaskRDistributedCppFlag ] )

if get_option('buildTests')
test('threading', mpirunExecutable, args : [ '-n', '2', '--oversubscribe', threading.full_path(), '-px', '1', '-py', '1', '-pz', '2', '-lx', '1', '-ly', '2', '-lz', '2', '-n', '64', '-i', '10'], suite: testSuite, workdir: threading.path() + '.p' )
endif
endif

# TODO: deadlocking (even for mpirun -n 1)
if 'nosv' in get_option('executionStateType') and 'nosv' in get_option('processingUnitType')
nosv = executable('nosv', [ 'source/nosv.cpp', 'source/grid.cpp' ], dependencies: [ TaskRBuildDep ], cpp_args: [ TaskRDistributedCppFlag ] )

if get_option('buildTests')
test('nosv', mpirunExecutable, args : [ '-n', '2', '--oversubscribe', nosv.full_path(), '-px', '1', '-py', '1', '-pz', '2', '-lx', '1', '-ly', '2', '-lz', '2', '-n', '64', '-i', '10'], is_parallel : false, suite: testSuite, workdir: nosv.path() + '.p' )
endif
endif

elif distributedEngine == 'lpf'
TaskRDistributedCppFlag = '-D_TASKR_DISTRIBUTED_ENGINE_LPF'

lpfrunExecutable = HiCRProject.get_variable('lpfrunExecutable')

if 'boost' in get_option('executionStateType') and 'pthreads' in get_option('processingUnitType')
threading = executable('threading', [ 'source/pthreads.cpp', 'source/grid.cpp' ], dependencies: [ TaskRBuildDep ], cpp_args: [ TaskRDistributedCppFlag ] )

if get_option('buildTests')
test('threading', lpfrunExecutable, args : [ '-n', '2', '-engine', 'zero', threading.full_path(), '-px', '1', '-py', '1', '-pz', '2', '-lx', '1', '-ly', '2', '-lz', '2', '-n', '64', '-i', '10'], suite: testSuite, workdir: threading.path() + '.p' )
endif
endif


if 'nosv' in get_option('executionStateType') and 'nosv' in get_option('processingUnitType')
nosv = executable('nosv', [ 'source/nosv.cpp', 'source/grid.cpp' ], dependencies: [ TaskRBuildDep ], cpp_args: [ TaskRDistributedCppFlag ] )

if get_option('buildTests')
test('nosv', lpfrunExecutable, args : [ '-n', '2', '-engine', 'zero', nosv.full_path(), '-px', '1', '-py', '1', '-pz', '2', '-lx', '1', '-ly', '2', '-lz', '2', '-n', '64', '-i', '10'], is_parallel : false, suite: testSuite, workdir: nosv.path() + '.p' )
endif
endif
elif distributedEngine == 'none' # Atm these are segfaulting (TODO fix!)
TaskRDistributedCppFlag = '-D_TASKR_DISTRIBUTED_ENGINE_NONE'

if 'boost' in get_option('executionStateType') and 'pthreads' in get_option('processingUnitType')
threading = executable('threading', [ 'source/pthreads.cpp', 'source/grid.cpp' ], dependencies: [ TaskRBuildDep ], cpp_args: [ TaskRDistributedCppFlag ] )

if get_option('buildTests')
test('threading', threading, args : [ '-n', '64', '-i', '10' ], suite: testSuite, workdir: threading.path() + '.p' )
endif
endif
endif

if 'nosv' in get_option('executionStateType') and 'nosv' in get_option('processingUnitType')
nosv = executable('nosv', [ 'source/nosv.cpp', 'source/grid.cpp' ], dependencies: [ TaskRBuildDep ], cpp_args: [ TaskRDistributedCppFlag ] )
if 'nosv' in get_option('executionStateType') and 'nosv' in get_option('processingUnitType')
nosv = executable('nosv', [ 'source/nosv.cpp', 'source/grid.cpp' ], dependencies: [ TaskRBuildDep ], cpp_args: [ TaskRDistributedCppFlag ] )

if get_option('buildTests')
test('nosv', nosv, args : [ '-n', '64', '-i', '10' ], is_parallel : false, suite: testSuite, workdir: nosv.path() + '.p' )
if get_option('buildTests')
test('nosv', nosv, args : [ '-n', '64', '-i', '10' ], is_parallel : false, suite: testSuite, workdir: nosv.path() + '.p' )
endif
endif
endif
21 changes: 9 additions & 12 deletions examples/jacobi3d/mpi/Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
CFLAGS = -O3 -g -Wfatal-errors
LIBS =
MPICXX = mpicxx
CXX = g++
CXXFLAGS = -O3 -g -Wfatal-errors
INCLUDES = -I/usr/local/include
LIBS = -L/usr/local/lib -lmpi

.SECONDARY:
.SECONDARY:
BINARIES = jacobi

.PHONY: all stage
.PHONY: all clean

all: $(BINARIES)

jacobi: jacobi.cpp grid.cpp
$(MPICXX) $(CFLAGS) $(LIBS) -o $@ $^
$(CXX) $(CXXFLAGS) $(INCLUDES) $^ -o $@ $(LIBS)

.PHONY: clean
clean:
$(RM) $(BINARIES) *.o




$(RM) $(BINARIES) *.o
6 changes: 4 additions & 2 deletions examples/jacobi3d/source/grid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

#pragma once

#include <vector>
#include <cstdint>
#include <string>
Expand All @@ -28,8 +30,8 @@
#include <hicr/frontends/channel/fixedSize/mpsc/locking/consumer.hpp>

#define CHANNEL_DEPTH 10
const int BLOCKZ = 96;
const int BLOCKY = 64;
constexpr int BLOCKZ = 96;
constexpr int BLOCKY = 64;

extern std::unordered_map<size_t, size_t> taskid_hashmap;

Expand Down
Loading
Loading