Class CUDAEnvironmentDirectedGraphBuffers
Defined in File CUDAEnvironmentDirectedGraphBuffers.cuh
Nested Relationships
Nested Types
Class Documentation
-
class CUDAEnvironmentDirectedGraphBuffers
This represents the equivalent of CUDAAgent, CUDAMessage for EnvironmentDirectedGraph As the graph cannot be modified on the device, the host buffers can be assumed to always holds the truth It is only necessary to ensure device buffers are updated to match if the host buffers have changed
Public Functions
-
explicit CUDAEnvironmentDirectedGraphBuffers(const EnvironmentDirectedGraphData &description)
Initialises the internal map with a buffer for each vertex and edge property
- Parameters:
description – The EnvironmentDirectedGraphData to initialise the CUDABuffers for
-
~CUDAEnvironmentDirectedGraphBuffers()
Destructor Frees any allocated CUDA buffers
Called internally by the constructor to register curve instances to be notified of allocations This should also be called when submodels are initialising
-
inline const EnvironmentDirectedGraphData &getDescription() const
Return the description of the represented graph
-
void setVertexCount(size_type count, cudaStream_t stream)
Allocates and initialises the vertex buffers
- Parameters:
count – The number of vertices to allocate each buffer for
stream – CUDA stream to be used if data must be copied back from device
-
void setEdgeCount(size_type count)
Allocates and initialises the vertex buffers
- Parameters:
count – The number of edges to allocate each buffer for
-
inline size_type getVertexCount() const
Returns the number of vertices the graph is currently allocated to hold
-
inline size_type getEdgeCount() const
Returns the number of edges the graph is currently allocated to hold
-
unsigned int createIfNotExistVertex(id_t vertex_id, cudaStream_t stream)
Attempt to assign the provided vertex_id with an index inside h_vertex_index_map
- Parameters:
vertex_id – The ID of the vertex to be created
stream – The CUDA stream to use if the ID buffer requires sync
- Throws:
exception::OutOfBoundsException – If the number of vertices would exceed the vertex count configured via setVertexCount()
- Returns:
The index of the vertex with the given ID
-
unsigned int createIfNotExistEdge(id_t source_vertex_id, id_t dest_vertex_id, cudaStream_t stream)
Attempt to assign the provided source_vertex_id and dest_vertex_id with an index inside h_vertex_index_map
- Parameters:
source_vertex_id – The ID of the source vertex of the edge to be created
dest_vertex_id – The ID of the destination vertex of the edge to be created
stream – The CUDA stream to use if the ID buffer requires sync
- Throws:
exception::OutOfBoundsException – If the number of edges would exceed the edge count configured via setEdgeCount()
- Returns:
The index of the edge with the given src and dest vertex IDs
-
id_t *getVertexIDBuffer(cudaStream_t stream)
Returns the currently allocated device buffer for vertex IDs
- Throws:
exception::OutOfBoundsException – If the vertex buffers have not been allocated yet
-
template<typename T>
const T *getVertexPropertyBuffer(const std::string &property_name, size_type &N, cudaStream_t stream) const Returns the currently allocated device buffer for the specified vertex property
Note
If N is passed as 0, it will instead be set to the number of elements
- Parameters:
property_name – The name of the property to set
N – The number of elements in the property (1 if not a property array)
stream – CUDA stream to be used if data must be copied back from device
- Template Parameters:
T – The type of the property
- Throws:
exception::InvalidArgument – If property_name does not refer to a valid vertex property
exception::InvalidGraphProperty – If an vertex property with the matching name and type does not exist
exception::OutOfBoundsException – If the vertex buffers have not been allocated yet
-
template<typename T>
T *getVertexPropertyBuffer(const std::string &property_name, size_type &N, cudaStream_t stream) Returns the currently allocated device buffer for the specified vertex property Additionally marks the device buffer as out of date, use the const version if you do not wish to change the buffer
Note
If N is passed as 0, it will instead be set to the number of elements
- Parameters:
property_name – The name of the property to set
N – The number of elements in the property (1 if not a property array)
stream – CUDA stream to be used if data must be copied back from device
- Template Parameters:
T – The type of the property
- Throws:
exception::InvalidArgument – If property_name does not refer to a valid vertex property
exception::InvalidGraphProperty – If an vertex property with the matching name and type does not exist
exception::OutOfBoundsException – If the vertex buffers have not been allocated yet
-
template<typename T>
const T *getEdgePropertyBuffer(const std::string &property_name, size_type &N, cudaStream_t stream) const Returns the currently allocated device buffer for the specified edge property
Note
If N is passed as 0, it will instead be set to the number of elements
- Parameters:
property_name – The name of the property to set
N – The number of elements in the property (1 if not a property array)
stream – CUDA stream to be used if data must be copied back from device
- Template Parameters:
T – The type of the property
- Throws:
exception::InvalidArgument – If property_name does not refer to a valid edge property
exception::InvalidGraphProperty – If an edge property with the matching name and type does not exist
exception::OutOfBoundsException – If the vertex buffers have not been allocated yet
-
template<typename T>
T *getEdgePropertyBuffer(const std::string &property_name, size_type &N, cudaStream_t stream) Returns the currently allocated device buffer for the specified edge property Additionally marks the device buffer as out of date, use the const version if you do not wish to change the buffer
Note
If N is passed as 0, it will instead be set to the number of elements
- Parameters:
property_name – The name of the property to set
N – The number of elements in the property (1 if not a property array)
stream – CUDA stream to be used if data must be copied back from device
- Template Parameters:
T – The type of the property
- Throws:
exception::InvalidArgument – If property_name does not refer to a valid edge property
exception::InvalidGraphProperty – If an edge property with the matching name and type does not exist
exception::OutOfBoundsException – If the vertex buffers have not been allocated yet
-
inline void markForRebuild()
-
void syncDevice_async(detail::CUDAScatter &scatter, unsigned int streamID, cudaStream_t stream)
Update any device buffers which don’t currently match the host Rebuild the internal graph CSR, sort edge buffers
- Parameters:
scatter – CUDAScatter singleton instance
streamID – Stream index corresponding to stream resources to use
stream – The cuda stream to perform CUDA operations on
-
void setVertexID(unsigned int vertex_index, id_t vertex_id, cudaStream_t stream)
Updates the vertex ID buffer Updates the internal host map of ID->index Updates the internal tracking of th vertex ID min/max
Note
This affects how much memory is allocates for the vertex id -> index map
- Parameters:
vertex_index – The index of the vertex
vertex_id – The ID that has been assigned to the vertex
stream – The cuda stream to perform CUDA operations on
- Throws:
exception::IDCollision – If the ID is already assigned to a different vertex
-
unsigned int getVertexIndex(id_t vertex_id) const
Returns the index of the vertex with the given ID
- Parameters:
vertex_id – The ID of the vertex of which to return the index
- Throws:
exception::InvalidID – If the ID is not in use
-
void setEdgeSourceDestination(unsigned int edge_index, id_t src_vertex_id, id_t dest_vertex_id)
Updates the edge ID buffer Updates the internal host map of src:dest->index
- Parameters:
edge_index – The index of the edge
src_vertex_id – The ID that has been assigned to the source vertex of the edge
dest_vertex_id – The ID that has been assigned to the destination vertex of the edge
- Throws:
exception::IDCollision – If the ID is already assigned to a different vertex
-
unsigned int getEdgeIndex(id_t src_vertex_id, id_t dest_vertex_id) const
Returns the index of the edge with the given source and destination vertices
- Parameters:
src_vertex_id – The ID that has been assigned to the source vertex of the edge
dest_vertex_id – The ID that has been assigned to the destination vertex of the edge
- Throws:
exception::InvalidID – If the ID is not in use
-
explicit CUDAEnvironmentDirectedGraphBuffers(const EnvironmentDirectedGraphData &description)