Skip to content

Commit

Permalink
fix compilation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Meyer Andersen committed May 6, 2024
1 parent 1023ed3 commit 595f0fb
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
6 changes: 1 addition & 5 deletions opm/simulators/linalg/cuistl/detail/cuda_safe_call.hpp
Expand Up @@ -100,8 +100,6 @@ cudaSafeCall(cudaError_t error,
* @param functionName name of the function the error occured in (typically __func__)
* @param lineNumber the line number the error occured in (typically __LINE__)
*
* @return the error sent in (for convenience).
*
* Example usage:
* @code{.cpp}
* #include <opm/simulators/linalg/cuistl/detail/cuda_safe_call.hpp>
Expand All @@ -119,7 +117,7 @@ cudaSafeCall(cudaError_t error,
*
* @todo Refactor to use std::source_location once we shift to C++20
*/
inline cudaError_t
inline void
cudaWarnIfError(cudaError_t error,
const std::string_view& expression,
const std::string_view& filename,
Expand All @@ -129,8 +127,6 @@ cudaWarnIfError(cudaError_t error,
if (error != cudaSuccess) {
OpmLog::warning(getCudaErrorMessage(error, expression, filename, functionName, lineNumber));
}

return error;
}
} // namespace Opm::cuistl::detail

Expand Down
3 changes: 2 additions & 1 deletion opm/simulators/linalg/cuistl/detail/vector_operations.cu
Expand Up @@ -20,6 +20,7 @@
#include <opm/simulators/linalg/cuistl/detail/vector_operations.hpp>
#include <opm/simulators/linalg/cuistl/detail/cublas_safe_call.hpp>
#include <opm/simulators/linalg/cuistl/detail/cublas_wrapper.hpp>
#include <opm/simulators/linalg/cuistl/detail/cuda_safe_call.hpp>
#include <opm/simulators/linalg/cuistl/CuVector.hpp>
#include <stdexcept>
namespace Opm::cuistl::detail
Expand Down Expand Up @@ -160,7 +161,7 @@ template <class T>
void prepareSendBuf(const T* deviceA, T* buffer, size_t numberOfElements, const int* indices)
{
prepareSendBufKernel<<<getBlocks(numberOfElements), getThreads(numberOfElements)>>>(deviceA, buffer, numberOfElements, indices);
cudaDeviceSynchronize(); // The buffers are prepared for MPI. Wait for them to finish.
OPM_CUDA_SAFE_CALL(cudaDeviceSynchronize()); // The buffers are prepared for MPI. Wait for them to finish.
}
template void prepareSendBuf(const double* deviceA, double* buffer, size_t numberOfElements, const int* indices);
template void prepareSendBuf(const float* deviceA, float* buffer, size_t numberOfElements, const int* indices);
Expand Down
2 changes: 1 addition & 1 deletion opm/simulators/linalg/cuistl/set_device.cpp
Expand Up @@ -28,7 +28,7 @@ setDevice(int mpiRank, [[maybe_unused]] int numberOfMpiRanks)
{

int deviceCount = -1;
cudaGetDeviceCount(&deviceCount);
OPM_CUDA_SAFE_CALL(cudaGetDeviceCount(&deviceCount));

if (deviceCount <= 0) {
// If they have CUDA enabled (ie. using a component that needs CUDA, eg. cubicgstab or CUILU0), this will fail
Expand Down
3 changes: 2 additions & 1 deletion tests/cuistl/test_cuvector.cpp
Expand Up @@ -25,6 +25,7 @@
#include <dune/common/fvector.hh>
#include <dune/istl/bvector.hh>
#include <opm/simulators/linalg/cuistl/CuVector.hpp>
#include <opm/simulators/linalg/cuistl/detail/cuda_safe_call.hpp>
#include <random>

BOOST_AUTO_TEST_CASE(TestDocumentedUsage)
Expand Down Expand Up @@ -105,7 +106,7 @@ BOOST_AUTO_TEST_CASE(TestDataPointer)
auto vectorOnGPU = Opm::cuistl::CuVector<double>(data.data(), data.size());

std::vector<double> buffer(data.size(), 0.0);
cudaMemcpy(buffer.data(), vectorOnGPU.data(), sizeof(double) * data.size(), cudaMemcpyDeviceToHost);
OPM_CUDA_SAFE_CALL(cudaMemcpy(buffer.data(), vectorOnGPU.data(), sizeof(double) * data.size(), cudaMemcpyDeviceToHost));
BOOST_CHECK_EQUAL_COLLECTIONS(data.begin(), data.end(), buffer.begin(), buffer.end());
}

Expand Down

0 comments on commit 595f0fb

Please sign in to comment.