14 template <
class T,
int rank,
int myMem,
int myStyle,
class I>
15 void memset( Array<T,rank,myMem,myStyle>
const &arr , I val , Stream stream = Stream() ) {
17 if (! arr.initialized()) {
18 yakl_throw(
"ERROR: calling memset on an array that is not allocated");
24 #if defined(YAKL_ARCH_CUDA)
25 cudaMemsetAsync( arr.data() , 0 ,
sizeof(T)*arr.totElems() , stream.get_real_stream() );
26 #elif defined(YAKL_ARCH_HIP)
27 hipMemsetAsync ( arr.data() , 0 ,
sizeof(T)*arr.totElems() , stream.get_real_stream() );
28 #elif defined(YAKL_ARCH_SYCL)
29 stream.get_real_stream().memset( arr.data() , 0 ,
sizeof(T)*arr.totElems() );
38 #if defined(YAKL_ARCH_SYCL)
39 stream.get_real_stream().fill<T>( arr.data() , val , arr.totElems() );
46 std::fill( arr.data(), arr.data()+arr.totElems(), val );
49 #if defined(YAKL_AUTO_FENCE)
56 template <
class T,
int rank,
class B0,
class B1,
class B2,
class B3,
class I>
57 YAKL_INLINE void memset( FSArray<T,rank,B0,B1,B2,B3> &arr , I val ) {
58 for (
index_t i = 0; i < arr.totElems(); i++) {
65 template <
class T,
int rank,
unsigned D0,
unsigned D1,
unsigned D2,
unsigned D3,
class I>
66 YAKL_INLINE void memset( SArray<T,rank,D0,D1,D2,D3> &arr , I val ) {
67 for (
index_t i = 0; i < arr.totElems(); i++) {