Skip to content

Commit

Permalink
Removed all the build warnings from the CUDA tests with MSVC.
Browse files Browse the repository at this point in the history
  • Loading branch information
krasznaa committed Sep 13, 2021
1 parent f0a8be7 commit ae7ce7f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion tests/core/test_core_contiguous_memory_resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ TEST_F(core_contiguous_memory_resource_test, allocations) {
EXPECT_EQ(static_cast<void*>(&*(vec5.begin())),
static_cast<void*>(&*(vec4.end())));

#endif // MSVC debug build...
#endif // MSVC debug build...
}
15 changes: 9 additions & 6 deletions tests/cuda/test_cuda_containers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ TEST_F(cuda_containers_test, explicit_memory) {

// Allocate a device memory block for the output container.
auto outputvechost = vecmem::get_data(outputvec);
vecmem::data::vector_buffer<int> outputvecdevice(outputvec.size(),
device_resource);
vecmem::data::vector_buffer<int> outputvecdevice(
static_cast<vecmem::data::vector_buffer<int>::size_type>(
outputvec.size()),
device_resource);

// Create the array that is used in the linear transformation.
vecmem::array<int, 2> constants(host_resource);
Expand Down Expand Up @@ -107,15 +109,15 @@ TEST_F(cuda_containers_test, atomic_memory) {
auto vec_on_device = m_copy.to(vecmem::get_data(vec), device_resource);

// Give it to the test function.
static constexpr int ITERATIONS = 100;
static constexpr unsigned int ITERATIONS = 100;
atomicTransform(ITERATIONS, vec_on_device);

// Copy it back to the host.
m_copy(vec_on_device, vec);

// Check the output.
for (int value : vec) {
EXPECT_EQ(value, 2 * ITERATIONS);
EXPECT_EQ(static_cast<unsigned int>(value), 2 * ITERATIONS);
}
}

Expand All @@ -134,8 +136,9 @@ TEST_F(cuda_containers_test, extendable_memory) {
}

// Create a buffer that will hold the filtered elements of the input vector.
vecmem::data::vector_buffer<int> output_buffer(input.size(), 0,
device_resource);
vecmem::data::vector_buffer<int> output_buffer(
static_cast<vecmem::data::vector_buffer<int>::size_type>(input.size()),
0, device_resource);
m_copy.setup(output_buffer);

// Run the filtering kernel.
Expand Down
8 changes: 4 additions & 4 deletions tests/cuda/test_cuda_containers_kernels.cu
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ __global__ void atomicTransformKernel(std::size_t iterations,
return;
}

void atomicTransform(std::size_t iterations,
void atomicTransform(unsigned int iterations,
vecmem::data::vector_view<int> vec) {

// Launch the kernel.
Expand Down Expand Up @@ -145,12 +145,12 @@ __global__ void filterTransformKernel(
}

void filterTransform(vecmem::data::jagged_vector_view<const int> input,
std::size_t max_vec_size,
unsigned int max_vec_size,
vecmem::data::jagged_vector_view<int> output) {

// Launch the kernel.
filterTransformKernel<<<1, dim3(input.m_size, max_vec_size)>>>(input,
output);
dim3 dimensions(static_cast<unsigned int>(input.m_size), max_vec_size);
filterTransformKernel<<<1, dimensions>>>(input, output);
// Check whether it succeeded to run.
VECMEM_CUDA_ERROR_CHECK(cudaGetLastError());
VECMEM_CUDA_ERROR_CHECK(cudaDeviceSynchronize());
Expand Down
4 changes: 2 additions & 2 deletions tests/cuda/test_cuda_containers_kernels.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void linearTransform(vecmem::data::vector_view<const int> constants,
vecmem::data::vector_view<int> output);

/// Function incrementing the elements of the received vector using atomics
void atomicTransform(std::size_t iterations,
void atomicTransform(unsigned int iterations,
vecmem::data::vector_view<int> vec);

/// Function filtering elements of an input vector into an output vector
Expand All @@ -29,5 +29,5 @@ void filterTransform(vecmem::data::vector_view<const int> input,

/// Function filtering elements of an input vector into an output vector
void filterTransform(vecmem::data::jagged_vector_view<const int> input,
std::size_t max_vec_size,
unsigned int max_vec_size,
vecmem::data::jagged_vector_view<int> output);
3 changes: 2 additions & 1 deletion tests/cuda/test_cuda_jagged_vector_view_kernels.cu
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ void linearTransform(const vecmem::data::vector_view<int>& constants,
assert(input.m_size == output.m_size);

// Launch the kernel.
linearTransformKernel<<<1, input.m_size>>>(constants, input, output);
linearTransformKernel<<<1, static_cast<unsigned int>(input.m_size)>>>(
constants, input, output);
// Check whether it succeeded to run.
VECMEM_CUDA_ERROR_CHECK(cudaGetLastError());
VECMEM_CUDA_ERROR_CHECK(cudaDeviceSynchronize());
Expand Down
5 changes: 3 additions & 2 deletions tests/cuda/test_cuda_memory_resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ class cuda_host_accessible_memory_resource_test

// Remove a couple of elements from the vectors.
for (int i : {26, 38, 25}) {
std::remove(reference_vector.begin(), reference_vector.end(), i);
std::remove(test_vector.begin(), test_vector.end(), i);
(void)std::remove(reference_vector.begin(), reference_vector.end(),
i);
(void)std::remove(test_vector.begin(), test_vector.end(), i);
}
// Make sure that they are still the same.
EXPECT_EQ(reference_vector.size(), test_vector.size());
Expand Down

0 comments on commit ae7ce7f

Please sign in to comment.