• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef TESTS_UT_STUB_RUNTIME_INCLUDE_CUDA_H_
17 #define TESTS_UT_STUB_RUNTIME_INCLUDE_CUDA_H_
18 
19 typedef enum cudaError_enum {
20   CUDA_SUCCESS = 0,
21   CUDA_ERROR_INVALID_IMAGE = 1,
22   CUDA_ERROR_DEINITIALIZED = 2,
23 } CUresult;
24 
25 typedef enum CUjit_option_enum {
26   CU_JIT_MAX_REGISTERS = 0,
27   CU_JIT_THREADS_PER_BLOCK,
28   CU_JIT_WALL_TIME,
29   CU_JIT_INFO_LOG_BUFFER,
30   CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES,
31   CU_JIT_ERROR_LOG_BUFFER,
32   CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES,
33   CU_JIT_OPTIMIZATION_LEVEL,
34   CU_JIT_TARGET_FROM_CUCONTEXT,
35   CU_JIT_TARGET,
36   CU_JIT_FALLBACK_STRATEGY,
37   CU_JIT_GENERATE_DEBUG_INFO,
38   CU_JIT_LOG_VERBOSE,
39   CU_JIT_GENERATE_LINE_INFO,
40   CU_JIT_CACHE_MODE,
41   CU_JIT_NEW_SM3X_OPT,
42   CU_JIT_FAST_COMPILE,
43   CU_JIT_GLOBAL_SYMBOL_NAMES,
44   CU_JIT_GLOBAL_SYMBOL_ADDRESSES,
45   CU_JIT_GLOBAL_SYMBOL_COUNT,
46   CU_JIT_NUM_OPTIONS
47 } CUjit_option;
48 
49 typedef enum CUdevice_attribute_enum {
50   CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR,
51   CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR,
52 } CUdevice_attribute;
53 
54 struct CUctx_st {
55   int arch;
56 };
57 struct CUmod_st {
58   int arch;
59 };
60 struct CUfunc_st {
61   int arch;
62 };
63 struct CUstream_st {
64   int arch;
65 };
66 
67 typedef struct CUctx_st *CUcontext;
68 typedef struct CUmod_st *CUmodule;
69 typedef struct CUfunc_st *CUfunction;
70 typedef struct CUstream_st *CUstream;
71 
72 CUresult cuModuleLoadData(CUmodule *module, const void *image);
73 CUresult cuModuleLoadDataEx(CUmodule *module, const void *image, unsigned int numOptions, CUjit_option *options,
74                             void **optionValues);
75 CUresult cuModuleGetFunction(CUfunction *hfunc, CUmodule hmod, const char *name);
76 CUresult cuLaunchKernel(CUfunction f, unsigned int gridDimX, unsigned int gridDimY, unsigned int gridDimZ,
77                         unsigned int blockDimX, unsigned int blockDimY, unsigned int blockDimZ,
78                         unsigned int sharedMemBytes, CUstream hStream, void **kernelParams, void **extra);
79 CUresult cuModuleUnload(CUmodule hmod);
80 CUresult cuGetErrorName(CUresult error, const char **pStr);
81 CUresult cuDeviceGetAttribute(int *pi, CUdevice_attribute attrib, int dev);
82 #endif  // TESTS_UT_STUB_RUNTIME_INCLUDE_CUDA_H_
83