20#ifndef HEDGEHOG_ABSTRACT_CUDA_TASK_H
21#define HEDGEHOG_ABSTRACT_CUDA_TASK_H
24#include <cuda_runtime.h>
25#include <unordered_set>
28#include "../../tools/cuda_debugging.h"
45template<
size_t Separator,
class ...AllTypes>
61 this->
coreTask()->printOptions().background({0x76, 0xb9, 0x00, 0xff});
62 this->
coreTask()->printOptions().font({0xff, 0xff, 0xff, 0xff});
77 this->
coreTask()->printOptions().background({0x76, 0xb9, 0x00, 0xff});
78 this->
coreTask()->printOptions().font({0xff, 0xff, 0xff, 0xff});
99 for (
int i = 0; i < numGpus; ++i) {
104 auto ret = cudaDeviceEnablePeerAccess(i, 0);
105 if (ret != cudaErrorPeerAccessAlreadyEnabled) {
113 auto ret = cudaGetLastError();
114 if (ret != cudaErrorPeerAccessAlreadyEnabled) {
#define checkCudaErrors(err)
Abstract Task specialized for CUDA computation.
AbstractCUDATask(std::string const &name, size_t numberThreads, bool enablePeerAccess, bool automaticStart=false)
AbstractCUDATask full constructor.
cudaStream_t stream_
CUDA stream linked to the task.
virtual void initializeCuda()
Virtual initialization step, where user defined data structure can be initialized.
bool enablePeerAccess_
Enable CUDA Peer Access through all CUDA devices available.
AbstractCUDATask(std::shared_ptr< hh::core::CoreTask< Separator, AllTypes... > > coreTask, bool enablePeerAccess)
Custom core task constructor.
cudaStream_t stream() const
Getter for CUDA task's stream.
~AbstractCUDATask() override
Default destructor.
virtual void shutdownCuda()
Virtual shutdown step, where user defined data structure can be destroyed.
bool hasPeerAccess(int peerDeviceId)
Accessor for peer access enabled for a specific device id.
void initialize() final
Initialize an AbstractCUDATask to bind it to a CUDA device, and do the peer access if enabled....
AbstractCUDATask(std::string const name="CudaTask", size_t numberThreads=1)
Main constructor for a AbstractCUDATask.
void shutdown() final
Shutdown an AbstractCUDATask to destroy the task's CUDA stream created during AbstractCUDATask::initi...
std::unordered_set< int > peerDeviceIds_
Sparse matrix of linked CUDA devices.
bool enablePeerAccess() const
Accessor for peer access choice.
Base node for computation.
std::shared_ptr< hh::core::CoreTask< Separator, AllTypes... > > const & coreTask() const
Accessor to the core task.
int deviceId()
Accessor to device id linked to the task (default 0 for CPU task)
size_t numberThreads() const
Number of threads accessor.
std::string name() const
Node's name accessor.
std::shared_ptr< hh::core::abstraction::NodeAbstraction > const & core() const
Core accessor.
std::shared_ptr< AbstractMemoryManager > const & memoryManager() const
Memory manager accessor.