Add initial context implementation.

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

Change-Id: If1cb9989b5a04a36147e25e84904336c7b6f3d88
Tá an tiomantas seo le fáil i:
Ben Sander tiomanta 2016-08-08 17:49:02 -05:00
1 tuismitheoir ac173c3ae8
tiomantas f19f2248bf
9 comhad athraithe
+201 -36

Níor tháinig aon chomhaid le do chuardach

+9 -1
Féach ar an gComhad
@@ -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
Féach ar an gComhad
@@ -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.
*