Celeritas 0.7-develop+a3e14d7
Loading...
Searching...
No Matches
Functions
CollectionAlgorithms.hh File Reference
#include <numeric>
#include <utility>
#include <vector>
#include "Collection.hh"
#include "CollectionBuilder.hh"
#include "Copier.hh"
#include "Filler.hh"

Functions

template<class T , Ownership W, MemSpace M, class I >
void celeritas::fill (T &&value, Collection< T, W, M, I > *col)
 Fill the collection with the given value.
 
template<class T , Ownership W, MemSpace M, class I >
void celeritas::fill_sequence (Collection< T, W, M, I > *dst, StreamId stream)
 Fill the collection with sequentially increasing values starting from zero.
 
template<class T , MemSpace M, class I >
void celeritas::reserve (Collection< T, Ownership::value, M, I > *col, size_type num_used, size_type capacity, StreamId stream)
 Reallocate the collection with a larger capacity.
 
template<class T , Ownership W, MemSpace M, class I , std::size_t E>
void celeritas::copy_to_host (Collection< T, W, M, I > const &src, Span< T, E > dst, StreamId sid={})
 Copy from the given collection to host.
 
template<class T , Ownership W, MemSpace M, class I >
auto celeritas::copy_to_host (Collection< T, W, M, I > const &src)
 Create a new host collection from the given collection.
 

Function Documentation

◆ copy_to_host()

template<class T , Ownership W, MemSpace M, class I >
auto celeritas::copy_to_host ( Collection< T, W, M, I > const &  src)

Create a new host collection from the given collection.

This is useful for debugging.

◆ fill()

template<class T , Ownership W, MemSpace M, class I >
void celeritas::fill ( T &&  value,
Collection< T, W, M, I > *  col 
)

Fill the collection with the given value.

This should only be used during initialization when stream synchronization is OK. Use the Filler directly during runtime since it supports streams.

◆ fill_sequence()

template<class T , Ownership W, MemSpace M, class I >
void celeritas::fill_sequence ( Collection< T, W, M, I > *  dst,
StreamId  stream 
)

Fill the collection with sequentially increasing values starting from zero.

Todo:
Make this a kernel launch rather than a local allocation and synchronous copy.

◆ reserve()

template<class T , MemSpace M, class I >
void celeritas::reserve ( Collection< T, Ownership::value, M, I > *  col,
size_type  num_used,
size_type  capacity,
StreamId  stream 
)

Reallocate the collection with a larger capacity.

The first num_used elements are copied into the new storage. On device, the allocation, copy, and release of the old storage are all ordered on the given stream, so the stream must order this after any kernels using the collection.

Warning
This invalidates all references, spans, and pointers to the collection's data, including copies in device memory. The caller must update them before they are used again.