fml  0.1-0
Fused Matrix Library
arch.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_ARCH_H
6 #define FML_GPU_ARCH_ARCH_H
7 #pragma once
8 
9 
10 #include <cstdarg>
11 
12 #if (!defined(FML_USE_CUDA) && !defined(FML_USE_HIP))
13  #define FML_USE_CUDA
14 #endif
15 
16 #if (!defined(FML_GPULAPACK_MAGMA))
17  #define FML_GPULAPACK_VENDOR
18 #endif
19 
20 
21 
22 // NOTE: include order matters with cusolver/cublas. cusolver MUST come first.
23 // something is wrong with their internals
24 #if defined(FML_GPULAPACK_MAGMA)
25  #error "MAGMA is currently unsupported"
26  // #include "gpulapack_magma.hh"
27 #else
28  #if defined(FML_USE_CUDA)
29  #include "cuda/gpulapack.hh"
30  #elif defined(FML_USE_HIP)
31  #error "HIP is currently unsupported"
32  // #include "hip/gpulapack.hh"
33  #else
34  #error "Unsupported GPU lapack"
35  #endif
36 #endif
37 
38 
39 
40 #if defined(FML_USE_CUDA)
41  #include "cuda/gpublas.hh"
42  #include "cuda/gpuprims.hh"
43  #include "cuda/gpurand.hh"
44  #include "cuda/nvml.hh"
45  #include "cuda/types.hh"
46 #elif defined(FML_USE_HIP)
47  #error "HIP is currently unsupported"
48  // #include "hip/gpublas.hh"
49  // #include "hip/gpuprims.hh"
50  // #include "hip/gpurand.hh"
51  // #include "hip/rocm_smi.hh"
52  // #include "hip/types.hh"
53 #else
54  #error "Unsupported kernel launcher"
55 #endif
56 
57 
58 
59 #if defined(FML_USE_CUDA)
60  #define FML_LAUNCH_KERNEL(FML_KERNEL, FML_GRIDSIZE, FML_BLOCKSIZE, ...) \
61  FML_KERNEL<<<FML_GRIDSIZE, FML_BLOCKSIZE>>>(__VA_ARGS__)
62 #elif defined(FML_USE_HIP)
63  #define FML_LAUNCH_KERNEL(FML_KERNEL, FML_GRIDSIZE, FML_BLOCKSIZE, ...) \
64  hipLaunchKernelGGL(FML_KERNEL, FML_GRIDSIZE, FML_BLOCKSIZE, 0, 0, __VA_ARGS__)
65 #else
66  #error "Unsupported kernel launcher"
67 #endif
68 
69 
70 #endif