Skip to content

Commit 0e87b82

Browse files
authored
Merge pull request #51 from Algebraic-Programming/refactor/adaptToLatestChanges
refactor: adapt to latest API changes
2 parents cf98e54 + 60759cc commit 0e87b82

22 files changed

Lines changed: 42 additions & 103 deletions

File tree

examples/neuralNetwork/groundTruth/source/include/imageLoader.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
std::vector<uint32_t> loadLabels(const std::string &labelFilePath)
1515
{
1616
std::ifstream in(labelFilePath, std::ios::binary);
17-
if (!in) { HICR_THROW_RUNTIME("Cannot open label file: %s", labelFilePath); }
17+
if (!in) { HICR_THROW_RUNTIME("Cannot open label file: %s", labelFilePath.c_str()); }
1818

1919
// Determine the file size
2020
in.seekg(0, std::ios::end);
@@ -26,7 +26,7 @@ std::vector<uint32_t> loadLabels(const std::string &labelFilePath)
2626
std::vector<uint32_t> labels(numLabels);
2727

2828
// Read the entire file into the vector
29-
if (!in.read(reinterpret_cast<char *>(labels.data()), fileSize)) { HICR_THROW_RUNTIME("Error reading label file: %s", labelFilePath); }
29+
if (!in.read(reinterpret_cast<char *>(labels.data()), fileSize)) { HICR_THROW_RUNTIME("Error reading label file: %s", labelFilePath.c_str()); }
3030

3131
// Close file
3232
in.close();

examples/neuralNetwork/source/include/factory/executionUnit/opencl/executionUnitFactory.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#include <algorithm>
21
#include <vector>
32

43
#include "../../../tensor/opencl/tensor.hpp"

examples/neuralNetwork/source/include/factory/executionUnit/opencl/executionUnitFactory.hpp

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,8 @@ class ExecutionUnitFactory final : public factory::ExecutionUnitFactory
2727
* @param[in] computeManager a HiCR compute manager
2828
*
2929
*/
30-
ExecutionUnitFactory(HiCR::backend::opencl::ComputeManager &computeManager,
31-
HiCR::backend::opencl::CommunicationManager &communicationManager,
32-
HiCR::backend::opencl::MemoryManager &memoryManager,
33-
std::shared_ptr<HiCR::MemorySpace> &deviceMemorySpace,
34-
std::shared_ptr<HiCR::MemorySpace> &hostMemorySpace,
35-
cl::Program &program)
30+
ExecutionUnitFactory(HiCR::backend::opencl::ComputeManager &computeManager, cl::Program &program)
3631
: _computeManager(computeManager),
37-
_communicationManager(communicationManager),
38-
_memoryManager(memoryManager),
39-
_deviceMemorySpace(deviceMemorySpace),
40-
_hostMemorySpace(hostMemorySpace),
4132
_program(program)
4233
{}
4334

@@ -77,26 +68,6 @@ class ExecutionUnitFactory final : public factory::ExecutionUnitFactory
7768
*/
7869
HiCR::backend::opencl::ComputeManager &_computeManager;
7970

80-
/**
81-
* OpenCL communication manager
82-
*/
83-
HiCR::backend::opencl::CommunicationManager &_communicationManager;
84-
85-
/**
86-
* OpenCL memory manager
87-
*/
88-
HiCR::backend::opencl::MemoryManager &_memoryManager;
89-
90-
/**
91-
* OpenCL device memory space
92-
*/
93-
std::shared_ptr<HiCR::MemorySpace> &_deviceMemorySpace;
94-
95-
/**
96-
* Host memory space
97-
*/
98-
std::shared_ptr<HiCR::MemorySpace> &_hostMemorySpace;
99-
10071
/**
10172
* OpenCL program
10273
*/

examples/neuralNetwork/source/include/imageLoader.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
std::vector<uint32_t> loadLabels(const std::string &labelFilePath)
1919
{
2020
std::ifstream in(labelFilePath, std::ios::binary);
21-
if (!in) { HICR_THROW_RUNTIME("Cannot open label file: %s", labelFilePath); }
21+
if (!in) { HICR_THROW_RUNTIME("Cannot open label file: %s", labelFilePath.c_str()); }
2222

2323
// Determine the file size
2424
in.seekg(0, std::ios::end);
@@ -30,7 +30,7 @@ std::vector<uint32_t> loadLabels(const std::string &labelFilePath)
3030
std::vector<uint32_t> labels(numLabels);
3131

3232
// Read the entire file into the vector
33-
if (!in.read(reinterpret_cast<char *>(labels.data()), fileSize)) { HICR_THROW_RUNTIME("Error reading label file: %s", labelFilePath); }
33+
if (!in.read(reinterpret_cast<char *>(labels.data()), fileSize)) { HICR_THROW_RUNTIME("Error reading label file: %s", labelFilePath.c_str()); }
3434

3535
// Close file
3636
in.close();

examples/neuralNetwork/source/opencl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ int main(int argc, char **argv)
102102
}
103103

104104
// Create execution unit factory
105-
auto executioUnitFactory =
106-
factory::opencl::ExecutionUnitFactory(openclComputeManager, openclCommunicationManager, openclMemoryManager, deviceMemorySpace, hostMemorySpace, program);
105+
auto executioUnitFactory = factory::opencl::ExecutionUnitFactory(openclComputeManager, program);
107106

108107
////// Load ONNX model
109108
// Declare ONNX model

examples/pingPong/include/producer.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
#include <hicr/frontends/channel/fixedSize/spsc/producer.hpp>
77
#include <hicr/frontends/channel/fixedSize/spsc/consumer.hpp>
88

9-
#include <iostream>
10-
119
void producerFc(HiCR::MemoryManager &memoryManager,
1210
HiCR::CommunicationManager &communicationManager,
1311
std::shared_ptr<HiCR::MemorySpace> bufferMemorySpace,
@@ -56,9 +54,9 @@ void producerFc(HiCR::MemoryManager &memoryManager,
5654
communicationManager, communicationManager, pongTokenBufferSlot, pongCoordinationBuffer, consumerPongCoordinationBuffer, tokenSize, channelCapacity);
5755

5856
// Allocating a send slot to put the values we want to communicate
59-
ELEMENT_TYPE sendBuffer[tokenSize] = {'a'};
60-
auto sendBufferPtr = sendBuffer;
61-
auto sendSlot = memoryManager.registerLocalMemorySlot(bufferMemorySpace, sendBufferPtr, tokenSize);
57+
auto sendBuffer = std::vector<ELEMENT_TYPE>(tokenSize, 'a');
58+
auto sendBufferPtr = sendBuffer;
59+
auto sendSlot = memoryManager.registerLocalMemorySlot(bufferMemorySpace, static_cast<void *>(sendBufferPtr.data()), tokenSize);
6260

6361
// Pushing values to the channel, one by one, suspending when/if the channel is full
6462
for (int i = 0; i < msgCount; i++)

examples/tasking/abcTasks/source/abcTasks.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
void abcTasks(Runtime &runtime, HiCR::ComputeManager *computeManager)
2525
{
2626
// Creating task functions
27-
auto taskAfc = [&runtime](void *arg) { printf("Task A %lu\n", ((Task *)arg)->getLabel()); };
28-
auto taskBfc = [&runtime](void *arg) { printf("Task B %lu\n", ((Task *)arg)->getLabel()); };
29-
auto taskCfc = [&runtime](void *arg) { printf("Task C %lu\n", ((Task *)arg)->getLabel()); };
27+
auto taskAfc = [](void *arg) { printf("Task A %lu\n", ((Task *)arg)->getLabel()); };
28+
auto taskBfc = [](void *arg) { printf("Task B %lu\n", ((Task *)arg)->getLabel()); };
29+
auto taskCfc = [](void *arg) { printf("Task C %lu\n", ((Task *)arg)->getLabel()); };
3030

3131
// Now creating tasks and their dependency graph
3232
for (size_t i = 0; i < ITERATIONS; i++)

examples/tasking/runtime.hpp

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,6 @@ class Runtime
105105
*/
106106
std::vector<std::unique_ptr<HiCR::ProcessingUnit>> _processingUnits;
107107

108-
/**
109-
* Determines the maximum amount of tasks (required by the lock-free queue)
110-
*/
111-
const size_t _maxTasks;
112-
113-
/**
114-
* Determines the maximum amount of workers (required by the lock-free queue)
115-
*/
116-
const size_t _maxWorkers;
117-
118108
/**
119109
* This function checks whether a given task is ready to go (i.e., all its dependencies have been satisfied)
120110
*
@@ -139,18 +129,13 @@ class Runtime
139129
/**
140130
* Constructor of the example tasking runtime.
141131
*/
142-
Runtime(HiCR::ComputeManager *executionStateComputeManager,
143-
HiCR::ComputeManager *processingUnitComputeManager,
144-
const size_t maxTasks = __TASKR_DEFAULT_MAX_TASKS,
145-
const size_t maxWorkers = __TASKR_DEFAULT_MAX_WORKERS)
132+
Runtime(HiCR::ComputeManager *executionStateComputeManager, HiCR::ComputeManager *processingUnitComputeManager, const size_t maxTasks = __TASKR_DEFAULT_MAX_TASKS)
146133
: _executionStateComputeManager(executionStateComputeManager),
147-
_processingUnitComputeManager(processingUnitComputeManager),
148-
_maxTasks(maxTasks),
149-
_maxWorkers(maxWorkers)
134+
_processingUnitComputeManager(processingUnitComputeManager)
150135
{
151136
_callbackMap = new HiCR::tasking::Task::taskCallbackMap_t();
152137
_waitingTaskQueue = new HiCR::concurrent::Queue<HiCR::tasking::Task>(maxTasks);
153-
_suspendedWorkerQueue = new HiCR::concurrent::Queue<HiCR::tasking::Worker>(maxWorkers);
138+
_suspendedWorkerQueue = new HiCR::concurrent::Queue<HiCR::tasking::Worker>(__TASKR_DEFAULT_MAX_WORKERS);
154139
}
155140

156141
// Destructor (frees previous allocations)

include/hicr/backends/acl/computeManager.hpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
#include <acl/acl.h>
3232
#include <memory>
33-
#include <unordered_map>
3433
#include <hicr/backends/acl/executionUnit.hpp>
3534
#include <hicr/backends/acl/processingUnit.hpp>
3635
#include <hicr/backends/acl/kernel.hpp>
@@ -56,6 +55,11 @@ class ComputeManager final : public HiCR::ComputeManager
5655

5756
~ComputeManager() override = default;
5857

58+
/**
59+
* Avoid shadowing of base class implementation
60+
*/
61+
using HiCR::ComputeManager::createExecutionUnit;
62+
5963
/**
6064
* Creates an execution unit given a stream/vector of \p kernelOperations to be executed on the device
6165
*
@@ -166,11 +170,11 @@ class ComputeManager final : public HiCR::ComputeManager
166170
auto p = dynamic_cast<acl::ProcessingUnit *>(processingUnit.get());
167171

168172
// If the processing unit is not recognized, throw error. We can use the processing unit's type (string) now.
169-
if (p == nullptr) HICR_THROW_LOGIC("This compute manager cannot handle processing units of type '%s'", processingUnit->getType());
173+
if (p == nullptr) HICR_THROW_LOGIC("This compute manager cannot handle processing units of type '%s'", processingUnit->getType().c_str());
170174

171175
// Returning converted pointer
172176
return p;
173177
}
174178
};
175179

176-
} // namespace HiCR::backend::acl
180+
} // namespace HiCR::backend::acl

include/hicr/backends/acl/executionState.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class ExecutionState final : public HiCR::ExecutionState
5252
auto e = dynamic_pointer_cast<acl::ExecutionUnit>(executionUnit);
5353

5454
// Checking whether the execution unit passed is compatible with this backend
55-
if (e == NULL) HICR_THROW_LOGIC("The execution unit of type '%s' is not supported by this backend\n", executionUnit->getType());
55+
if (e == NULL) HICR_THROW_LOGIC("The execution unit of type '%s' is not supported by this backend\n", executionUnit->getType().c_str());
5656

5757
_executionUnit = e;
5858
}
@@ -111,7 +111,7 @@ class ExecutionState final : public HiCR::ExecutionState
111111
if (err != ACL_SUCCESS) HICR_THROW_RUNTIME("can not set sync bit to 1. Error %d", err);
112112
}
113113

114-
__INLINE__ void suspendImpl() { HICR_THROW_RUNTIME("Suspend functionality not supported by acl backend"); }
114+
__INLINE__ void suspendImpl() override { HICR_THROW_RUNTIME("Suspend functionality not supported by acl backend"); }
115115

116116
/**
117117
* Internal implementation of checkFinalization routine. It periodically query the ACL event on the stream to check for completion and

0 commit comments

Comments
 (0)