HIP: Heterogenous-computing Interface for Portability
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Classes | Macros | Enumerations | Functions | Variables
hip_hcc.cpp File Reference
#include <assert.h>
#include <stdint.h>
#include <iostream>
#include <list>
#include <sys/types.h>
#include <unistd.h>
#include <hc.hpp>
#include <hc_am.hpp>
#include "hip_runtime.h"
#include "hsa_ext_amd.h"

Classes

struct  ihipStream_t
 
struct  ihipEvent_t
 
struct  ihipDevice_t
 

Macros

#define USE_PINNED_HOST   (__hcc_workweek__ >= 1601)
 
#define INLINE   static inline
 
#define TRACE_API   0x1 /* trace API calls and return values */
 
#define TRACE_SYNC   0x2 /* trace synchronization pieces */
 
#define TRACE_MEM   0x4 /* trace memory allocation / deallocation */
 
#define tprintf(trace_level,...)
 
#define DeviceErrorCheck(x)   if (x != HSA_STATUS_SUCCESS) { return hipErrorInvalidDevice; }
 
#define ErrorCheck(x)   error_check(x, __LINE__, __FILE__)
 
#define ihipLogStatus(_hip_status)
 
#define READ_ENV_I(_build, _ENV_VAR, _ENV_VAR2, _description)
 

Enumerations

enum  ihipCommand_t { ihipCommandKernel, ihipCommandData }
 
enum  hipEventStatus_t { hipEventStatusUnitialized = 0, hipEventStatusCreated = 1, hipEventStatusRecording = 2, hipEventStatusRecorded = 3 }
 

Functions

void error_check (hsa_status_t hsa_error_code, int line_num, std::string str)
 
hsa_status_t get_region_info (hsa_region_t region, void *data)
 
void ihipReadEnv_I (int *var_ptr, const char *var_name1, const char *var_name2, const char *description)
 
void ihipInit ()
 
INLINE bool ihipIsValidDevice (unsigned deviceIndex)
 
INLINE ihipDevice_tihipGetTlsDefaultDevice ()
 
INLINE ihipDevice_tihipGetDevice (int deviceId)
 
void ihipWaitNullStream (ihipDevice_t *device)
 
hipStream_t ihipSyncAndResolveStream (hipStream_t stream)
 
bool ihipCheckCommandSwitchSync (hipStream_t stream, ihipCommand_t new_command, hc::completion_future *marker)
 
hc::accelerator_view * ihipLaunchKernel (hipStream_t stream)
 
hipError_t hipGetDevice (int *device)
 Return the default device id for the calling host thread. More...
 
hipError_t hipGetDeviceCount (int *count)
 Return number of compute-capable devices. More...
 
hipError_t hipDeviceSetCacheConfig (hipFuncCache cacheConfig)
 Set L1/Shared cache partition. More...
 
hipError_t hipDeviceGetCacheConfig (hipFuncCache *cacheConfig)
 Set Cache configuration for a specific function. More...
 
hipError_t hipFuncSetCacheConfig (hipFuncCache cacheConfig)
 Set Cache configuration for a specific function. More...
 
hipError_t hipDeviceSetSharedMemConfig (hipSharedMemConfig config)
 Set Shared memory bank configuration. More...
 
hipError_t hipDeviceGetSharedMemConfig (hipSharedMemConfig *pConfig)
 Get Shared memory bank configuration. More...
 
hipError_t hipSetDevice (int device)
 Set default device to be used for subsequent hip API calls from this thread. More...
 
hipError_t hipDeviceSynchronize (void)
 Blocks until the default device has completed all preceding requested tasks. More...
 
hipError_t hipDeviceReset (void)
 Destroy all resources and reset all state on the default device in the current process. More...
 
hipError_t hipDeviceGetProperties (hipDeviceProp_t *props, int device)
 Returns device properties. More...
 
hipError_t hipGetLastError ()
 Return last error returned by any HIP runtime API call and resets the stored error code to hipSuccess. More...
 
hipError_t hipPeakAtLastError ()
 
const char * hipGetErrorName (hipError_t hip_error)
 Return name of the specified error code in text form. More...
 
const char * hipGetErrorString (hipError_t hip_error)
 Return handy text string message to explain the error which occurred. More...
 
hipError_t hipStreamCreateWithFlags (hipStream_t *stream, unsigned int flags)
 Create an asynchronous stream. More...
 
hipError_t hipStreamWaitEvent (hipStream_t stream, hipEvent_t event, unsigned int flags)
 Make the specified compute stream wait for an event. More...
 
hipError_t hipStreamSynchronize (hipStream_t stream)
 Wait for all commands in stream to complete. More...
 
hipError_t hipStreamDestroy (hipStream_t stream)
 Destroys the specified stream. More...
 
