HIP: Heterogenous-computing Interface for Portability
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
hip_runtime_api.h
1 /*
2 Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved.
3 
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10 
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
13 
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 THE SOFTWARE.
21 */
29 #pragma once
30 
31 
32 #include <string.h> // for getDeviceProp
33 #include <hip/hip_common.h>
34 
35 typedef struct {
36  // 32-bit Atomics
37  unsigned hasGlobalInt32Atomics : 1;
38  unsigned hasGlobalFloatAtomicExch : 1;
39  unsigned hasSharedInt32Atomics : 1;
40  unsigned hasSharedFloatAtomicExch : 1;
41  unsigned hasFloatAtomicAdd : 1;
42 
43  // 64-bit Atomics
44  unsigned hasGlobalInt64Atomics : 1;
45  unsigned hasSharedInt64Atomics : 1;
46 
47  // Doubles
48  unsigned hasDoubles : 1;
49 
50  // Warp cross-lane operations
51  unsigned hasWarpVote : 1;
52  unsigned hasWarpBallot : 1;
53  unsigned hasWarpShuffle : 1;
54  unsigned hasFunnelShift : 1;
55 
56  // Sync
57  unsigned hasThreadFenceSystem : 1;
58  unsigned hasSyncThreadsExt : 1;
59 
60  // Misc
61  unsigned hasSurfaceFuncs : 1;
62  unsigned has3dGrid : 1;
63  unsigned hasDynamicParallelism : 1;
65 
66 
67 //---
68 // Common headers for both NVCC and HCC paths:
69 
74 typedef struct hipDeviceProp_t {
75  char name[256];
76  size_t totalGlobalMem;
79  int warpSize;
81  int maxThreadsDim[3];
82  int maxGridSize[3];
83  int clockRate;
86  size_t totalConstMem;
87  int major;
88  int minor;
96  int pciBusID;
101  } hipDeviceProp_t;
102 
103 
107 enum hipMemoryType {
108  hipMemoryTypeHost,
109  hipMemoryTypeDevice
110 };
111 
112 
113 
117 typedef struct hipPointerAttribute_t {
118  enum hipMemoryType memoryType;
119  int device;
120  void *devicePointer;
121  void *hostPointer;
122  int isManaged;
123  unsigned allocationFlags; /* flags specified when memory was allocated*/
124  /* peers? */
126 
127 
128 // hack to get these to show up in Doxygen:
136 /*
137  asdasd* @brief hipError_t
138  * @enum
139  * @ingroup Enumerations
140  */
141 // Developer note - when updating these, update the hipErrorName and hipErrorString functions in NVCC and HCC paths
142 typedef enum hipError_t {
154 
165 } hipError_t;
166 
167 /*
168  * @brief hipDeviceAttribute_t
169  * @enum
170  * @ingroup Enumerations
171  */
172 typedef enum hipDeviceAttribute_t {
199 
204 #if defined(__HIP_PLATFORM_HCC__) && !defined (__HIP_PLATFORM_NVCC__)
205 #include "hip/hcc_detail/hip_runtime_api.h"
206 #elif defined(__HIP_PLATFORM_NVCC__) && !defined (__HIP_PLATFORM_HCC__)
207 #include "hip/nvcc_detail/hip_runtime_api.h"
208 #else
209 #error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__");
210 #endif
211 
212 
220 #ifdef __cplusplus
221 template<class T>
222 static inline hipError_t hipMalloc ( T** devPtr, size_t size)
223 {
224  return hipMalloc((void**)devPtr, size);
225 }
226 
227 // Provide an override to automatically typecast the pointer type from void**, and also provide a default for the flags.
228 template<class T>
229 static inline hipError_t hipHostMalloc( T** ptr, size_t size, unsigned int flags = hipHostMallocDefault)
230 {
231  return hipHostMalloc((void**)ptr, size, flags);
232 }
233 #endif
Call to hipGetDeviceCount returned 0 devices.
Definition: hip_runtime_api.h:155
size_t totalConstMem
Size of shared memory region (in bytes).
Definition: hip_runtime_api.h:86
Maximum Shared Memory Per Multiprocessor.
Definition: hip_runtime_api.h:196
Maximum x-dimension of a block.
Definition: hip_runtime_api.h:174
Maximum x-dimension of a grid.
Definition: hip_runtime_api.h:177
Peer access was already enabled from the current device.
Definition: hip_runtime_api.h:159
Unknown symbol.
Definition: hip_runtime_api.h:146
HSA runtime memory call returned error. Typically not seen in production systems. ...
Definition: hip_runtime_api.h:160
Global memory bus width in bits.
Definition: hip_runtime_api.h:186
Successful completion.
Definition: hip_runtime_api.h:143
int minor
Minor compute capability. On HCC, this is an approximation and features may differ from CUDA CC...
Definition: hip_runtime_api.h:88
int canMapHostMemory
Check whether HIP can map host memory.
Definition: hip_runtime_api.h:100
Maximum number of 32-bit registers available to a thread block. This number is shared by all thread b...
Definition: hip_runtime_api.h:183
int regsPerBlock
Registers per block.
Definition: hip_runtime_api.h:78
Size of L2 cache in bytes. 0 if the device doesn't have L2 cache.
Definition: hip_runtime_api.h:189
#define hipHostMallocDefault
Flags that can be used with hipHostMalloc.
Definition: hip_runtime_api.h:69
HSA runtime call other than memory returned error. Typically not seen in production systems...
Definition: hip_runtime_api.h:161
int isMultiGpuBoard
1 if device is on a multi-GPU board, 0 if not.
Definition: hip_runtime_api.h:99
DeviceID must be in range 0...#compute-devices.
Definition: hip_runtime_api.h:150
Peak clock frequency in kilohertz.
Definition: hip_runtime_api.h:184
Definition: hip_runtime_api.h:117
int clockRate
Max clock frequency of the multiProcessors in khz.
Definition: hip_runtime_api.h:83
Maximum z-dimension of a grid.
Definition: hip_runtime_api.h:179
Out of resources error.
Definition: hip_runtime_api.h:147
Minor compute capability version number.
Definition: hip_runtime_api.h:192
Maximum shared memory available per block in bytes.
Definition: hip_runtime_api.h:180
int pciBusID
PCI Bus ID.
Definition: hip_runtime_api.h:96
Maximum y-dimension of a grid.
Definition: hip_runtime_api.h:178
Multiple GPU devices.
Definition: hip_runtime_api.h:197
Unknown error.
Definition: hip_runtime_api.h:157
int maxThreadsPerBlock
Max work items per work group or workgroup max size.
Definition: hip_runtime_api.h:80
Maximum y-dimension of a block.
Definition: hip_runtime_api.h:175
hipError_t hipHostMalloc(void **ptr, size_t size, unsigned int flags)
Allocate device accessible page locked host memory.
Definition: hip_memory.cpp:148
size_t sharedMemPerBlock
Size of shared memory region (in bytes).
Definition: hip_runtime_api.h:77
int maxThreadsPerMultiProcessor
Maximum resident threads per multi-processor.
Definition: hip_runtime_api.h:91
Produced when trying to lock a page-locked memory.
Definition: hip_runtime_api.h:162
int l2CacheSize
L2 cache size.
Definition: hip_runtime_api.h:90
hipDeviceAttribute_t
Definition: hip_runtime_api.h:172
Major compute capability version number.
Definition: hip_runtime_api.h:191
Peer access was never enabled from the current device.
Definition: hip_runtime_api.h:158
Maximum number of threads per block.
Definition: hip_runtime_api.h:173
Resource handle (hipEvent_t or hipStream_t) invalid.
Definition: hip_runtime_api.h:149
Memory allocation error.
Definition: hip_runtime_api.h:144
hipDeviceArch_t arch
Architectural feature flags. New for HIP.
Definition: hip_runtime_api.h:94
int maxGridSize[3]
Max grid dimensions (XYZ).
Definition: hip_runtime_api.h:82
int computeMode
Compute mode.
Definition: hip_runtime_api.h:92
Maximum z-dimension of a block.
Definition: hip_runtime_api.h:176
PCI Bus ID.
Definition: hip_runtime_api.h:194
Invalid memory copy direction.
Definition: hip_runtime_api.h:151
Marker that more error codes are needed.
Definition: hip_runtime_api.h:164
Warp size in threads.
Definition: hip_runtime_api.h:182
int major
Major compute capability. On HCC, this is an approximation and features may differ from CUDA CC...
Definition: hip_runtime_api.h:87
Peak memory clock frequency in kilohertz.
Definition: hip_runtime_api.h:185
Maximum resident threads per multiprocessor.
Definition: hip_runtime_api.h:190
hipError_t
Definition: hip_runtime_api.h:142
int clockInstructionRate
Frequency in khz of the timer used by the device-side "clock*" instructions. New for HIP...
Definition: hip_runtime_api.h:93
Constant memory size in bytes.
Definition: hip_runtime_api.h:181
Memory free error.
Definition: hip_runtime_api.h:145
int warpSize
Warp size.
Definition: hip_runtime_api.h:79
int concurrentKernels
Device can possibly execute multiple kernels concurrently.
Definition: hip_runtime_api.h:95
size_t totalGlobalMem
Size of global memory region (in bytes).
Definition: hip_runtime_api.h:76
Invalid Device Pointer.
Definition: hip_runtime_api.h:152
hipError_t hipMalloc(void **ptr, size_t size)
Allocate memory on the default accelerator.
Definition: hip_memory.cpp:116
Compute mode that device is currently in.
Definition: hip_runtime_api.h:188
PCI Device ID.
Definition: hip_runtime_api.h:195
int maxThreadsDim[3]
Max number of threads in each dimension (XYZ) of a block.
Definition: hip_runtime_api.h:81
Number of multiprocessors on the device.
Definition: hip_runtime_api.h:187
int memoryBusWidth
Global memory bus width in bits.
Definition: hip_runtime_api.h:85
One or more of the parameters passed to the API call is NULL or not in an acceptable range...
Definition: hip_runtime_api.h:148
Definition: hip_runtime_api.h:74
Indicates that asynchronous operations enqueued earlier are not ready. This is not actually an error...
Definition: hip_runtime_api.h:156
size_t maxSharedMemoryPerMultiProcessor
Maximum Shared Memory Per Multiprocessor.
Definition: hip_runtime_api.h:98
int pciDeviceID
PCI Device ID.
Definition: hip_runtime_api.h:97
char name[256]
Device name.
Definition: hip_runtime_api.h:75
Produced when trying to unlock a non-page-locked memory.
Definition: hip_runtime_api.h:163
Definition: hip_runtime_api.h:35
int memoryClockRate
Max global memory clock frequency in khz.
Definition: hip_runtime_api.h:84
TODO comment from hipErrorInitializationError.
Definition: hip_runtime_api.h:153
Device can possibly execute multiple kernels concurrently.
Definition: hip_runtime_api.h:193
int multiProcessorCount
Number of multi-processors (compute units).
Definition: hip_runtime_api.h:89