From ad88810e128bf81426fd9167ac7565af931e85aa Mon Sep 17 00:00:00 2001 From: Wesley Maxey <71408887+wmaxey@users.noreply.github.com> Date: Tue, 19 Mar 2024 11:39:26 -0700 Subject: [PATCH] Fix usage of naked array with 0 elements in sm90 barrier tests. (#1546) (#1549) --- .../cuda/barrier/cp_async_bulk_tensor_generic.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libcudacxx/test/libcudacxx/cuda/barrier/cp_async_bulk_tensor_generic.h b/libcudacxx/test/libcudacxx/cuda/barrier/cp_async_bulk_tensor_generic.h index f5340c47950..31f75e20a91 100644 --- a/libcudacxx/test/libcudacxx/cuda/barrier/cp_async_bulk_tensor_generic.h +++ b/libcudacxx/test/libcudacxx/cuda/barrier/cp_async_bulk_tensor_generic.h @@ -216,17 +216,18 @@ CUtensorMap map_encode(T *tensor_ptr, const cuda::std::array // The stride is the number of bytes to traverse from the first element of one row to the next. // It must be a multiple of 16. - uint64_t stride[num_dims - 1]; + constexpr int num_strides = num_dims - 1; + cuda::std::array stride; uint64_t base_stride = sizeof(T); - for (size_t i = 0; i < num_dims - 1; ++i) { + for (size_t i = 0; i < stride.size(); ++i) { base_stride *= gmem_dims[i]; stride[i] = base_stride; } // The distance between elements in units of sizeof(element). A stride of 2 // can be used to load only the real component of a complex-valued tensor, for instance. - uint32_t elem_stride[num_dims]; // = {1, .., 1}; - for (size_t i = 0; i < num_dims; ++i) { + cuda::std::array elem_stride; // = {1, .., 1}; + for (size_t i = 0; i < elem_stride.size(); ++i) { elem_stride[i] = 1; } @@ -240,9 +241,9 @@ CUtensorMap map_encode(T *tensor_ptr, const cuda::std::array num_dims, // cuuint32_t tensorRank, tensor_ptr, // void *globalAddress, gmem_dims.data(), // const cuuint64_t *globalDim, - stride, // const cuuint64_t *globalStrides, + stride.data(), // const cuuint64_t *globalStrides, smem_dims.data(), // const cuuint32_t *boxDim, - elem_stride, // const cuuint32_t *elementStrides, + elem_stride.data(), // const cuuint32_t *elementStrides, CUtensorMapInterleave::CU_TENSOR_MAP_INTERLEAVE_NONE, CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_NONE, CUtensorMapL2promotion::CU_TENSOR_MAP_L2_PROMOTION_NONE,