diff --git a/examples/neuralNetwork/groundTruth/source/include/imageLoader.hpp b/examples/neuralNetwork/groundTruth/source/include/imageLoader.hpp index 87a5ccaf..7de609bc 100644 --- a/examples/neuralNetwork/groundTruth/source/include/imageLoader.hpp +++ b/examples/neuralNetwork/groundTruth/source/include/imageLoader.hpp @@ -14,7 +14,7 @@ std::vector loadLabels(const std::string &labelFilePath) { std::ifstream in(labelFilePath, std::ios::binary); - if (!in) { HICR_THROW_RUNTIME("Cannot open label file: %s", labelFilePath); } + if (!in) { HICR_THROW_RUNTIME("Cannot open label file: %s", labelFilePath.c_str()); } // Determine the file size in.seekg(0, std::ios::end); @@ -26,7 +26,7 @@ std::vector loadLabels(const std::string &labelFilePath) std::vector labels(numLabels); // Read the entire file into the vector - if (!in.read(reinterpret_cast(labels.data()), fileSize)) { HICR_THROW_RUNTIME("Error reading label file: %s", labelFilePath); } + if (!in.read(reinterpret_cast(labels.data()), fileSize)) { HICR_THROW_RUNTIME("Error reading label file: %s", labelFilePath.c_str()); } // Close file in.close(); diff --git a/examples/neuralNetwork/source/include/factory/executionUnit/opencl/executionUnitFactory.cpp b/examples/neuralNetwork/source/include/factory/executionUnit/opencl/executionUnitFactory.cpp index 22d80d3f..a460d331 100644 --- a/examples/neuralNetwork/source/include/factory/executionUnit/opencl/executionUnitFactory.cpp +++ b/examples/neuralNetwork/source/include/factory/executionUnit/opencl/executionUnitFactory.cpp @@ -1,4 +1,3 @@ -#include #include #include "../../../tensor/opencl/tensor.hpp" diff --git a/examples/neuralNetwork/source/include/factory/executionUnit/opencl/executionUnitFactory.hpp b/examples/neuralNetwork/source/include/factory/executionUnit/opencl/executionUnitFactory.hpp index 7e243f28..e9b54b33 100644 --- a/examples/neuralNetwork/source/include/factory/executionUnit/opencl/executionUnitFactory.hpp +++ b/examples/neuralNetwork/source/include/factory/executionUnit/opencl/executionUnitFactory.hpp @@ -27,17 +27,8 @@ class ExecutionUnitFactory final : public factory::ExecutionUnitFactory * @param[in] computeManager a HiCR compute manager * */ - ExecutionUnitFactory(HiCR::backend::opencl::ComputeManager &computeManager, - HiCR::backend::opencl::CommunicationManager &communicationManager, - HiCR::backend::opencl::MemoryManager &memoryManager, - std::shared_ptr &deviceMemorySpace, - std::shared_ptr &hostMemorySpace, - cl::Program &program) + ExecutionUnitFactory(HiCR::backend::opencl::ComputeManager &computeManager, cl::Program &program) : _computeManager(computeManager), - _communicationManager(communicationManager), - _memoryManager(memoryManager), - _deviceMemorySpace(deviceMemorySpace), - _hostMemorySpace(hostMemorySpace), _program(program) {} @@ -77,26 +68,6 @@ class ExecutionUnitFactory final : public factory::ExecutionUnitFactory */ HiCR::backend::opencl::ComputeManager &_computeManager; - /** - * OpenCL communication manager - */ - HiCR::backend::opencl::CommunicationManager &_communicationManager; - - /** - * OpenCL memory manager - */ - HiCR::backend::opencl::MemoryManager &_memoryManager; - - /** - * OpenCL device memory space - */ - std::shared_ptr &_deviceMemorySpace; - - /** - * Host memory space - */ - std::shared_ptr &_hostMemorySpace; - /** * OpenCL program */ diff --git a/examples/neuralNetwork/source/include/imageLoader.hpp b/examples/neuralNetwork/source/include/imageLoader.hpp index 9c624ecb..f044ba17 100644 --- a/examples/neuralNetwork/source/include/imageLoader.hpp +++ b/examples/neuralNetwork/source/include/imageLoader.hpp @@ -18,7 +18,7 @@ std::vector loadLabels(const std::string &labelFilePath) { std::ifstream in(labelFilePath, std::ios::binary); - if (!in) { HICR_THROW_RUNTIME("Cannot open label file: %s", labelFilePath); } + if (!in) { HICR_THROW_RUNTIME("Cannot open label file: %s", labelFilePath.c_str()); } // Determine the file size in.seekg(0, std::ios::end); @@ -30,7 +30,7 @@ std::vector loadLabels(const std::string &labelFilePath) std::vector labels(numLabels); // Read the entire file into the vector - if (!in.read(reinterpret_cast(labels.data()), fileSize)) { HICR_THROW_RUNTIME("Error reading label file: %s", labelFilePath); } + if (!in.read(reinterpret_cast(labels.data()), fileSize)) { HICR_THROW_RUNTIME("Error reading label file: %s", labelFilePath.c_str()); } // Close file in.close(); diff --git a/examples/neuralNetwork/source/opencl.cpp b/examples/neuralNetwork/source/opencl.cpp index cdd30569..bbe7d671 100644 --- a/examples/neuralNetwork/source/opencl.cpp +++ b/examples/neuralNetwork/source/opencl.cpp @@ -102,8 +102,7 @@ int main(int argc, char **argv) } // Create execution unit factory - auto executioUnitFactory = - factory::opencl::ExecutionUnitFactory(openclComputeManager, openclCommunicationManager, openclMemoryManager, deviceMemorySpace, hostMemorySpace, program); + auto executioUnitFactory = factory::opencl::ExecutionUnitFactory(openclComputeManager, program); ////// Load ONNX model // Declare ONNX model diff --git a/examples/pingPong/include/producer.hpp b/examples/pingPong/include/producer.hpp index 4e93fc4c..29b8ce45 100644 --- a/examples/pingPong/include/producer.hpp +++ b/examples/pingPong/include/producer.hpp @@ -6,8 +6,6 @@ #include #include -#include - void producerFc(HiCR::MemoryManager &memoryManager, HiCR::CommunicationManager &communicationManager, std::shared_ptr bufferMemorySpace, @@ -56,9 +54,9 @@ void producerFc(HiCR::MemoryManager &memoryManager, communicationManager, communicationManager, pongTokenBufferSlot, pongCoordinationBuffer, consumerPongCoordinationBuffer, tokenSize, channelCapacity); // Allocating a send slot to put the values we want to communicate - ELEMENT_TYPE sendBuffer[tokenSize] = {'a'}; - auto sendBufferPtr = sendBuffer; - auto sendSlot = memoryManager.registerLocalMemorySlot(bufferMemorySpace, sendBufferPtr, tokenSize); + auto sendBuffer = std::vector(tokenSize, 'a'); + auto sendBufferPtr = sendBuffer; + auto sendSlot = memoryManager.registerLocalMemorySlot(bufferMemorySpace, static_cast(sendBufferPtr.data()), tokenSize); // Pushing values to the channel, one by one, suspending when/if the channel is full for (int i = 0; i < msgCount; i++) diff --git a/examples/tasking/abcTasks/source/abcTasks.hpp b/examples/tasking/abcTasks/source/abcTasks.hpp index 706f381f..176d1af9 100644 --- a/examples/tasking/abcTasks/source/abcTasks.hpp +++ b/examples/tasking/abcTasks/source/abcTasks.hpp @@ -24,9 +24,9 @@ void abcTasks(Runtime &runtime, HiCR::ComputeManager *computeManager) { // Creating task functions - auto taskAfc = [&runtime](void *arg) { printf("Task A %lu\n", ((Task *)arg)->getLabel()); }; - auto taskBfc = [&runtime](void *arg) { printf("Task B %lu\n", ((Task *)arg)->getLabel()); }; - auto taskCfc = [&runtime](void *arg) { printf("Task C %lu\n", ((Task *)arg)->getLabel()); }; + auto taskAfc = [](void *arg) { printf("Task A %lu\n", ((Task *)arg)->getLabel()); }; + auto taskBfc = [](void *arg) { printf("Task B %lu\n", ((Task *)arg)->getLabel()); }; + auto taskCfc = [](void *arg) { printf("Task C %lu\n", ((Task *)arg)->getLabel()); }; // Now creating tasks and their dependency graph for (size_t i = 0; i < ITERATIONS; i++) diff --git a/examples/tasking/runtime.hpp b/examples/tasking/runtime.hpp index 14aca038..cac3f118 100644 --- a/examples/tasking/runtime.hpp +++ b/examples/tasking/runtime.hpp @@ -105,16 +105,6 @@ class Runtime */ std::vector> _processingUnits; - /** - * Determines the maximum amount of tasks (required by the lock-free queue) - */ - const size_t _maxTasks; - - /** - * Determines the maximum amount of workers (required by the lock-free queue) - */ - const size_t _maxWorkers; - /** * This function checks whether a given task is ready to go (i.e., all its dependencies have been satisfied) * @@ -139,18 +129,13 @@ class Runtime /** * Constructor of the example tasking runtime. */ - Runtime(HiCR::ComputeManager *executionStateComputeManager, - HiCR::ComputeManager *processingUnitComputeManager, - const size_t maxTasks = __TASKR_DEFAULT_MAX_TASKS, - const size_t maxWorkers = __TASKR_DEFAULT_MAX_WORKERS) + Runtime(HiCR::ComputeManager *executionStateComputeManager, HiCR::ComputeManager *processingUnitComputeManager, const size_t maxTasks = __TASKR_DEFAULT_MAX_TASKS) : _executionStateComputeManager(executionStateComputeManager), - _processingUnitComputeManager(processingUnitComputeManager), - _maxTasks(maxTasks), - _maxWorkers(maxWorkers) + _processingUnitComputeManager(processingUnitComputeManager) { _callbackMap = new HiCR::tasking::Task::taskCallbackMap_t(); _waitingTaskQueue = new HiCR::concurrent::Queue(maxTasks); - _suspendedWorkerQueue = new HiCR::concurrent::Queue(maxWorkers); + _suspendedWorkerQueue = new HiCR::concurrent::Queue(__TASKR_DEFAULT_MAX_WORKERS); } // Destructor (frees previous allocations) diff --git a/include/hicr/backends/acl/computeManager.hpp b/include/hicr/backends/acl/computeManager.hpp index a9d2c0ae..ef76df0f 100644 --- a/include/hicr/backends/acl/computeManager.hpp +++ b/include/hicr/backends/acl/computeManager.hpp @@ -30,7 +30,6 @@ #include #include -#include #include #include #include @@ -56,6 +55,11 @@ class ComputeManager final : public HiCR::ComputeManager ~ComputeManager() override = default; + /** + * Avoid shadowing of base class implementation + */ + using HiCR::ComputeManager::createExecutionUnit; + /** * Creates an execution unit given a stream/vector of \p kernelOperations to be executed on the device * @@ -166,11 +170,11 @@ class ComputeManager final : public HiCR::ComputeManager auto p = dynamic_cast(processingUnit.get()); // If the processing unit is not recognized, throw error. We can use the processing unit's type (string) now. - if (p == nullptr) HICR_THROW_LOGIC("This compute manager cannot handle processing units of type '%s'", processingUnit->getType()); + if (p == nullptr) HICR_THROW_LOGIC("This compute manager cannot handle processing units of type '%s'", processingUnit->getType().c_str()); // Returning converted pointer return p; } }; -} // namespace HiCR::backend::acl \ No newline at end of file +} // namespace HiCR::backend::acl diff --git a/include/hicr/backends/acl/executionState.hpp b/include/hicr/backends/acl/executionState.hpp index d09a923c..6d2b6e0d 100644 --- a/include/hicr/backends/acl/executionState.hpp +++ b/include/hicr/backends/acl/executionState.hpp @@ -52,7 +52,7 @@ class ExecutionState final : public HiCR::ExecutionState auto e = dynamic_pointer_cast(executionUnit); // Checking whether the execution unit passed is compatible with this backend - if (e == NULL) HICR_THROW_LOGIC("The execution unit of type '%s' is not supported by this backend\n", executionUnit->getType()); + if (e == NULL) HICR_THROW_LOGIC("The execution unit of type '%s' is not supported by this backend\n", executionUnit->getType().c_str()); _executionUnit = e; } @@ -111,7 +111,7 @@ class ExecutionState final : public HiCR::ExecutionState if (err != ACL_SUCCESS) HICR_THROW_RUNTIME("can not set sync bit to 1. Error %d", err); } - __INLINE__ void suspendImpl() { HICR_THROW_RUNTIME("Suspend functionality not supported by acl backend"); } + __INLINE__ void suspendImpl() override { HICR_THROW_RUNTIME("Suspend functionality not supported by acl backend"); } /** * Internal implementation of checkFinalization routine. It periodically query the ACL event on the stream to check for completion and diff --git a/include/hicr/backends/acl/meson.build b/include/hicr/backends/acl/meson.build index e46c94da..b05172cb 100644 --- a/include/hicr/backends/acl/meson.build +++ b/include/hicr/backends/acl/meson.build @@ -12,7 +12,7 @@ if aclPath == '' else backendIncludes = include_directories([aclPath + '/include']) backendLinkArgs = [ - '-L' + aclPath + '/acllib/lib64/stub', + '-L' + aclPath / host_machine.cpu_family() + '-linux/lib64', '-lascendcl', ] endif @@ -22,4 +22,4 @@ HiCRBackendDependencies += declare_dependency( compile_args: backendCppArgs, link_args: backendLinkArgs, include_directories: backendIncludes, -) \ No newline at end of file +) diff --git a/include/hicr/backends/hwloc/computeResource.hpp b/include/hicr/backends/hwloc/computeResource.hpp index 47a06a7d..afd180be 100644 --- a/include/hicr/backends/hwloc/computeResource.hpp +++ b/include/hicr/backends/hwloc/computeResource.hpp @@ -68,7 +68,6 @@ class ComputeResource final : public HiCR::ComputeResource */ ComputeResource(hwloc_topology_t topology, const hwlocObjectIndex_t hwlocObjectIndex) : HiCR::ComputeResource(), - _hwlocObjectIndex(hwlocObjectIndex), _logicalProcessorId(detectLogicalProcessorId(topology, hwlocObjectIndex)), _physicalProcessorId(detectPhysicalProcessorId(topology, hwlocObjectIndex)), _numaAffinity(detectCoreNUMAffinity(topology, hwlocObjectIndex)), @@ -91,7 +90,6 @@ class ComputeResource final : public HiCR::ComputeResource const numaAffinity_t numaAffinity, std::unordered_set> caches) : HiCR::ComputeResource(), - _hwlocObjectIndex(hwlocObjectIndex), _logicalProcessorId(logicalProcessorId), _physicalProcessorId(physicalProcessorId), _numaAffinity(numaAffinity), @@ -384,11 +382,6 @@ class ComputeResource final : public HiCR::ComputeResource private: - /** - * Id of the core within the hwloc topology - */ - hwlocObjectIndex_t _hwlocObjectIndex; - /** * The logical ID of the hardware core / processing unit */ diff --git a/include/hicr/backends/hwloc/instanceManager.hpp b/include/hicr/backends/hwloc/instanceManager.hpp index 57232814..ec3ea867 100644 --- a/include/hicr/backends/hwloc/instanceManager.hpp +++ b/include/hicr/backends/hwloc/instanceManager.hpp @@ -70,13 +70,6 @@ class InstanceManager final : public HiCR::InstanceManager } [[nodiscard]] __INLINE__ HiCR::Instance::instanceId_t getRootInstanceId() const override { return 0; } - - private: - - /** - * The return value buffer is stored locally - */ - void *_returnValueBuffer{}; }; } // namespace HiCR::backend::hwloc diff --git a/include/hicr/backends/lpf/memoryManager.hpp b/include/hicr/backends/lpf/memoryManager.hpp index b54a491f..7bc2cea8 100644 --- a/include/hicr/backends/lpf/memoryManager.hpp +++ b/include/hicr/backends/lpf/memoryManager.hpp @@ -129,8 +129,6 @@ class MemoryManager final : public HiCR::MemoryManager void *ptr = malloc(newSize); if (ptr == nullptr) HICR_THROW_RUNTIME("Could not allocate memory of size %lu", newSize); - // Update the memory usage for the memory space - memorySpace->increaseUsage(newSize - size); // Creating and returning new memory slot return registerLocalMemorySlotImpl(memorySpace, ptr, newSize); } diff --git a/include/hicr/backends/mpi/instanceManager.hpp b/include/hicr/backends/mpi/instanceManager.hpp index b5c10a83..00060f1e 100644 --- a/include/hicr/backends/mpi/instanceManager.hpp +++ b/include/hicr/backends/mpi/instanceManager.hpp @@ -131,11 +131,6 @@ class InstanceManager final : public HiCR::InstanceManager private: - /** - * This value remembers what is the MPI rank of the instance that requested the execution of an RPC - */ - int _RPCRequestRank = 0; - /** * Default MPI communicator to use for this backend */ diff --git a/include/hicr/backends/nosv/computeManager.hpp b/include/hicr/backends/nosv/computeManager.hpp index acb07152..391776b4 100644 --- a/include/hicr/backends/nosv/computeManager.hpp +++ b/include/hicr/backends/nosv/computeManager.hpp @@ -51,7 +51,7 @@ class ComputeManager : public HiCR::ComputeManager * \param[in] executionUnit The replicable function to execute * @return The newly created execution unit */ - __INLINE__ static std::shared_ptr createExecutionUnit(const std::function &executionUnit) + __INLINE__ std::shared_ptr createExecutionUnit(const std::function &executionUnit) override { return std::make_shared(executionUnit); } @@ -176,7 +176,7 @@ class ComputeManager : public HiCR::ComputeManager auto p = dynamic_cast(processingUnit.get()); // If the processing unit is not recognized, throw error. We can use the processing unit's type (string) now. - if (p == nullptr) HICR_THROW_LOGIC("This compute manager cannot handle processing units of type '%s'", processingUnit->getType()); + if (p == nullptr) HICR_THROW_LOGIC("This compute manager cannot handle processing units of type '%s'", processingUnit->getType().c_str()); // Returning converted pointer return p; diff --git a/include/hicr/backends/opencl/computeManager.hpp b/include/hicr/backends/opencl/computeManager.hpp index f21584e4..e9dcad39 100644 --- a/include/hicr/backends/opencl/computeManager.hpp +++ b/include/hicr/backends/opencl/computeManager.hpp @@ -54,6 +54,11 @@ class ComputeManager final : public HiCR::ComputeManager ~ComputeManager() override = default; + /** + * Reintroduce base class function to avoid hiding + */ + using HiCR::ComputeManager::createExecutionUnit; + /** * Creates an execution unit given a stream/vector of \p kernelOperations to be executed on the device * @@ -159,11 +164,11 @@ class ComputeManager final : public HiCR::ComputeManager auto p = dynamic_cast(processingUnit.get()); // If the processing unit is not recognized, throw error. We can use the processing unit's type (string) now. - if (p == nullptr) HICR_THROW_LOGIC("This compute manager cannot handle processing units of type '%s'", processingUnit->getType()); + if (p == nullptr) HICR_THROW_LOGIC("This compute manager cannot handle processing units of type '%s'", processingUnit->getType().c_str()); // Returning converted pointer return p; } }; -} // namespace HiCR::backend::opencl \ No newline at end of file +} // namespace HiCR::backend::opencl diff --git a/include/hicr/backends/opencl/executionState.hpp b/include/hicr/backends/opencl/executionState.hpp index 0ef437eb..bd7bb968 100644 --- a/include/hicr/backends/opencl/executionState.hpp +++ b/include/hicr/backends/opencl/executionState.hpp @@ -51,7 +51,7 @@ class ExecutionState final : public HiCR::ExecutionState auto e = dynamic_pointer_cast(executionUnit); // Checking whether the execution unit passed is compatible with this backend - if (e == NULL) HICR_THROW_LOGIC("The execution unit of type '%s' is not supported by this backend\n", executionUnit->getType()); + if (e == NULL) HICR_THROW_LOGIC("The execution unit of type '%s' is not supported by this backend\n", executionUnit->getType().c_str()); _executionUnit = e; } @@ -101,7 +101,7 @@ class ExecutionState final : public HiCR::ExecutionState if (err != CL_SUCCESS) [[unlikely]] { HICR_THROW_RUNTIME("Failed to write event in the queue", err); } } - __INLINE__ void suspendImpl() { HICR_THROW_RUNTIME("Suspend functionality not supported by OpenCL backend"); } + __INLINE__ void suspendImpl() override { HICR_THROW_RUNTIME("Suspend functionality not supported by OpenCL backend"); } /** * Internal implementation of checkFinalization routine. It periodically query the OpenCL event on the queue to check for completion and diff --git a/include/hicr/core/meson.build b/include/hicr/core/meson.build index 0cbbb297..5ca287ac 100644 --- a/include/hicr/core/meson.build +++ b/include/hicr/core/meson.build @@ -12,7 +12,7 @@ endif # Warning handling option warningAsErrorFlags=[] if get_option('compileWarningsAsErrors') == true - warningAsErrorFlags=[ '-Werror' ] + warningAsErrorFlags=[ '-Werror', '-Wall' ] endif hicrBuildLinkArgs = [ diff --git a/include/hicr/frontends/tasking/worker.hpp b/include/hicr/frontends/tasking/worker.hpp index d5c5b684..512b0abb 100644 --- a/include/hicr/frontends/tasking/worker.hpp +++ b/include/hicr/frontends/tasking/worker.hpp @@ -392,7 +392,7 @@ class Worker if (_callbackMap != nullptr) _callbackMap->trigger(this, callback_t::onWorkerTaskPulled); // If a task was returned, then start or execute it - if (_currentTask != nullptr) + if (_currentTask != nullptr) { // If the task hasn't been initialized yet, we need to do it now if (_currentTask->getState() == HiCR::ExecutionState::state_t::uninitialized) @@ -409,7 +409,7 @@ class Worker } // Requesting processing units to terminate as soon as possible - if (_state == state_t::suspending) + if (_state == state_t::suspending) { // Setting state as suspended _state = state_t::suspended; diff --git a/tests/backends/hwloc/instanceManager.cpp b/tests/backends/hwloc/instanceManager.cpp index 56a6877e..83eeae78 100644 --- a/tests/backends/hwloc/instanceManager.cpp +++ b/tests/backends/hwloc/instanceManager.cpp @@ -21,7 +21,6 @@ * @date 16/8/2024 */ -#include #include "gtest/gtest.h" #include #include diff --git a/tests/frontends/objectStore/objectStore.cpp b/tests/frontends/objectStore/objectStore.cpp index 5dc704ca..cb8a63bc 100644 --- a/tests/frontends/objectStore/objectStore.cpp +++ b/tests/frontends/objectStore/objectStore.cpp @@ -39,13 +39,13 @@ class ObjectStoreTest : public ::testing::Test { memorySpace = std::make_shared(1024); - auto customRegisterLocalMemorySlotImpl = [this](std::shared_ptr memorySpace, void *const ptr, const size_t size) { + auto customRegisterLocalMemorySlotImpl = [](std::shared_ptr memorySpace, void *const ptr, const size_t size) { return std::make_shared(ptr, size, memorySpace); }; ON_CALL(memoryManager, registerLocalMemorySlotImpl(_, _, _)).WillByDefault(Invoke(customRegisterLocalMemorySlotImpl)); - auto customPromoteLocalMemorySlot = [this](std::shared_ptr slot, HiCR::GlobalMemorySlot::tag_t tag) { + auto customPromoteLocalMemorySlot = [](std::shared_ptr slot, HiCR::GlobalMemorySlot::tag_t tag) { return std::make_shared(tag, 0, slot); };