EddyCudaHelperFunctions.h 1.63 KB
Newer Older
wangkx1's avatar
init  
wangkx1 committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/////////////////////////////////////////////////////////////////////
///
/// \file EddyCudaHelperFunctions.h
/// \brief Declarations of some low level helper functions for eddy 
/// CUDA code.
///
/// \author Jesper Andersson
/// \version 1.0b, Nov., 2020.
/// \Copyright (C) 2020 University of Oxford 
///
/////////////////////////////////////////////////////////////////////

#ifndef EddyCudaHelperFunctions_h
#define EddyCudaHelperFunctions_h

#include "hipblas.h"
#include <string>
#include <sstream>
#include <hip/hip_runtime.h>

namespace EDDY {

/////////////////////////////////////////////////////////////////////
///
/// \brief This class contains a set of static methods that implement
/// various CUDA utility functions for the eddy project.
///
/////////////////////////////////////////////////////////////////////
class EddyCudaHelperFunctions
{
public:
  /// Does a little song and dance to initialize GPU
  static void InitGpu(bool verbose=true);

 /// Returns a formatted string with info about a hipError_t code
  static std::string cudaError2String(const hipError_t& ce);

  /// Waits for GPU to finish and checks error status
  static void CudaSync(const std::string& msg);

  /// Returns name of error associated with cs
  static std::string cuBLASGetErrorName(const hipblasStatus_t& cs);  

  /// Returns explanatory string for error associated with cs
  static std::string cuBLASGetErrorString(const hipblasStatus_t& cs);  

  /// Returns a formatted string with info about a hipblasStatus_t code
  static std::string cublasError2String(const hipblasStatus_t& ce);  
};

} // End namespace EDDY

#endif // End #ifndef EddyCudaHelperFunctions_h