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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
std::vector<uint32_t> 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);
Expand All @@ -26,7 +26,7 @@ std::vector<uint32_t> loadLabels(const std::string &labelFilePath)
std::vector<uint32_t> labels(numLabels);

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

// Close file
in.close();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <algorithm>
#include <vector>

#include "../../../tensor/opencl/tensor.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<HiCR::MemorySpace> &deviceMemorySpace,
std::shared_ptr<HiCR::MemorySpace> &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)
{}

Expand Down Expand Up @@ -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<HiCR::MemorySpace> &_deviceMemorySpace;

/**
* Host memory space
*/
std::shared_ptr<HiCR::MemorySpace> &_hostMemorySpace;

/**
* OpenCL program
*/
Expand Down
4 changes: 2 additions & 2 deletions examples/neuralNetwork/source/include/imageLoader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
std::vector<uint32_t> 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);
Expand All @@ -30,7 +30,7 @@ std::vector<uint32_t> loadLabels(const std::string &labelFilePath)
std::vector<uint32_t> labels(numLabels);

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

// Close file
in.close();
Expand Down
3 changes: 1 addition & 2 deletions examples/neuralNetwork/source/opencl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions examples/pingPong/include/producer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#include <hicr/frontends/channel/fixedSize/spsc/producer.hpp>
#include <hicr/frontends/channel/fixedSize/spsc/consumer.hpp>

#include <iostream>

void producerFc(HiCR::MemoryManager &memoryManager,
HiCR::CommunicationManager &communicationManager,
std::shared_ptr<HiCR::MemorySpace> bufferMemorySpace,
Expand Down Expand Up @@ -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<ELEMENT_TYPE>(tokenSize, 'a');
auto sendBufferPtr = sendBuffer;
auto sendSlot = memoryManager.registerLocalMemorySlot(bufferMemorySpace, static_cast<void *>(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++)
Expand Down
6 changes: 3 additions & 3 deletions examples/tasking/abcTasks/source/abcTasks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down
21 changes: 3 additions & 18 deletions examples/tasking/runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,6 @@ class Runtime
*/
std::vector<std::unique_ptr<HiCR::ProcessingUnit>> _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)
*
Expand All @@ -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<HiCR::tasking::Task>(maxTasks);
_suspendedWorkerQueue = new HiCR::concurrent::Queue<HiCR::tasking::Worker>(maxWorkers);
_suspendedWorkerQueue = new HiCR::concurrent::Queue<HiCR::tasking::Worker>(__TASKR_DEFAULT_MAX_WORKERS);
}

// Destructor (frees previous allocations)
Expand Down
10 changes: 7 additions & 3 deletions include/hicr/backends/acl/computeManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

#include <acl/acl.h>
#include <memory>
#include <unordered_map>
#include <hicr/backends/acl/executionUnit.hpp>
#include <hicr/backends/acl/processingUnit.hpp>
#include <hicr/backends/acl/kernel.hpp>
Expand All @@ -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
*
Expand Down Expand Up @@ -166,11 +170,11 @@ class ComputeManager final : public HiCR::ComputeManager
auto p = dynamic_cast<acl::ProcessingUnit *>(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
} // namespace HiCR::backend::acl
4 changes: 2 additions & 2 deletions include/hicr/backends/acl/executionState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ExecutionState final : public HiCR::ExecutionState
auto e = dynamic_pointer_cast<acl::ExecutionUnit>(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;
}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions include/hicr/backends/acl/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -22,4 +22,4 @@ HiCRBackendDependencies += declare_dependency(
compile_args: backendCppArgs,
link_args: backendLinkArgs,
include_directories: backendIncludes,
)
)
7 changes: 0 additions & 7 deletions include/hicr/backends/hwloc/computeResource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand All @@ -91,7 +90,6 @@ class ComputeResource final : public HiCR::ComputeResource
const numaAffinity_t numaAffinity,
std::unordered_set<std::shared_ptr<backend::hwloc::Cache>> caches)
: HiCR::ComputeResource(),
_hwlocObjectIndex(hwlocObjectIndex),
_logicalProcessorId(logicalProcessorId),
_physicalProcessorId(physicalProcessorId),
_numaAffinity(numaAffinity),
Expand Down Expand Up @@ -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
*/
Expand Down
7 changes: 0 additions & 7 deletions include/hicr/backends/hwloc/instanceManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions include/hicr/backends/lpf/memoryManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
5 changes: 0 additions & 5 deletions include/hicr/backends/mpi/instanceManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
4 changes: 2 additions & 2 deletions include/hicr/backends/nosv/computeManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<HiCR::ExecutionUnit> createExecutionUnit(const std::function<void(void *)> &executionUnit)
__INLINE__ std::shared_ptr<HiCR::ExecutionUnit> createExecutionUnit(const std::function<void(void *)> &executionUnit) override
{
return std::make_shared<HiCR::backend::nosv::ExecutionUnit>(executionUnit);
}
Expand Down Expand Up @@ -176,7 +176,7 @@ class ComputeManager : public HiCR::ComputeManager
auto p = dynamic_cast<nosv::ProcessingUnit *>(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;
Expand Down
9 changes: 7 additions & 2 deletions include/hicr/backends/opencl/computeManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -159,11 +164,11 @@ class ComputeManager final : public HiCR::ComputeManager
auto p = dynamic_cast<opencl::ProcessingUnit *>(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
} // namespace HiCR::backend::opencl
4 changes: 2 additions & 2 deletions include/hicr/backends/opencl/executionState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ExecutionState final : public HiCR::ExecutionState
auto e = dynamic_pointer_cast<opencl::ExecutionUnit>(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;
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion include/hicr/core/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ endif
# Warning handling option
warningAsErrorFlags=[]
if get_option('compileWarningsAsErrors') == true
warningAsErrorFlags=[ '-Werror' ]
warningAsErrorFlags=[ '-Werror', '-Wall' ]
endif

hicrBuildLinkArgs = [
Expand Down
4 changes: 2 additions & 2 deletions include/hicr/frontends/tasking/worker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down
Loading