| 1 |
/*========================== begin_copyright_notice ============================ |
| 2 |
|
| 3 |
Copyright (C) 2018-2021 Intel Corporation |
| 4 |
|
| 5 |
SPDX-License-Identifier: MIT |
| 6 |
|
| 7 |
============================= end_copyright_notice ===========================*/ |
| 8 |
|
| 9 |
#ifndef _GPTIN_OCL_INTERFACE_ |
| 10 |
#define _GPTIN_OCL_INTERFACE_ |
| 11 |
|
| 12 |
#include <stdint.h> |
| 13 |
#include "gtpin_driver_common_bti.h" |
| 14 |
|
| 15 |
namespace gtpin { |
| 16 |
namespace ocl { |
| 17 |
/*! |
| 18 |
* GTPin <-> OpenCL Driver Interface Changelog: |
| 19 |
* 2. File reordering |
| 20 |
* 1. IGC info added |
| 21 |
* 0. Official release of OpenCL support |
| 22 |
*/ |
| 23 |
// GTPin <-> OpenCL driver interface version |
| 24 |
static const uint8_t GTPIN_OCL_INTERNAL_INTERFACE_VERSION = 2; /// GTPIN INTERNAL VALUE |
| 25 |
static const uint16_t GTPIN_OCL_INTERFACE_VERSION = GENERATE_SPECIFIC_VERSION(GTPIN_OCL_INTERNAL_INTERFACE_VERSION); |
| 26 |
|
| 27 |
/************************************************************************/ |
| 28 |
/* General Comments: |
| 29 |
1. All memory management is done by the caller. |
| 30 |
The callee should not make any assumptions about the availability |
| 31 |
of the data out side the scope of the call. |
| 32 |
The callee must copy all data that will be used out side |
| 33 |
the scope of the call. |
| 34 |
*/ |
| 35 |
/************************************************************************/ |
| 36 |
|
| 37 |
/************************************************************************/ |
| 38 |
/* Events (Driver -> GTPin) */ |
| 39 |
/* The following functions are implemented by GTPin */ |
| 40 |
/* and called by the driver */ |
| 41 |
/************************************************************************/ |
| 42 |
|
| 43 |
/** |
| 44 |
Called up on a creation of a new Device by the application |
| 45 |
|
| 46 |
Params: |
| 47 |
(in) context - The context created. |
| 48 |
(in) platform_info - information about the platform |
| 49 |
(out) igc_init - IGC's initialization data |
| 50 |
*/ |
| 51 |
typedef void (*OnContextCreateFPTR)(device_handle_t handle, platform_info_t *platform_info, igc_init_t **igc_init); |
| 52 |
|
| 53 |
/** |
| 54 |
Called up on a destruction of the device |
| 55 |
|
| 56 |
Params: |
| 57 |
(in) context - The context been destroyed. |
| 58 |
**/ |
| 59 |
typedef void (*OnContextDestroyFPTR)(device_handle_t handle); |
| 60 |
|
| 61 |
/** |
| 62 |
Called on up the creation of a new shader by the application |
| 63 |
|
| 64 |
Params: |
| 65 |
(in) context - The handle of the context |
| 66 |
(in) params_in - All instrumentation parameters needed for GTPin's instrumentation |
| 67 |
(out) params_out - GTPin's instrumentation artifacts |
| 68 |
**/ |
| 69 |
typedef void (*OnKernelCreateFPTR)(device_handle_t handle, const instrument_params_in_t *params_in, |
| 70 |
instrument_params_out_t *params_out); |
| 71 |
|
| 72 |
/** |
| 73 |
Called up on applications call to the EnqueueNDRange API. |
| 74 |
The driver shall call this function for each shader in the pipeline (PS, VS, ...) |
| 75 |
and is submitted into the command buffer |
| 76 |
|
| 77 |
Params: |
| 78 |
(in) cb - Driver's internal command buffer handle |
| 79 |
(in) kernel_id - Kernel's id as assigned by GTPin in KernelCreate function |
| 80 |
(out) entry_offset - The entry point in the binary relative to the first instruction |
| 81 |
(out) resource - GTPin's resource for this kernel |
| 82 |
**/ |
| 83 |
typedef void (*OnKernelSubmitFPTR)(command_buffer_handle_t cb, uint64_t kernel_id, uint32_t *entry_offset, |
| 84 |
resource_handle_t *resource); |
| 85 |
|
| 86 |
/** |
| 87 |
Called up on the creation of driver's internal command buffer |
| 88 |
|
| 89 |
Params: |
| 90 |
(in) context - The handle of the context |
| 91 |
(in) cb - Driver's internal command buffer handle |
| 92 |
**/ |
| 93 |
typedef void (*OnCommandBufferCreateFPTR)(device_handle_t handle, command_buffer_handle_t cb); |
| 94 |
|
| 95 |
/** |
| 96 |
Called up on the submissions for execution driver's internal command buffer |
| 97 |
|
| 98 |
Params: |
| 99 |
(in) cb - Driver's internal command buffer handle |
| 100 |
(out) resource - GTPin's resource for polling on to identify command buffer completion |
| 101 |
**/ |
| 102 |
typedef void (*OnCommandBufferCompleteFPTR)(command_buffer_handle_t cb); |
| 103 |
|
| 104 |
/** |
| 105 |
Event structure: |
| 106 |
Holds the pointers for functions implemented by GTPin. |
| 107 |
Those function will be called by the Driver upon a corresponding events. |
| 108 |
*/ |
| 109 |
typedef struct gtpin_events_s { |
| 110 |
OnContextCreateFPTR onContextCreate; |
| 111 |
OnContextDestroyFPTR onContextDestroy; |
| 112 |
OnKernelCreateFPTR onKernelCreate; |
| 113 |
OnKernelSubmitFPTR onKernelSubmit; |
| 114 |
OnCommandBufferCreateFPTR onCommandBufferCreate; |
| 115 |
OnCommandBufferCompleteFPTR onCommandBufferComplete; |
| 116 |
|
| 117 |
} gtpin_events_t; |
| 118 |
|
| 119 |
/** |
| 120 |
Initialize GTPin events and driver services structures |
| 121 |
This is the entry point into the driver for GTPin and used for the handshake. |
| 122 |
|
| 123 |
This function must be: |
| 124 |
1. implemented with the name of GTPin_Init |
| 125 |
2. exported and visible outside the driver's image |
| 126 |
3. un-mangled with extern "C" |
| 127 |
|
| 128 |
Params: |
| 129 |
(in) gtpin_events - GTPin's events functions callbacks (if NULL ignored) |
| 130 |
(out) driver_services - Driver's services function callbacks (if NULL ignored) |
| 131 |
(out) driver_version - Driver's version of the interface (if NULL ignored) |
| 132 |
*/ |
| 133 |
|
| 134 |
// extern "C" |
| 135 |
// GTPIN_DI_STATUS GTPin_Init(gtpin::ocl::gtpin_events_t* gtpin_events, driver_services_t* driver_services, |
| 136 |
// interface_version_t* driver_version); |
| 137 |
|
| 138 |
} // namespace ocl |
| 139 |
} // namespace gtpin |
| 140 |
#endif |