fml  0.1-0
Fused Matrix Library
gpuprims.hh
1 // This file is part of fml which is released under the Boost Software
2 // License, Version 1.0. See accompanying file LICENSE or copy at
3 // https://www.boost.org/LICENSE_1_0.txt
4 
5 #ifndef FML_GPU_ARCH_HIP_GPUPRIMS_H
6 #define FML_GPU_ARCH_HIP_GPUPRIMS_H
7 #pragma once
8 
9 
10 #include <rocblas.h>
11 #include <rocsolver.h>
12 
13 
14 namespace fml
15 {
16  namespace gpuprims
17  {
18  // device management
19  inline hipError_t gpu_set_device(int device)
20  {
21  return hipSetDevice(device);
22  }
23 
24  inline hipError_t gpu_synch()
25  {
26  return hipDeviceSynchronize();
27  }
28 
29  inline hipError_t gpu_device_reset()
30  {
31  return hipDeviceReset();
32  }
33 
34 
35 
36  // memory management
37  inline hipError_t gpu_malloc(void **x, size_t size)
38  {
39  return hipMalloc(x, size);
40  }
41 
42  inline hipError_t gpu_memset(void *x, int value, size_t count)
43  {
44  return hipMemset(x, value, count);
45  }
46 
47  inline hipError_t gpu_free(void *x)
48  {
49  return hipFree(x);
50  }
51 
52  inline hipError_t gpu_memcpy(void *dst, const void *src, size_t count, hipMemcpyKind kind)
53  {
54  return hipMemcpy(dst, src, count, kind);
55  }
56 
57 
58 
59  // error handling
60  inline std::string gpu_error_string(hipError_t code)
61  {
62  return hipGetErrorString(code);
63  }
64 
65  inline hipError_t gpu_last_error()
66  {
67  return hipGetLastError();
68  }
69 
70 
71 
72  // rocblas and rocsolver
73  inline rocblas_status gpu_blas_init(rocblas_handle *handle)
74  {
75  return rocblas_create_handle(handle);
76  }
77 
78  inline rocblas_status gpu_blas_free(rocblas_handle handle)
79  {
80  return rocblas_destroy_handle(handle);
81  }
82 
83  inline rocsolver_status gpu_lapack_init(rocsolver_handle *handle)
84  {
85  return rocsolver_create_handle(handle);
86  }
87 
88  inline rocsolver_status gpu_lapack_free(rocsolver_handle handle)
89  {
90  return rocsolver_destroy_handle(handle);
91  }
92  }
93 }
94 
95 
96 #endif
fml
Core namespace.
Definition: dimops.hh:10