Add initial context implementation.

APIs: hipInit, hipCtxCreate.
Track TLS default ctx.  Set deviceID now changes the ctx.
Add first context test.

Change-Id: If1cb9989b5a04a36147e25e84904336c7b6f3d88
This commit is contained in:
Ben Sander
2016-08-08 17:49:02 -05:00
parent ed0a2c02fe
commit 8f402132ba
9 ha cambiato i file con 201 aggiunte e 36 eliminazioni
+9 -1
Vedi File
@@ -66,8 +66,16 @@ extern int HIP_VISIBLE_DEVICES; /* Contains a comma-separated sequence of GPU id
extern int HIP_DISABLE_HW_KERNEL_DEP;
extern int HIP_DISABLE_HW_COPY_DEP;
extern thread_local int tls_defaultDevice;
//---
//Extern tls
extern thread_local int tls_defaultDeviceId;
extern thread_local ihipCtx_t *tls_defaultCtx;
extern thread_local hipError_t tls_lastHipError;
//---
//Forward defs:
class ihipStream_t;
class ihipDevice_t;
class ihipCtx_t;
+23 -4
Vedi File
@@ -43,7 +43,13 @@ THE SOFTWARE.
extern "C" {
#endif
typedef struct ihipCtx_t hipCtx_t;
//---
//API-visible structures
typedef struct ihipCtx_t *hipCtx_t;
// Note many APIs also use integer deviceIds as an alternative to the device pointer:
typedef struct ihipDevice_t *hipDevice_t;
typedef struct ihipStream_t *hipStream_t;
typedef struct hipEvent_t {
struct ihipEvent_t *_handle;
@@ -1023,16 +1029,29 @@ hipError_t hipMemcpyPeerAsync(void* dst, int dstDevice, const void* src, int src
* @}
*/
/**
*-------------------------------------------------------------------------------------------------
*-------------------------------------------------------------------------------------------------
* @defgroup Version Management
* @defgroup Driver Initialization and Version
* @{
*
*/
/**
* @brief Explicitly initializes the HIP runtime.
*
* Most HIP APIs implicitly initialize the HIP runtime.
* This API provides control over the timing of the initialization.
*/
// TODO-ctx - more description on error codes.
hipError_t hipInit(unsigned int flags) ;
// TODO-ctx
hipError_t hipCtxCreate(hipCtx_t *ctx, unsigned int flags, hipDevice_t device);
/**
* @brief Returns the approximate HIP driver version.
*