42#if defined (__CUDACC__)
46#if defined (__HIPCC__)
55#if defined(__cplusplus)
68#define CS_ARRAY_SUBSET_NULL -1
69#define CS_ARRAY_SUBSET_IN 0
70#define CS_ARRAY_SUBSET_OUT 1
71#define CS_ARRAY_SUBSET_INOUT 2
106template <
typename T,
size_t stride,
typename... Arrays>
113 T* array_ptrs[] = {arrays ... };
115#if defined (__CUDACC__) || defined(__HIPCC__)
117 for (T* array : array_ptrs)
118 is_available_on_device = is_available_on_device
122 if (is_available_on_device) {
123#if defined (__CUDACC__)
124 cudaStream_t stream_ = cs_cuda_get_stream(0);
126 hipStream_t stream_ = cs_hip_get_stream(0);
128 cs_arrays_set_value<T, stride>(stream_,
138 for (T* array : array_ptrs)
139 memcpy(array + i_elt*stride, ref_val, stride*
sizeof(T));
145# pragma omp parallel for num_threads(n_threads)
168template <
typename T,
size_t stride,
typename... Arrays>
175 T* array_ptrs[] = {arrays ... };
177#if defined (__CUDACC__) || defined (__HIPCC__)
178 bool is_available_on_device =
true;
179 for (T* array : array_ptrs)
180 is_available_on_device = is_available_on_device
184 if (is_available_on_device) {
185#if defined (__CUDACC__)
186 cudaStream_t stream_ = cs_cuda_get_stream(0);
188 hipStream_t stream_ = cs_hip_get_stream(0);
190 cs_arrays_set_value<T, stride>(stream_,
200 for (T* array : array_ptrs)
201 for (
size_t k = 0;
k < stride;
k++) {
202 array[i_elt*stride +
k] = ref_val;
209# pragma omp parallel for num_threads(n_threads)
236template <
typename T,
size_t stride,
typename... Arrays>
244 T* array_ptrs[] = {arrays ... };
246#if defined (__CUDACC__) || defined (__HIPCC__)
249 cs_arrays_set_value<T, stride>(stream_,
259 for (T* array : array_ptrs)
260 memcpy(array + i_elt*stride, ref_val, stride*
sizeof(T));
265 int n_threads = ctx.n_cpu_threads();
268# pragma omp parallel for num_threads(n_threads)
295template <
typename T,
size_t stride,
typename... Arrays>
303 T* array_ptrs[] = {arrays ... };
305#if defined (__CUDACC__) || defined (__HIPCC__)
308 cs_arrays_set_value<T, stride>(stream_,
318 for (T* array : array_ptrs)
319 for (
size_t k = 0;
k < stride;
k++) {
320 array[i_elt*stride +
k] = ref_val;
326 int n_threads = ctx.n_cpu_threads();
329# pragma omp parallel for num_threads(n_threads)
354template <
typename T,
size_t stride,
typename... Arrays>
361 T* array_ptrs[] = {arrays ... };
363#if defined (__CUDACC__) || defined (__HIPCC__)
366 cs_arrays_set_zero<T, stride>(stream_,
374 constexpr T c =
static_cast<T
>(0);
379 int n_threads = ctx.n_cpu_threads();
382# pragma omp parallel num_threads(n_threads)
385 for (T* array : array_ptrs) {
387# pragma omp for nowait
413template <
typename T,
size_t stride,
typename... Arrays>
424 cs_arrays_set_value<T, stride>(n_elts, ref_val, arrays...);
427 T* array_ptrs[] = {arrays ... };
430 for (T* array : array_ptrs)
431 memcpy(array + i_elt*stride, ref_val, stride*
sizeof(T));
437# pragma omp parallel for num_threads(n_threads)
440 set_value(elt_ids[i]);
462template <
typename T,
size_t stride,
typename... Arrays>
473 cs_arrays_set_value<T, stride>(n_elts, ref_val, arrays...);
477 T* array_ptrs[] = {arrays ... };
480 for (T* array : array_ptrs)
481 for (
size_t k = 0;
k < stride;
k++) {
482 array[i_elt*stride +
k] = ref_val;
489# pragma omp parallel for num_threads(n_threads)
492 set_value(elt_ids[i]);
515#if defined (__CUDACC__) || defined (__HIPCC__)
519 if (is_available_on_device) {
520#if defined (__CUDACC__)
521 cudaStream_t stream_ = cs_cuda_get_stream(0);
523 hipStream_t stream_ = cs_hip_get_stream(0);
525 cs_array_copy<T>(stream_,
false, size, src, dest);
532# pragma omp parallel for num_threads(n_threads)
565# pragma omp parallel for num_threads(n_threads)
1117template<
class T,
int N = 1, layout L = layout::right>
1137#if (defined(__GNUC__) || defined(__clang__)) \
1138 && !defined(CS_AOCC_BUILTIN_WORKAROUND) \
1139 && __has_builtin(__builtin_LINE) && __has_builtin(__builtin_FILE)
1140 const char *file_name = __builtin_FILE(),
1141 const int line_number = __builtin_LINE()
1143 const char *file_name = __FILE__,
1144 const int line_number = __LINE__
1167#if (defined(__GNUC__) || defined(__clang__)) && \
1168 __has_builtin(__builtin_LINE) && \
1169 __has_builtin(__builtin_FILE)
1170 const char *file_name = __builtin_FILE(),
1171 const int line_number = __builtin_LINE()
1173 const char *file_name = __FILE__,
1174 const int line_number = __LINE__
1194 operator delete(
void *ptr)
1207 operator delete[](
void *ptr)
1222#if !defined(__CUDA_ARCH__) && \
1223 !defined(SYCL_LANGUAGE_VERSION) && \
1224 !defined(__HIP_DEVICE_COMPILE__)
1243#
if (defined(__GNUC__) || defined(__clang__)) && \
1246 const char *file_name = __builtin_FILE(),
1247 const int line_number = __builtin_LINE()
1249 const char *file_name = __FILE__,
1250 const int line_number = __LINE__
1258 static_assert(N == 1,
1259 "Instantiation using only total size only possible for "
1260 " cs::array<T,1> or cs::array<T>");
1262 allocate_(file_name, line_number);
1263#if defined(CS_ARRAY_DBG_INIT)
1279#
if (defined(__GNUC__) || defined(__clang__)) && \
1282 const char *file_name = __builtin_FILE(),
1283 const int line_number = __builtin_LINE()
1285 const char *file_name = __FILE__,
1286 const int line_number = __LINE__
1294 allocate_(file_name, line_number);
1295#if defined(CS_ARRAY_DBG_INIT)
1312#
if (defined(__GNUC__) || defined(__clang__)) && \
1315 const char *file_name = __builtin_FILE(),
1316 const int line_number = __builtin_LINE()
1318 const char *file_name = __FILE__,
1319 const int line_number = __LINE__
1327 static_assert(N == 2,
1328 "Instantiation using (size1, size2) only possible for "
1332 allocate_(file_name, line_number);
1333#if defined(CS_ARRAY_DBG_INIT)
1351#
if (defined(__GNUC__) || defined(__clang__)) && \
1354 const char *file_name = __builtin_FILE(),
1355 const int line_number = __builtin_LINE()
1357 const char *file_name = __FILE__,
1358 const int line_number = __LINE__
1366 static_assert(N == 3,
1367 "Instantiation using (size1, size2, size3) only possible "
1368 " for cs::array<T,3>");
1369 cs_lnum_t tmp_size[N] = {size1, size2, size3};
1371 allocate_(file_name, line_number);
1372#if defined(CS_ARRAY_DBG_INIT)
1391#
if (defined(__GNUC__) || defined(__clang__)) && \
1394 const char *file_name = __builtin_FILE(),
1395 const int line_number = __builtin_LINE()
1397 const char *file_name = __FILE__,
1398 const int line_number = __LINE__
1406 static_assert(N == 4,
1407 "Instantiation using (size1, size2, size3, size4) only possible "
1408 " for cs::array<T,4>");
1409 cs_lnum_t tmp_size[N] = {size1, size2, size3, size4};
1411 allocate_(file_name, line_number);
1412#if defined(CS_ARRAY_DBG_INIT)
1423 template<
typename... Args>
1434#if !defined(__CUDA_ARCH__) && \
1435 !defined(SYCL_LANGUAGE_VERSION) && \
1436 !defined(__HIP_DEVICE_COMPILE__)
1460#if !defined(__CUDA_ARCH__) && \
1461 !defined(SYCL_LANGUAGE_VERSION) && \
1462 !defined(__HIP_DEVICE_COMPILE__)
1485 _mode = other._mode;
1567#if !defined(__CUDA_ARCH__) && \
1568 !defined(SYCL_LANGUAGE_VERSION) && \
1569 !defined(__HIP_DEVICE_COMPILE__)
1577 for (
int i = 0; i < N; i++) {
1587#
if (defined(__GNUC__) || defined(__clang__)) && \
1590 const char *file_name = __builtin_FILE(),
1591 const int line_number = __builtin_LINE()
1593 const char *file_name = __FILE__,
1594 const int line_number = __LINE__
1632 template<
int _N_, layout _L_ = L>
1642 for (
int i = 0; i < _N_; i++)
1646#if !defined(__CUDA_ARCH__) && \
1647 !defined(SYCL_LANGUAGE_VERSION) && \
1648 !defined(__HIP_DEVICE_COMPILE__)
1650 _(
"%s: requested span has total size of %d instead of %d "
1651 "for this array.\n"),
1671 template<
layout _L_ = L,
typename... Args>
1673 mdspan<T,
sizeof...(Args), _L_>
1679 check_non_empty_args_(indices...);
1681 constexpr int n_vals =
sizeof...(Args);
1682 cs_lnum_t tmp_args[n_vals] = {indices...};
1684 return get_mdspan<n_vals, _L_>(tmp_args);
1701#if !defined(__CUDA_ARCH__) && \
1702 !defined(SYCL_LANGUAGE_VERSION) && \
1703 !defined(__HIP_DEVICE_COMPILE__)
1720#
if (defined(__GNUC__) || defined(__clang__)) && \
1723 const char *file_name = __builtin_FILE(),
1724 const int line_number = __builtin_LINE()
1726 const char *file_name = __FILE__,
1727 const int line_number = __LINE__
1731 static_assert(N == 1,
1732 "Method reshape(size, ...) only possible for "
1733 " cs::array<T> or cs::array<T,1>");
1734 assert(new_size >= 0);
1742 reallocate_(file_name, line_number);
1746 _(
"%s: array cannot be reshaped if non owner, "
1747 "use mdspan instead.\n"), __func__);
1763#
if (defined(__GNUC__) || defined(__clang__)) && \
1766 const char *file_name = __builtin_FILE(),
1767 const int line_number = __builtin_LINE()
1769 const char *file_name = __FILE__,
1770 const int line_number = __LINE__
1775 "Method reshape_and_copy(size, ...) only possible for "
1776 " cs::array<T> or cs::array<T,1>");
1777 assert(new_size >= 0);
1778 assert(size_to_keep <= new_size && size_to_keep <=
_span::_size);
1784 if (!(size_to_keep <= new_size && size_to_keep <=
_span::_size))
1786 "%s: Data cannot be saved when new size is smaller "
1787 "than size to keep.\n",
1793 reallocate_(file_name, line_number);
1797 _(
"%s: array cannot be reshaped if non owner, "
1798 "use mdspan instead.\n"), __func__);
1811#
if (defined(__GNUC__) || defined(__clang__)) && \
1814 const char *file_name = __builtin_FILE(),
1815 const int line_number = __builtin_LINE()
1817 const char *file_name = __FILE__,
1818 const int line_number = __LINE__
1823 bool same_dim =
true;
1824 for (
int i = 0; i < N; i++)
1833 reallocate_(file_name, line_number);
1837 _(
"%s: array cannot be reshaped if non owner, "
1838 "use mdspan instead.\n"), __func__);
1852#
if (defined(__GNUC__) || defined(__clang__)) && \
1855 const char *file_name = __builtin_FILE(),
1856 const int line_number = __builtin_LINE()
1858 const char *file_name = __FILE__,
1859 const int line_number = __LINE__
1863 assert(size_to_keep <= dims[N-1] && size_to_keep <=
_span::_extent[N-1]);
1866 bool same_dim =
true;
1867 for (
int i = 0; i < N; i++)
1876 if (size_to_keep != 0) {
1882 reallocate_(file_name, line_number);
1885 cs_lnum_t new_o[N], new_e[N], old_o[N], old_e[N], max_e[N];
1887 for (
int i = 0; i < N; i++) {
1890 old_o[i] = tmp.
offset(i);
1891 old_e[i] = tmp.
extent(i);
1893 max_e[i] = (new_e[i] > old_e[i]) ? old_e[i] : new_e[i];
1895 if (max_e[N-1] > size_to_keep && size_to_keep > 0)
1896 max_e[N-1] = size_to_keep;
1898 T* old_data = tmp.
data();
1910 for (
int i = N-1; i >= 1; i--) {
1911 idx[i] = dummy % old_e[i];
1912 dummy = (dummy - idx[i]) / old_e[i];
1917 for (
int i = 0; i < N; i++) {
1918 if (idx[i] >= max_e[i]) {
1928 for (
int i = 0; i < N; i++) {
1929 o_id += idx[i] * old_o[i];
1930 n_id += idx[i] * new_o[i];
1933 new_data[n_id] = old_data[o_id];
1940 reshape(dims, file_name, line_number);
1945 _(
"%s: array cannot be reshaped if non owner, "
1946 "use mdspan instead.\n"), __func__);
1961#
if (defined(__GNUC__) || defined(__clang__)) && \
1964 const char *file_name = __builtin_FILE(),
1965 const int line_number = __builtin_LINE()
1967 const char *file_name = __FILE__,
1968 const int line_number = __LINE__
1972 static_assert(N == 2,
1973 "Method reshape(size1, size2, ...) only possible for "
1977 reshape(tmp_size, file_name, line_number);
1993#
if (defined(__GNUC__) || defined(__clang__)) && \
1996 const char *file_name = __builtin_FILE(),
1997 const int line_number = __builtin_LINE()
1999 const char *file_name = __FILE__,
2000 const int line_number = __LINE__
2004 static_assert(N == 2,
2005 "Method reshape_and_copy(size1, size2, ...) only possible for "
2025#
if (defined(__GNUC__) || defined(__clang__)) && \
2028 const char *file_name = __builtin_FILE(),
2029 const int line_number = __builtin_LINE()
2031 const char *file_name = __FILE__,
2032 const int line_number = __LINE__
2036 static_assert(N == 3,
2037 "Method reshape(size1, size2, size3, ...) only possible for "
2039 cs_lnum_t tmp_size[N] = {size1, size2, size3};
2041 reshape(tmp_size, file_name, line_number);
2058#
if (defined(__GNUC__) || defined(__clang__)) && \
2061 const char *file_name = __builtin_FILE(),
2062 const int line_number = __builtin_LINE()
2064 const char *file_name = __FILE__,
2065 const int line_number = __LINE__
2069 static_assert(N == 3,
2070 "Method reshape_and_copy(size1, size2, size3, ...) only "
2071 "possible for cs::array<T,3>");
2072 cs_lnum_t tmp_size[N] = {size1, size2, size3};
2092#
if (defined(__GNUC__) || defined(__clang__)) && \
2095 const char *file_name = __builtin_FILE(),
2096 const int line_number = __builtin_LINE()
2098 const char *file_name = __FILE__,
2099 const int line_number = __LINE__
2103 static_assert(N == 4,
2104 "Method reshape_and_copy(size1, size2, size3, size4, ...)"
2105 " only possible for cs::array<T,4>");
2106 cs_lnum_t tmp_size[N] = {size1, size2, size3, size4};
2123 if (_mode !=
mode) {
2207 assert(loop_size <= other.
size());
2211 T* o_data_ptr = other.
data();
2214 data_ptr[e_id] = o_data_ptr[e_id];
2226 template<
typename... Args>
2230 check_non_empty_args_
2235 static_assert(
sizeof...(Args) > 0,
"At least one input argument is needed.");
2236 static_assert(
cs::are_integral<Args...>::value,
"Non integral input arguments.");
2249 const char *file_name,
2250 const int line_number
2253 const char *_ptr_name =
"cs::array._data";
2254 _span::_data =
static_cast<T *
>(cs_mem_malloc_hd(_mode,
2272 const char *file_name,
2273 const int line_number
2278 const char *_ptr_name =
"cs::array._data";
2300 constexpr T tmp_nan = std::numeric_limits<T>::signaling_NaN();
2322template<
class T, cs::layout L = cs::layout::right>
2325template<
class T, cs::layout L = cs::layout::right>
2328template<
class T, cs::layout L = cs::layout::right>
2331template<
class T,
int N, cs::layout L = cs::layout::right>
2334template<
class T,
int N>
2337template<
class T,
int N>
void bft_error(const char *const file_name, const int line_num, const int sys_error_code, const char *const format,...)
Calls the error handler (set by bft_error_handler_set() or default).
Definition: bft_error.cpp:187
Define a templated array class (owner of data)
Definition: cs_array.h:1118
CS_F_HOST_DEVICE mdspan< T, _N_, _L_ > get_mdspan(const cs_lnum_t(&dims)[_N_])
Get span view of array with a given array of dimensions (extent). If total size of span is different ...
Definition: cs_array.h:1636
CS_F_HOST_DEVICE void set_alloc_mode(cs_alloc_mode_t mode)
Set memory allocation mode.
Definition: cs_array.h:2119
CS_F_HOST array(cs_lnum_t size1, cs_lnum_t size2, cs_alloc_mode_t alloc_mode=cs_alloc_mode, const char *file_name=__FILE__, const int line_number=__LINE__)
Constructor method for 2D array based on sizes.
Definition: cs_array.h:1308
CS_F_HOST_DEVICE cs_alloc_mode_t mode() const
Getter function for allocation mode.
Definition: cs_array.h:2159
CS_F_HOST void copy_data(cs_dispatch_context &ctx, const array &other, const cs_lnum_t n_vals=-1)
Copy data from raw pointer, we suppose that data size is same as that of the array....
Definition: cs_array.h:2197
CS_F_HOST void reshape(cs_lnum_t new_size, const char *file_name=__FILE__, const int line_number=__LINE__)
Resize data array.
Definition: cs_array.h:1718
CS_F_HOST array(cs_lnum_t size, cs_alloc_mode_t alloc_mode=cs_alloc_mode, const char *file_name=__FILE__, const int line_number=__LINE__)
Constructor method using only size.
Definition: cs_array.h:1240
CS_F_HOST void reshape_and_copy(cs_lnum_t new_size, cs_lnum_t size_to_keep, const char *file_name=__FILE__, const int line_number=__LINE__)
Resize data array and copy old data.
Definition: cs_array.h:1760
CS_F_HOST_DEVICE array(const array &other)
Constructor method using copy results in a shallow copy. If a deep copy is needed,...
Definition: cs_array.h:1479
CS_F_HOST_DEVICE mdspan< T, N, L > view()
Get span view of array, same dimensions as array.
Definition: cs_array.h:1617
CS_F_HOST_DEVICE array & operator=(array other)
Assignment operator.
Definition: cs_array.h:1548
CS_F_HOST array(cs_lnum_t size1, cs_lnum_t size2, cs_lnum_t size3, cs_lnum_t size4, cs_alloc_mode_t alloc_mode=cs_alloc_mode, const char *file_name=__FILE__, const int line_number=__LINE__)
Constructor method for 4D array based on sizes.
Definition: cs_array.h:1385
CS_F_HOST_DEVICE array(array &&other)
Move constructor.
Definition: cs_array.h:1498
CS_F_HOST void reshape(const cs_lnum_t(&dims)[N], const char *file_name=__FILE__, const int line_number=__LINE__)
Resize data array and do not keep old data.
Definition: cs_array.h:1809
CS_F_HOST void reshape(const cs_lnum_t size1, const cs_lnum_t size2, const char *file_name=__FILE__, const int line_number=__LINE__)
Resize data array 2D (no explicit copy, only realloc)
Definition: cs_array.h:1958
CS_F_HOST array< T, N, L > get_deep_copy(const char *file_name=__FILE__, const int line_number=__LINE__) const
Definition: cs_array.h:1586
CS_F_HOST void copy_data(const array &other, const cs_lnum_t n_vals=-1)
Copy data from another array, we suppose that data size is same as that of the array....
Definition: cs_array.h:2175
CS_F_HOST_DEVICE array()
Default constructor method leading to "empty container".
Definition: cs_array.h:1219
CS_F_HOST array(cs_lnum_t size1, cs_lnum_t size2, cs_lnum_t size3, cs_alloc_mode_t alloc_mode=cs_alloc_mode, const char *file_name=__FILE__, const int line_number=__LINE__)
Constructor method for 3D array based on sizes.
Definition: cs_array.h:1346
CS_F_HOST_DEVICE void clear()
Clear data (empty container).
Definition: cs_array.h:1563
CS_F_HOST void reshape_and_copy(const cs_lnum_t size1, const cs_lnum_t size2, cs_lnum_t size_to_keep, const char *file_name=__FILE__, const int line_number=__LINE__)
Resize data array and copy old data (2D)
Definition: cs_array.h:1989
CS_F_HOST void reshape(const cs_lnum_t size1, const cs_lnum_t size2, const cs_lnum_t size3, const char *file_name=__FILE__, const int line_number=__LINE__)
Resize data array 3D (no explicit copy, only realloc)
Definition: cs_array.h:2021
CS_F_HOST array(const cs_lnum_t(&dims)[N], cs_alloc_mode_t alloc_mode=cs_alloc_mode, const char *file_name=__FILE__, const int line_number=__LINE__)
Constructor method using dimensions.
Definition: cs_array.h:1276
CS_F_HOST_DEVICE array(T *data, const cs_lnum_t(&dims)[N])
Constructor method for non owner version in multidimensional.
Definition: cs_array.h:1452
CS_F_HOST void reshape_and_copy(const cs_lnum_t(&dims)[N], cs_lnum_t size_to_keep=-1, const char *file_name=__FILE__, const int line_number=__LINE__)
Resize data array and copy old data.
Definition: cs_array.h:1849
CS_F_HOST_DEVICE ~array()
Destructor method.
Definition: cs_array.h:1513
CS_F_HOST void reshape_and_copy(const cs_lnum_t size1, const cs_lnum_t size2, const cs_lnum_t size3, cs_lnum_t size_to_keep, const char *file_name=__FILE__, const int line_number=__LINE__)
Resize data array and copy old data (3D)
Definition: cs_array.h:2053
CS_F_HOST_DEVICE void set_empty()
Initializer method for empty containers.
Definition: cs_array.h:1695
CS_F_HOST_DEVICE bool owner() const
Getter function for owner status.
Definition: cs_array.h:2143
CS_F_HOST_DEVICE array(T *data, Args... indices)
Constructor method for non owner version.
Definition: cs_array.h:1426
CS_F_HOST_DEVICE friend void swap(array &first, array &second)
Class swap operator used for assignment or move.
Definition: cs_array.h:1527
CS_F_HOST void reshape_and_copy(const cs_lnum_t size1, const cs_lnum_t size2, const cs_lnum_t size3, const cs_lnum_t size4, cs_lnum_t size_to_keep, const char *file_name=__FILE__, const int line_number=__LINE__)
Resize data array and copy old data (4D)
Definition: cs_array.h:2086
Define a templated mdspan class (non owner of data)
Definition: cs_mdspan.h:68
CS_F_HOST void set_to_val(T val, const cs_lnum_t n_vals=-1)
Set all values of the data array to a constant value.
Definition: cs_mdspan.h:680
CS_F_HOST_DEVICE void set_size_(const cs_lnum_t(&dims)[N])
Set size of array based on dimensions.
Definition: cs_mdspan.h:1067
T * _data
Definition: cs_mdspan.h:1186
CS_F_HOST_DEVICE cs_lnum_t size() const
Getter for total size.
Definition: cs_mdspan.h:508
CS_F_HOST_DEVICE cs_lnum_t offset(int i) const
Getter for extent along a given dimension.
Definition: cs_mdspan.h:544
cs_lnum_t _size
Definition: cs_mdspan.h:1185
cs_lnum_t _extent[N]
Definition: cs_mdspan.h:1183
cs_lnum_t _offset[N]
Definition: cs_mdspan.h:1184
CS_F_HOST_DEVICE T * data() const
Getter for data raw pointer.
Definition: cs_mdspan.h:561
CS_F_HOST_DEVICE cs_lnum_t extent(int i) const
Getter for extent along a given dimension.
Definition: cs_mdspan.h:525
CS_F_HOST_DEVICE void set_data_ptr(T *data_ptr) const
Set data pointer.
Definition: cs_mdspan.h:454
auto parallel_for(cs_lnum_t n, F &&f, Args &&... args)
Definition: cs_dispatch.h:2146
void wait(void)
Wait (synchronize) until launched computations have finished.
Definition: cs_dispatch.h:2211
Definition: cs_dispatch.h:2288
void cs_array_real_fill_zero(cs_lnum_t size, cs_real_t a[])
Assign zero to all elements of an array.
Definition: cs_array.cpp:1015
void cs_array_real_set_wvalue(cs_lnum_t n_elts, int stride, const cs_real_t ref_val[], const cs_real_t weight[], cs_real_t a[])
Assign a weighted constant value of dim "stride" to an interlaced array sharing the same stride....
Definition: cs_array.cpp:598
void cs_array_real_set_scalar_on_subset(cs_lnum_t n_elts, const cs_lnum_t elt_ids[], cs_real_t ref_val, cs_real_t a[])
Assign a constant scalar value to an array on a selected subset of elements. If elt_ids is null,...
Definition: cs_array.cpp:762
void cs_array_set_value_real(cs_lnum_t n_elts, cs_lnum_t dim, cs_real_t v, cs_real_t a[])
Assign a constant value to an array (deprecated function).
Definition: cs_array.cpp:1041
void cs_array_bool_fill_false(cs_lnum_t size, bool a[])
Assign false to all elements of an array. Case of an array of booleans.
Definition: cs_array.cpp:102
void cs_arrays_set_zero(cs_dispatch_context &ctx, const cs_lnum_t n_elts, Arrays &&... arrays)
Assign zero value to all elements of multiple arrays.
Definition: cs_array.h:356
void cs_array_real_set_tensor(cs_lnum_t n_elts, const cs_real_t ref_tens[3][3], cs_real_t a[])
Assign a constant 3x3 tensor to an array (of stride 9) which is interlaced.
Definition: cs_array.cpp:946
void cs_array_int_fill_zero(cs_lnum_t size, int a[])
Assign zero to all elements of an array. Case of a int array.
Definition: cs_array.cpp:243
void cs_array_real_set_vector(cs_lnum_t n_elts, const cs_real_t ref_val[3], cs_real_t a[])
Assign a constant vector to an array of stride 3 which is interlaced.
Definition: cs_array.cpp:826
void cs_array_flag_fill_zero(cs_lnum_t size, cs_flag_t a[])
Assign zero to all elements of an array. Case of a cs_flag_t array.
Definition: cs_array.cpp:120
void cs_array_real_scale(cs_lnum_t n_elts, int stride, const cs_lnum_t *elt_ids, cs_real_t scaling_factor, cs_real_t dest[])
Multiply each value by a scaling factor s.t. dest *= scaling_factor If elt_ids is non-null,...
Definition: cs_array.cpp:485
void cs_arrays_set_value_on_subset(const cs_lnum_t n_elts, const cs_lnum_t *elt_ids, const T *ref_val, Arrays &&... arrays)
Assign values on a selected subset of elements to multiple arrays. ref_val is input as a pointer or a...
Definition: cs_array.h:415
void cs_array_difference(cs_lnum_t size, const T *x, const T *y, T *diff)
Compute the difference diff = x - y. All arrays have the same dimension.
Definition: cs_array.h:556
void cs_array_real_set_wvector_on_subset(cs_lnum_t n_elts, const cs_lnum_t elt_ids[], const cs_real_t ref_val[3], const cs_real_t weight[], cs_real_t a[])
Assign a weighted constant vector value to an interlaced array (of stride 3). The subset selection is...
Definition: cs_array.cpp:912
void cs_array_copy(const cs_lnum_t size, const T *src, T *dest)
Copy values from an array to another of the same dimensions.
Definition: cs_array.h:511
void cs_array_real_copy_subset(cs_lnum_t n_elts, int stride, const cs_lnum_t elt_ids[], int mode, const cs_real_t ref[], cs_real_t dest[])
Copy an array ("ref") into another array ("dest") on possibly only a part of the array(s)....
Definition: cs_array.cpp:332
void cs_array_lnum_fill_zero(cs_lnum_t size, cs_lnum_t a[])
Assign zero to all elements of an array. Case of a cs_lnum_t array.
Definition: cs_array.cpp:142
void cs_array_lnum_set_value_on_subset(cs_lnum_t n_elts, const cs_lnum_t elt_ids[], cs_lnum_t num, cs_lnum_t a[])
Assign the value "num" to an array on a selected subset of elements. if elt_ids is null,...
Definition: cs_array.cpp:218
void cs_array_real_set_scalar(cs_lnum_t n_elts, cs_real_t ref_val, cs_real_t a[])
Assign a constant scalar value to an array.
Definition: cs_array.cpp:716
void cs_array_bool_fill_true(cs_lnum_t size, bool a[])
Assign true to all elements of an array. Case of an array of booleans.
Definition: cs_array.cpp:84
void cs_array_real_set_vector_on_subset(cs_lnum_t n_elts, const cs_lnum_t elt_ids[], const cs_real_t ref_val[3], cs_real_t a[])
Assign a constant vector to an interlaced array (of stride 3) on a selected subset of elements....
Definition: cs_array.cpp:877
void cs_array_real_set_value_on_subset(cs_lnum_t n_elts, int stride, const cs_lnum_t elt_ids[], const cs_real_t ref_val[], cs_real_t a[])
Assign a constant value of dim "stride" to an interlaced array sharing the same stride....
Definition: cs_array.cpp:637
void cs_array_real_padd(cs_lnum_t n_elts, const cs_real_t l_add[], cs_real_t r[])
Add in place an array s.t. r += l_add.
Definition: cs_array.cpp:537
void cs_array_lnum_copy(cs_lnum_t size, const cs_lnum_t src[], cs_lnum_t dest[])
Copy values from an array of cs_lnum_t type to another of the same dimensions.
Definition: cs_array.cpp:166
void cs_array_real_copy(cs_lnum_t size, const cs_real_t src[], cs_real_t dest[])
Copy real values from an array to another of the same dimensions.
Definition: cs_array.cpp:453
void cs_array_int_set_value(cs_lnum_t size, int num, int a[])
Assign the value "num" to all elements of an array. Case of a int array.
Definition: cs_array.cpp:267
void cs_array_real_set_value(cs_lnum_t n_elts, int stride, const cs_real_t ref_val[], cs_real_t a[])
Assign a constant value of dim "stride" to an interlaced array sharing the same stride.
Definition: cs_array.cpp:563
void cs_arrays_set_value(const cs_lnum_t n_elts, const T *ref_val, Arrays &&... arrays)
Assign values to all elements of multiple arrays. ref_val is input as a pointer or an array.
Definition: cs_array.h:108
void cs_array_real_set_wscalar_on_subset(cs_lnum_t n_elts, const cs_lnum_t elt_ids[], cs_real_t ref_val, const cs_real_t weight[], cs_real_t a[])
Assign a weighted constant scalar value to an array on a selected subset of elements....
Definition: cs_array.cpp:795
void cs_array_real_set_tensor_on_subset(cs_lnum_t n_elts, const cs_lnum_t elt_ids[], const cs_real_t ref_tens[3][3], cs_real_t a[])
Assign a constant 3x3 tensor to an interlaced array (of stride 9) on a subset of elements....
Definition: cs_array.cpp:981
void cs_array_real_set_wvector(cs_lnum_t n_elts, const cs_real_t ref_val[3], const cs_real_t weight[], cs_real_t a[])
Assign a weighted constant vector value to an interlaced array (of stride 3). The array of weights ha...
Definition: cs_array.cpp:850
void cs_array_lnum_set_value(cs_lnum_t size, cs_lnum_t num, cs_lnum_t a[])
Assign the value "num" to all elements of an array. Case of a cs_lnum_t array.
Definition: cs_array.cpp:195
void cs_array_real_set_wvalue_on_subset(cs_lnum_t n_elts, int stride, const cs_lnum_t elt_ids[], const cs_real_t ref_val[], const cs_real_t weight[], cs_real_t a[])
Assign a weighted constant value of dim "stride" to an interlaced array sharing the same stride....
Definition: cs_array.cpp:678
void cs_array_int_set_value_on_subset(cs_lnum_t n_elts, const cs_lnum_t elt_ids[], int num, int a[])
Assign the value "num" to an array on a selected subset of elements. if elt_ids is null,...
Definition: cs_array.cpp:290
void cs_array_real_set_wscalar(cs_lnum_t n_elts, cs_real_t ref_val, const cs_real_t weight[], cs_real_t a[])
Assign a weighted constant scalar value to an array. The weight array has the same size as the array ...
Definition: cs_array.cpp:738
void * cs_stream_t
Definition: cs_defs.h:135
#define CS_F_HOST_DEVICE
Definition: cs_defs.h:555
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
#define _(String)
Definition: cs_defs.h:61
#define __has_builtin(x)
Definition: cs_defs.h:268
#define CS_LAMBDA
Definition: cs_defs.h:564
#define CS_THR_MIN
Definition: cs_defs.h:483
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
unsigned short int cs_flag_t
Definition: cs_defs.h:334
#define CS_F_HOST
Definition: cs_defs.h:553
@ k
Definition: cs_field_pointer.h:68
#define CS_FREE(_ptr)
Definition: cs_mem.h:151
#define cs_alloc_mode
Definition: cs_mem.h:183
cs_alloc_mode_t cs_check_device_ptr(const void *ptr)
Check if a pointer is associated with a device.
Definition: cs_mem.h:727
cs_alloc_mode_t
Definition: cs_mem.h:46
@ CS_ALLOC_HOST
Definition: cs_mem.h:48
@ CS_ALLOC_HOST_DEVICE_SHARED
Definition: cs_mem.h:53
static int cs_parall_n_threads(cs_lnum_t n_elements, cs_lnum_t min_thread_elements)
Compute recommended number of threads for a section.
Definition: cs_parall.h:549
cs_dispatch_context & default_context(void)
Definition: cs_execution_context.cpp:62
Definition: cs_algorithm.h:51
layout
Definition: cs_mdspan.h:51
CS_F_HOST_DEVICE constexpr std::enable_if_t< std::is_move_constructible< T >::value &&std::is_move_assignable< T >::value > swap_objects(T &obj1, T &obj2)
A swap method which is callable from GPU and not only CPU.
Definition: cs_defs.h:814
Utility template to check if a pack of parameters is made of integral types.
Definition: cs_defs.h:775