hipError_t hipStreamGetFlags (hipStream_t stream, unsigned int *flags)
 Return flags associated with this stream. More...
 
hipError_t hipEventCreateWithFlags (hipEvent_t *event, unsigned flags)
 Create an event with the specified flags. More...
 
hipError_t hipEventRecord (hipEvent_t event, hipStream_t stream)
 Record an event in the specified stream. More...
 
hipError_t hipEventDestroy (hipEvent_t event)
 Destroy the specified event. More...
 
hipError_t hipEventSynchronize (hipEvent_t event)
 : Wait for an event to complete. More...
 
void ihipSetTs (hipEvent_t e)
 
hipError_t hipEventElapsedTime (float *ms, hipEvent_t start, hipEvent_t stop)
 Return the elapsed time between two events. More...
 
hipError_t hipEventQuery (hipEvent_t event)
 Query event status. More...
 
template<typename T >
hc::completion_future ihipMemcpyKernel (hipStream_t stream, T *c, const T *a, size_t sizeBytes)
 
template<typename T >
hc::completion_future ihipMemsetKernel (hipStream_t stream, T *ptr, T val, size_t sizeBytes)
 
hipError_t hipMalloc (void **ptr, size_t sizeBytes)
 
hipError_t hipMallocHost (void **ptr, size_t sizeBytes)
 
hipError_t hipMemcpyToSymbol (const char *symbolName, const void *src, size_t count, size_t offset, hipMemcpyKind kind)
 
hipError_t hipMemcpy (void *dst, const void *src, size_t sizeBytes, hipMemcpyKind kind)
 
hipError_t hipMemcpyAsync (void *dst, const void *src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream)
 
hipError_t hipMemsetAsync (void *dst, int value, size_t sizeBytes, hipStream_t stream)
 
hipError_t hipMemset (void *dst, int value, size_t sizeBytes)
 
hipError_t hipMemGetInfo (size_t *free, size_t *total)
 
hipError_t hipFree (void *ptr)
 
hipError_t hipFreeHost (void *ptr)
 
hipError_t hipDeviceCanAccessPeer (int *canAccessPeer, int device, int peerDevice)
 Determine if a device can access a peer's memory. More...
 
hipError_t hipDeviceDisablePeerAccess (int peerDevice)
 
hipError_t hipDeviceEnablePeerAccess (int peerDevice, unsigned int flags)
 
hipError_t hipMemcpyPeer (void *dst, int dstDevice, const void *src, int srcDevice, size_t sizeBytes)
 
hipError_t hipMemcpyPeerAsync (void *dst, int dstDevice, const void *src, int srcDevice, size_t sizeBytes, hipStream_t stream)
 
hipError_t hipDriverGetVersion (int *driverVersion)
 Returns the approximate HIP driver versin. More...
 
hipError_t hipHccGetAccelerator (int deviceId, hc::accelerator *acc)
 Return hc::acclerator associated with the specified deviceId. More...
 
hipError_t hipHccGetAcceleratorView (hipStream_t stream, hc::accelerator_view **av)
 Return hc::acclerator_view associated with the specified stream. More...
 

Variables

int warpSize = 64
 
int HIP_PRINT_ENV = 0
 Print all HIP-related environment variables.
 
int HIP_TRACE_API = 0
 Trace HIP APIs.
 
int HIP_LAUNCH_BLOCKING = 0
 Make all HIP APIs host-synchronous.
 
const hipStream_t hipStreamNull = 0x0
 
thread_local hipError_t tls_lastHipError = hipSuccess
 
thread_local int tls_defaultDevice = 0
 
std::once_flag hip_initialized
 
std::vector< ihipDevice_tg_devices
 

Detailed Description

Contains definitions for functions that are large enough that we don't want to inline them everywhere. This file is compiled and linked into apps running HIP / HCC path.

Macro Definition Documentation

#define ihipLogStatus (   _hip_status)
Value:
({\
tls_lastHipError = _hip_status;\
\
if (HIP_TRACE_API & TRACE_API) {\
fprintf(stderr, "hiptrace1: %-30s ret=%2d\n", __func__, _hip_status);\
}\
_hip_status;\
})
int HIP_TRACE_API
Trace HIP APIs.
Definition: hip_hcc.cpp:57
#define READ_ENV_I (   _build,
  _ENV_VAR,
  _ENV_VAR2,
  _description 
)
Value:
if (_build == release) {\
ihipReadEnv_I(&_ENV_VAR, #_ENV_VAR, #_ENV_VAR2, _description);\
};
#define tprintf (   trace_level,
  ... 
)
Value:
{\
if (HIP_TRACE_API & trace_level) {\
fprintf (stderr, "hiptrace%d: ", trace_level); \
fprintf (stderr, __VA_ARGS__);\
}\
}
int HIP_TRACE_API
Trace HIP APIs.
Definition: hip_hcc.cpp:57