make style

This commit is contained in:
Philippe Teuwen 2021-01-14 11:39:45 +01:00
parent 2fbdada593
commit f2bc066858
33 changed files with 4734 additions and 5173 deletions

View file

@ -817,7 +817,7 @@ static int CmdConnect(const char *Cmd) {
int p_len = FILE_PATH_SIZE; int p_len = FILE_PATH_SIZE;
char port[FILE_PATH_SIZE] = {0}; char port[FILE_PATH_SIZE] = {0};
CLIGetStrWithReturn(ctx, 1, (uint8_t*)port, &p_len); CLIGetStrWithReturn(ctx, 1, (uint8_t *)port, &p_len);
uint32_t baudrate = arg_get_u32_def(ctx, 2, USART_BAUD_RATE); uint32_t baudrate = arg_get_u32_def(ctx, 2, USART_BAUD_RATE);
CLIParserFree(ctx); CLIParserFree(ctx);

View file

@ -81,10 +81,10 @@ static void print_usage_t55xx_downloadlink(uint8_t ShowAll, uint8_t dl_mode_defa
static void arg_add_t55xx_downloadlink(void *at[], uint8_t *idx, uint8_t show, uint8_t dl_mode_def) { static void arg_add_t55xx_downloadlink(void *at[], uint8_t *idx, uint8_t show, uint8_t dl_mode_def) {
char *r0 = (char*)calloc(56, sizeof(uint8_t)); char *r0 = (char *)calloc(56, sizeof(uint8_t));
char *r1 = (char*)calloc(56, sizeof(uint8_t)); char *r1 = (char *)calloc(56, sizeof(uint8_t));
char *r2 = (char*)calloc(56, sizeof(uint8_t)); char *r2 = (char *)calloc(56, sizeof(uint8_t));
char *r3 = (char*)calloc(56, sizeof(uint8_t)); char *r3 = (char *)calloc(56, sizeof(uint8_t));
sprintf(r0, "downlink - fixed bit length %s", (dl_mode_def == 0) ? "(detected def)" : ""); sprintf(r0, "downlink - fixed bit length %s", (dl_mode_def == 0) ? "(detected def)" : "");
sprintf(r1, "downlink - long leading reference %s", (dl_mode_def == 1) ? "(detected def)" : ""); sprintf(r1, "downlink - long leading reference %s", (dl_mode_def == 1) ? "(detected def)" : "");
@ -98,7 +98,7 @@ static void arg_add_t55xx_downloadlink(void *at[], uint8_t *idx, uint8_t show, u
at[n++] = arg_lit0(NULL, "r3", r3); at[n++] = arg_lit0(NULL, "r3", r3);
if (show == T55XX_DLMODE_ALL) { if (show == T55XX_DLMODE_ALL) {
char *r4 = (char*)calloc(50, sizeof(uint8_t)); char *r4 = (char *)calloc(50, sizeof(uint8_t));
sprintf(r4, "try all downlink modes %s", (dl_mode_def == 4) ? "(def)" : ""); sprintf(r4, "try all downlink modes %s", (dl_mode_def == 4) ? "(def)" : "");
at[n++] = arg_lit0(NULL, "all", r4); at[n++] = arg_lit0(NULL, "all", r4);
} }
@ -3565,7 +3565,7 @@ static int CmdT55xxDetectPage1(const char *Cmd) {
if (res == 2) { if (res == 2) {
PrintAndLogEx(INFO, "Password should be 4 hex bytes"); PrintAndLogEx(INFO, "Password should be 4 hex bytes");
return PM3_EINVARG; return PM3_EINVARG;
} else if ( res == 1) { } else if (res == 1) {
usepwd = true; usepwd = true;
} }
@ -3776,7 +3776,7 @@ static int CmdT55xxProtect(const char *Cmd) {
CLIParserFree(ctx); CLIParserFree(ctx);
PrintAndLogEx(FAILED, "Error parsing password bytes"); PrintAndLogEx(FAILED, "Error parsing password bytes");
return PM3_EINVARG; return PM3_EINVARG;
} else if ( res == 1) { } else if (res == 1) {
usepwd = true; usepwd = true;
override = 1; override = 1;
} }

View file

@ -733,7 +733,7 @@ static int CmdSmartSetClock(const char *Cmd) {
bool c4 = arg_get_lit(ctx, 3); bool c4 = arg_get_lit(ctx, 3);
CLIParserFree(ctx); CLIParserFree(ctx);
if ((c16 + c8 + c4) > 1 ) { if ((c16 + c8 + c4) > 1) {
PrintAndLogEx(WARNING, "Only one clock speed can be used at a time"); PrintAndLogEx(WARNING, "Only one clock speed can be used at a time");
return PM3_EINVARG; return PM3_EINVARG;
} }

View file

@ -119,7 +119,7 @@ static int CmdUsartConfig(const char *Cmd) {
bool po = arg_get_lit(ctx, 4); bool po = arg_get_lit(ctx, 4);
CLIParserFree(ctx); CLIParserFree(ctx);
if ((pn + pe + po) > 1 ) { if ((pn + pe + po) > 1) {
PrintAndLogEx(WARNING, "Only one parity can be used at a time"); PrintAndLogEx(WARNING, "Only one parity can be used at a time");
return PM3_EINVARG; return PM3_EINVARG;
} }
@ -361,7 +361,7 @@ static int CmdUsartBtPin(const char *Cmd) {
}; };
CLIExecWithReturn(ctx, Cmd, argtable, true); CLIExecWithReturn(ctx, Cmd, argtable, true);
int plen = 4; int plen = 4;
char pin[5] = { 0, 0 ,0, 0, 0 }; char pin[5] = { 0, 0, 0, 0, 0 };
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)pin, sizeof(pin), &plen); CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)pin, sizeof(pin), &plen);
CLIParserFree(ctx); CLIParserFree(ctx);

View file

@ -196,11 +196,11 @@ bool create_path(const char *dirname) {
} }
*/ */
bool setDefaultPath (savePaths_t pathIndex, const char *Path) { bool setDefaultPath(savePaths_t pathIndex, const char *Path) {
if (pathIndex < spItemCount) { if (pathIndex < spItemCount) {
if ((Path == NULL) && (session.defaultPaths[pathIndex] != NULL)) { if ((Path == NULL) && (session.defaultPaths[pathIndex] != NULL)) {
free (session.defaultPaths[pathIndex]); free(session.defaultPaths[pathIndex]);
session.defaultPaths[pathIndex] = NULL; session.defaultPaths[pathIndex] = NULL;
} }

View file

@ -78,7 +78,7 @@ typedef enum {
int fileExists(const char *filename); int fileExists(const char *filename);
//bool create_path(const char *dirname); //bool create_path(const char *dirname);
bool setDefaultPath (savePaths_t pathIndex,const char *Path); // set a path in the path list session.defaultPaths bool setDefaultPath(savePaths_t pathIndex, const char *Path); // set a path in the path list session.defaultPaths
char *newfilenamemcopy(const char *preferredName, const char *suffix); char *newfilenamemcopy(const char *preferredName, const char *suffix);

View file

@ -55,27 +55,27 @@ int preferences_load(void) {
session.show_hints = true; session.show_hints = true;
session.bar_mode = STYLE_VALUE; session.bar_mode = STYLE_VALUE;
setDefaultPath (spDefault, ""); setDefaultPath(spDefault, "");
setDefaultPath (spDump, ""); setDefaultPath(spDump, "");
setDefaultPath (spTrace, ""); setDefaultPath(spTrace, "");
// default save path // default save path
if (get_my_user_directory() != NULL) // should return path to .proxmark3 folder if (get_my_user_directory() != NULL) // should return path to .proxmark3 folder
setDefaultPath (spDefault, get_my_user_directory()); setDefaultPath(spDefault, get_my_user_directory());
else else
setDefaultPath (spDefault, "."); setDefaultPath(spDefault, ".");
// default dump path // default dump path
if (get_my_user_directory() != NULL) // should return path to .proxmark3 folder if (get_my_user_directory() != NULL) // should return path to .proxmark3 folder
setDefaultPath (spDump, get_my_user_directory()); setDefaultPath(spDump, get_my_user_directory());
else else
setDefaultPath (spDump, "."); setDefaultPath(spDump, ".");
// default dump path // default dump path
if (get_my_user_directory() != NULL) // should return path to .proxmark3 folder if (get_my_user_directory() != NULL) // should return path to .proxmark3 folder
setDefaultPath (spTrace, get_my_user_directory()); setDefaultPath(spTrace, get_my_user_directory());
else else
setDefaultPath (spTrace, "."); setDefaultPath(spTrace, ".");
if (session.incognito) { if (session.incognito) {
PrintAndLogEx(INFO, "No preferences file will be loaded"); PrintAndLogEx(INFO, "No preferences file will be loaded");
@ -262,15 +262,15 @@ void preferences_load_callback(json_t *root) {
// default save path // default save path
if (json_unpack_ex(root, &up_error, 0, "{s:s}", "file.default.savepath", &s1) == 0) if (json_unpack_ex(root, &up_error, 0, "{s:s}", "file.default.savepath", &s1) == 0)
setDefaultPath (spDefault, s1); setDefaultPath(spDefault, s1);
// default dump path // default dump path
if (json_unpack_ex(root, &up_error, 0, "{s:s}", "file.default.dumppath", &s1) == 0) if (json_unpack_ex(root, &up_error, 0, "{s:s}", "file.default.dumppath", &s1) == 0)
setDefaultPath (spDump, s1); setDefaultPath(spDump, s1);
// default trace path // default trace path
if (json_unpack_ex(root, &up_error, 0, "{s:s}", "file.default.tracepath", &s1) == 0) if (json_unpack_ex(root, &up_error, 0, "{s:s}", "file.default.tracepath", &s1) == 0)
setDefaultPath (spTrace, s1); setDefaultPath(spTrace, s1);
// window plot // window plot
if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.plot.xpos", &i1) == 0) if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.plot.xpos", &i1) == 0)
@ -424,17 +424,17 @@ static void showSavePathState(savePaths_t path_index, prefShowOpt_t opt) {
char s[50]; char s[50];
switch (path_index) { switch (path_index) {
case spDefault: case spDefault:
strcpy (s, "default save path......"); strcpy(s, "default save path......");
break; break;
case spDump: case spDump:
strcpy (s, "dump save path........."); strcpy(s, "dump save path.........");
break; break;
case spTrace: case spTrace:
strcpy (s, "trace save path........"); strcpy(s, "trace save path........");
break; break;
case spItemCount: case spItemCount:
default: default:
strcpy (s, _RED_("unknown")" save path......"); strcpy(s, _RED_("unknown")" save path......");
} }
if ((session.defaultPaths[path_index] == NULL) || (strcmp(session.defaultPaths[path_index], "") == 0)) { if ((session.defaultPaths[path_index] == NULL) || (strcmp(session.defaultPaths[path_index], "") == 0)) {
@ -522,7 +522,7 @@ static int setCmdEmoji(const char *Cmd) {
bool show_none = arg_get_lit(ctx, 4); bool show_none = arg_get_lit(ctx, 4);
CLIParserFree(ctx); CLIParserFree(ctx);
if ( (show_a + show_e + show_alt + show_none) > 1) { if ((show_a + show_e + show_alt + show_none) > 1) {
PrintAndLogEx(FAILED, "Can only set one option"); PrintAndLogEx(FAILED, "Can only set one option");
return PM3_EINVARG; return PM3_EINVARG;
} }
@ -572,7 +572,7 @@ static int setCmdColor(const char *Cmd) {
bool use_n = arg_get_lit(ctx, 2); bool use_n = arg_get_lit(ctx, 2);
CLIParserFree(ctx); CLIParserFree(ctx);
if ( (use_c + use_n) > 1) { if ((use_c + use_n) > 1) {
PrintAndLogEx(FAILED, "Can only set one option"); PrintAndLogEx(FAILED, "Can only set one option");
return PM3_EINVARG; return PM3_EINVARG;
} }
@ -618,7 +618,7 @@ static int setCmdDebug(const char *Cmd) {
bool use_full = arg_get_lit(ctx, 3); bool use_full = arg_get_lit(ctx, 3);
CLIParserFree(ctx); CLIParserFree(ctx);
if ( (use_off + use_simple + use_full) > 1) { if ((use_off + use_simple + use_full) > 1) {
PrintAndLogEx(FAILED, "Can only set one option"); PrintAndLogEx(FAILED, "Can only set one option");
return PM3_EINVARG; return PM3_EINVARG;
} }
@ -734,7 +734,7 @@ static int setCmdHint(const char *Cmd) {
bool use_on = arg_get_lit(ctx, 2); bool use_on = arg_get_lit(ctx, 2);
CLIParserFree(ctx); CLIParserFree(ctx);
if ( (use_off + use_on) > 1) { if ((use_off + use_on) > 1) {
PrintAndLogEx(FAILED, "Can only set one option"); PrintAndLogEx(FAILED, "Can only set one option");
return PM3_EINVARG; return PM3_EINVARG;
} }
@ -777,7 +777,7 @@ static int setCmdPlotSliders(const char *Cmd) {
bool use_on = arg_get_lit(ctx, 2); bool use_on = arg_get_lit(ctx, 2);
CLIParserFree(ctx); CLIParserFree(ctx);
if ( (use_off + use_on) > 1) { if ((use_off + use_on) > 1) {
PrintAndLogEx(FAILED, "Can only set one option"); PrintAndLogEx(FAILED, "Can only set one option");
return PM3_EINVARG; return PM3_EINVARG;
} }
@ -801,7 +801,7 @@ static int setCmdPlotSliders(const char *Cmd) {
return PM3_SUCCESS; return PM3_SUCCESS;
} }
static int setCmdSavePaths (const char *Cmd) { static int setCmdSavePaths(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "pref set savepath", CLIParserInit(&ctx, "pref set savepath",
"Set presistent preference of file paths in the client", "Set presistent preference of file paths in the client",
@ -861,7 +861,7 @@ static int setCmdSavePaths (const char *Cmd) {
// Check path // Check path
if (fileExists(path) == false && create_dir == false) { if (fileExists(path) == false && create_dir == false) {
PrintAndLogEx(ERR,"path does not exist... "_RED_("%s"), path); PrintAndLogEx(ERR, "path does not exist... "_RED_("%s"), path);
} }
// do we need to create it // do we need to create it
@ -871,7 +871,7 @@ static int setCmdSavePaths (const char *Cmd) {
if (path_item < spItemCount) { if (path_item < spItemCount) {
if (strcmp(path, session.defaultPaths[path_item]) != 0) { if (strcmp(path, session.defaultPaths[path_item]) != 0) {
showSavePathState(path_item, prefShowOLD); showSavePathState(path_item, prefShowOLD);
setDefaultPath (path_item, path); setDefaultPath(path_item, path);
showSavePathState(path_item, prefShowNEW); showSavePathState(path_item, prefShowNEW);
preferences_save(); preferences_save();
} else { } else {
@ -902,7 +902,7 @@ static int setCmdBarMode(const char *Cmd) {
bool show_val = arg_get_lit(ctx, 3); bool show_val = arg_get_lit(ctx, 3);
CLIParserFree(ctx); CLIParserFree(ctx);
if ( (show_bar + show_mix + show_val) > 1) { if ((show_bar + show_mix + show_val) > 1) {
PrintAndLogEx(FAILED, "Can only set one option"); PrintAndLogEx(FAILED, "Can only set one option");
return PM3_EINVARG; return PM3_EINVARG;
} }

View file

@ -506,7 +506,7 @@ Check column "offline" for their availability.
|command |offline |description |command |offline |description
|------- |------- |----------- |------- |------- |-----------
|`hw help `|Y |`This help` |`hw help `|Y |`This help`
|`hw connect `|Y |`connect Proxmark3 to serial port` |`hw connect `|Y |`Connect Proxmark3 to serial port`
|`hw dbg `|N |`Set Proxmark3 debug level` |`hw dbg `|N |`Set Proxmark3 debug level`
|`hw detectreader `|N |`Detect external reader field` |`hw detectreader `|N |`Detect external reader field`
|`hw fpgaoff `|N |`Set FPGA off` |`hw fpgaoff `|N |`Set FPGA off`
@ -515,7 +515,7 @@ Check column "offline" for their availability.
|`hw ping `|N |`Test if the Proxmark3 is responsive` |`hw ping `|N |`Test if the Proxmark3 is responsive`
|`hw readmem `|N |`Read memory at decimal address from flash` |`hw readmem `|N |`Read memory at decimal address from flash`
|`hw reset `|N |`Reset the Proxmark3` |`hw reset `|N |`Reset the Proxmark3`
|`hw setlfdivisor `|N |`Drive LF antenna at 12 MHz / (divisor + 1)` |`hw setlfdivisor `|N |`Drive LF antenna at 12MHz / (divisor + 1)`
|`hw setmux `|N |`Set the ADC mux to a specific value` |`hw setmux `|N |`Set the ADC mux to a specific value`
|`hw standalone `|N |`Jump to the standalone mode` |`hw standalone `|N |`Jump to the standalone mode`
|`hw status `|N |`Show runtime status information about the connected Proxmark3` |`hw status `|N |`Show runtime status information about the connected Proxmark3`

File diff suppressed because it is too large Load diff

View file

@ -75,50 +75,50 @@ typedef cl_uint cl_d3d10_device_set_khr;
/******************************************************************************/ /******************************************************************************/
typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetDeviceIDsFromD3D10KHR_fn)( typedef CL_API_ENTRY cl_int(CL_API_CALL *clGetDeviceIDsFromD3D10KHR_fn)(
cl_platform_id platform, cl_platform_id platform,
cl_d3d10_device_source_khr d3d_device_source, cl_d3d10_device_source_khr d3d_device_source,
void * d3d_object, void *d3d_object,
cl_d3d10_device_set_khr d3d_device_set, cl_d3d10_device_set_khr d3d_device_set,
cl_uint num_entries, cl_uint num_entries,
cl_device_id * devices, cl_device_id *devices,
cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0; cl_uint *num_devices) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D10BufferKHR_fn)( typedef CL_API_ENTRY cl_mem(CL_API_CALL *clCreateFromD3D10BufferKHR_fn)(
cl_context context, cl_context context,
cl_mem_flags flags, cl_mem_flags flags,
ID3D10Buffer * resource, ID3D10Buffer *resource,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D10Texture2DKHR_fn)( typedef CL_API_ENTRY cl_mem(CL_API_CALL *clCreateFromD3D10Texture2DKHR_fn)(
cl_context context, cl_context context,
cl_mem_flags flags, cl_mem_flags flags,
ID3D10Texture2D * resource, ID3D10Texture2D *resource,
UINT subresource, UINT subresource,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D10Texture3DKHR_fn)( typedef CL_API_ENTRY cl_mem(CL_API_CALL *clCreateFromD3D10Texture3DKHR_fn)(
cl_context context, cl_context context,
cl_mem_flags flags, cl_mem_flags flags,
ID3D10Texture3D * resource, ID3D10Texture3D *resource,
UINT subresource, UINT subresource,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireD3D10ObjectsKHR_fn)( typedef CL_API_ENTRY cl_int(CL_API_CALL *clEnqueueAcquireD3D10ObjectsKHR_fn)(
cl_command_queue command_queue, cl_command_queue command_queue,
cl_uint num_objects, cl_uint num_objects,
const cl_mem * mem_objects, const cl_mem *mem_objects,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event * event_wait_list, const cl_event *event_wait_list,
cl_event * event) CL_API_SUFFIX__VERSION_1_0; cl_event *event) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseD3D10ObjectsKHR_fn)( typedef CL_API_ENTRY cl_int(CL_API_CALL *clEnqueueReleaseD3D10ObjectsKHR_fn)(
cl_command_queue command_queue, cl_command_queue command_queue,
cl_uint num_objects, cl_uint num_objects,
const cl_mem * mem_objects, const cl_mem *mem_objects,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event * event_wait_list, const cl_event *event_wait_list,
cl_event * event) CL_API_SUFFIX__VERSION_1_0; cl_event *event) CL_API_SUFFIX__VERSION_1_0;
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -75,50 +75,50 @@ typedef cl_uint cl_d3d11_device_set_khr;
/******************************************************************************/ /******************************************************************************/
typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetDeviceIDsFromD3D11KHR_fn)( typedef CL_API_ENTRY cl_int(CL_API_CALL *clGetDeviceIDsFromD3D11KHR_fn)(
cl_platform_id platform, cl_platform_id platform,
cl_d3d11_device_source_khr d3d_device_source, cl_d3d11_device_source_khr d3d_device_source,
void * d3d_object, void *d3d_object,
cl_d3d11_device_set_khr d3d_device_set, cl_d3d11_device_set_khr d3d_device_set,
cl_uint num_entries, cl_uint num_entries,
cl_device_id * devices, cl_device_id *devices,
cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2; cl_uint *num_devices) CL_API_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D11BufferKHR_fn)( typedef CL_API_ENTRY cl_mem(CL_API_CALL *clCreateFromD3D11BufferKHR_fn)(
cl_context context, cl_context context,
cl_mem_flags flags, cl_mem_flags flags,
ID3D11Buffer * resource, ID3D11Buffer *resource,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D11Texture2DKHR_fn)( typedef CL_API_ENTRY cl_mem(CL_API_CALL *clCreateFromD3D11Texture2DKHR_fn)(
cl_context context, cl_context context,
cl_mem_flags flags, cl_mem_flags flags,
ID3D11Texture2D * resource, ID3D11Texture2D *resource,
UINT subresource, UINT subresource,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D11Texture3DKHR_fn)( typedef CL_API_ENTRY cl_mem(CL_API_CALL *clCreateFromD3D11Texture3DKHR_fn)(
cl_context context, cl_context context,
cl_mem_flags flags, cl_mem_flags flags,
ID3D11Texture3D * resource, ID3D11Texture3D *resource,
UINT subresource, UINT subresource,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireD3D11ObjectsKHR_fn)( typedef CL_API_ENTRY cl_int(CL_API_CALL *clEnqueueAcquireD3D11ObjectsKHR_fn)(
cl_command_queue command_queue, cl_command_queue command_queue,
cl_uint num_objects, cl_uint num_objects,
const cl_mem * mem_objects, const cl_mem *mem_objects,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event * event_wait_list, const cl_event *event_wait_list,
cl_event * event) CL_API_SUFFIX__VERSION_1_2; cl_event *event) CL_API_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseD3D11ObjectsKHR_fn)( typedef CL_API_ENTRY cl_int(CL_API_CALL *clEnqueueReleaseD3D11ObjectsKHR_fn)(
cl_command_queue command_queue, cl_command_queue command_queue,
cl_uint num_objects, cl_uint num_objects,
const cl_mem * mem_objects, const cl_mem *mem_objects,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event * event_wait_list, const cl_event *event_wait_list,
cl_event * event) CL_API_SUFFIX__VERSION_1_2; cl_event *event) CL_API_SUFFIX__VERSION_1_2;
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -33,8 +33,7 @@ typedef cl_uint cl_dx9_media_adapter_set_khr;
#if defined(_WIN32) #if defined(_WIN32)
#include <d3d9.h> #include <d3d9.h>
typedef struct _cl_dx9_surface_info_khr typedef struct _cl_dx9_surface_info_khr {
{
IDirect3DSurface9 *resource; IDirect3DSurface9 *resource;
HANDLE shared_handle; HANDLE shared_handle;
} cl_dx9_surface_info_khr; } cl_dx9_surface_info_khr;
@ -76,39 +75,39 @@ typedef struct _cl_dx9_surface_info_khr
/******************************************************************************/ /******************************************************************************/
typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetDeviceIDsFromDX9MediaAdapterKHR_fn)( typedef CL_API_ENTRY cl_int(CL_API_CALL *clGetDeviceIDsFromDX9MediaAdapterKHR_fn)(
cl_platform_id platform, cl_platform_id platform,
cl_uint num_media_adapters, cl_uint num_media_adapters,
cl_dx9_media_adapter_type_khr * media_adapter_type, cl_dx9_media_adapter_type_khr *media_adapter_type,
void * media_adapters, void *media_adapters,
cl_dx9_media_adapter_set_khr media_adapter_set, cl_dx9_media_adapter_set_khr media_adapter_set,
cl_uint num_entries, cl_uint num_entries,
cl_device_id * devices, cl_device_id *devices,
cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2; cl_uint *num_devices) CL_API_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromDX9MediaSurfaceKHR_fn)( typedef CL_API_ENTRY cl_mem(CL_API_CALL *clCreateFromDX9MediaSurfaceKHR_fn)(
cl_context context, cl_context context,
cl_mem_flags flags, cl_mem_flags flags,
cl_dx9_media_adapter_type_khr adapter_type, cl_dx9_media_adapter_type_khr adapter_type,
void * surface_info, void *surface_info,
cl_uint plane, cl_uint plane,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireDX9MediaSurfacesKHR_fn)( typedef CL_API_ENTRY cl_int(CL_API_CALL *clEnqueueAcquireDX9MediaSurfacesKHR_fn)(
cl_command_queue command_queue, cl_command_queue command_queue,
cl_uint num_objects, cl_uint num_objects,
const cl_mem * mem_objects, const cl_mem *mem_objects,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event * event_wait_list, const cl_event *event_wait_list,
cl_event * event) CL_API_SUFFIX__VERSION_1_2; cl_event *event) CL_API_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseDX9MediaSurfacesKHR_fn)( typedef CL_API_ENTRY cl_int(CL_API_CALL *clEnqueueReleaseDX9MediaSurfacesKHR_fn)(
cl_command_queue command_queue, cl_command_queue command_queue,
cl_uint num_objects, cl_uint num_objects,
const cl_mem * mem_objects, const cl_mem *mem_objects,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event * event_wait_list, const cl_event *event_wait_list,
cl_event * event) CL_API_SUFFIX__VERSION_1_2; cl_event *event) CL_API_SUFFIX__VERSION_1_2;
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -96,71 +96,71 @@ extern CL_API_ENTRY cl_int CL_API_CALL
clGetDeviceIDsFromDX9INTEL( clGetDeviceIDsFromDX9INTEL(
cl_platform_id platform, cl_platform_id platform,
cl_dx9_device_source_intel dx9_device_source, cl_dx9_device_source_intel dx9_device_source,
void* dx9_object, void *dx9_object,
cl_dx9_device_set_intel dx9_device_set, cl_dx9_device_set_intel dx9_device_set,
cl_uint num_entries, cl_uint num_entries,
cl_device_id* devices, cl_device_id *devices,
cl_uint* num_devices) CL_EXT_SUFFIX__VERSION_1_1; cl_uint *num_devices) CL_EXT_SUFFIX__VERSION_1_1;
typedef CL_API_ENTRY cl_int (CL_API_CALL* clGetDeviceIDsFromDX9INTEL_fn)( typedef CL_API_ENTRY cl_int(CL_API_CALL *clGetDeviceIDsFromDX9INTEL_fn)(
cl_platform_id platform, cl_platform_id platform,
cl_dx9_device_source_intel dx9_device_source, cl_dx9_device_source_intel dx9_device_source,
void* dx9_object, void *dx9_object,
cl_dx9_device_set_intel dx9_device_set, cl_dx9_device_set_intel dx9_device_set,
cl_uint num_entries, cl_uint num_entries,
cl_device_id* devices, cl_device_id *devices,
cl_uint* num_devices) CL_EXT_SUFFIX__VERSION_1_1; cl_uint *num_devices) CL_EXT_SUFFIX__VERSION_1_1;
extern CL_API_ENTRY cl_mem CL_API_CALL extern CL_API_ENTRY cl_mem CL_API_CALL
clCreateFromDX9MediaSurfaceINTEL( clCreateFromDX9MediaSurfaceINTEL(
cl_context context, cl_context context,
cl_mem_flags flags, cl_mem_flags flags,
IDirect3DSurface9* resource, IDirect3DSurface9 *resource,
HANDLE sharedHandle, HANDLE sharedHandle,
UINT plane, UINT plane,
cl_int* errcode_ret) CL_EXT_SUFFIX__VERSION_1_1; cl_int *errcode_ret) CL_EXT_SUFFIX__VERSION_1_1;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromDX9MediaSurfaceINTEL_fn)( typedef CL_API_ENTRY cl_mem(CL_API_CALL *clCreateFromDX9MediaSurfaceINTEL_fn)(
cl_context context, cl_context context,
cl_mem_flags flags, cl_mem_flags flags,
IDirect3DSurface9* resource, IDirect3DSurface9 *resource,
HANDLE sharedHandle, HANDLE sharedHandle,
UINT plane, UINT plane,
cl_int* errcode_ret) CL_EXT_SUFFIX__VERSION_1_1; cl_int *errcode_ret) CL_EXT_SUFFIX__VERSION_1_1;
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueAcquireDX9ObjectsINTEL( clEnqueueAcquireDX9ObjectsINTEL(
cl_command_queue command_queue, cl_command_queue command_queue,
cl_uint num_objects, cl_uint num_objects,
const cl_mem* mem_objects, const cl_mem *mem_objects,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event* event_wait_list, const cl_event *event_wait_list,
cl_event* event) CL_EXT_SUFFIX__VERSION_1_1; cl_event *event) CL_EXT_SUFFIX__VERSION_1_1;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireDX9ObjectsINTEL_fn)( typedef CL_API_ENTRY cl_int(CL_API_CALL *clEnqueueAcquireDX9ObjectsINTEL_fn)(
cl_command_queue command_queue, cl_command_queue command_queue,
cl_uint num_objects, cl_uint num_objects,
const cl_mem* mem_objects, const cl_mem *mem_objects,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event* event_wait_list, const cl_event *event_wait_list,
cl_event* event) CL_EXT_SUFFIX__VERSION_1_1; cl_event *event) CL_EXT_SUFFIX__VERSION_1_1;
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueReleaseDX9ObjectsINTEL( clEnqueueReleaseDX9ObjectsINTEL(
cl_command_queue command_queue, cl_command_queue command_queue,
cl_uint num_objects, cl_uint num_objects,
cl_mem* mem_objects, cl_mem *mem_objects,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event* event_wait_list, const cl_event *event_wait_list,
cl_event* event) CL_EXT_SUFFIX__VERSION_1_1; cl_event *event) CL_EXT_SUFFIX__VERSION_1_1;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseDX9ObjectsINTEL_fn)( typedef CL_API_ENTRY cl_int(CL_API_CALL *clEnqueueReleaseDX9ObjectsINTEL_fn)(
cl_command_queue command_queue, cl_command_queue command_queue,
cl_uint num_objects, cl_uint num_objects,
cl_mem* mem_objects, cl_mem *mem_objects,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event* event_wait_list, const cl_event *event_wait_list,
cl_event* event) CL_EXT_SUFFIX__VERSION_1_1; cl_event *event) CL_EXT_SUFFIX__VERSION_1_1;
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -34,13 +34,13 @@ extern "C" {
#define CL_EGL_RESOURCE_NOT_ACQUIRED_KHR -1092 #define CL_EGL_RESOURCE_NOT_ACQUIRED_KHR -1092
/* CLeglImageKHR is an opaque handle to an EGLImage */ /* CLeglImageKHR is an opaque handle to an EGLImage */
typedef void* CLeglImageKHR; typedef void *CLeglImageKHR;
/* CLeglDisplayKHR is an opaque handle to an EGLDisplay */ /* CLeglDisplayKHR is an opaque handle to an EGLDisplay */
typedef void* CLeglDisplayKHR; typedef void *CLeglDisplayKHR;
/* CLeglSyncKHR is an opaque handle to an EGLSync object */ /* CLeglSyncKHR is an opaque handle to an EGLSync object */
typedef void* CLeglSyncKHR; typedef void *CLeglSyncKHR;
/* properties passed to clCreateFromEGLImageKHR */ /* properties passed to clCreateFromEGLImageKHR */
typedef intptr_t cl_egl_image_properties_khr; typedef intptr_t cl_egl_image_properties_khr;
@ -53,50 +53,50 @@ clCreateFromEGLImageKHR(cl_context context,
CLeglDisplayKHR egldisplay, CLeglDisplayKHR egldisplay,
CLeglImageKHR eglimage, CLeglImageKHR eglimage,
cl_mem_flags flags, cl_mem_flags flags,
const cl_egl_image_properties_khr * properties, const cl_egl_image_properties_khr *properties,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromEGLImageKHR_fn)( typedef CL_API_ENTRY cl_mem(CL_API_CALL *clCreateFromEGLImageKHR_fn)(
cl_context context, cl_context context,
CLeglDisplayKHR egldisplay, CLeglDisplayKHR egldisplay,
CLeglImageKHR eglimage, CLeglImageKHR eglimage,
cl_mem_flags flags, cl_mem_flags flags,
const cl_egl_image_properties_khr * properties, const cl_egl_image_properties_khr *properties,
cl_int * errcode_ret); cl_int *errcode_ret);
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueAcquireEGLObjectsKHR(cl_command_queue command_queue, clEnqueueAcquireEGLObjectsKHR(cl_command_queue command_queue,
cl_uint num_objects, cl_uint num_objects,
const cl_mem * mem_objects, const cl_mem *mem_objects,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event * event_wait_list, const cl_event *event_wait_list,
cl_event * event) CL_API_SUFFIX__VERSION_1_0; cl_event *event) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireEGLObjectsKHR_fn)( typedef CL_API_ENTRY cl_int(CL_API_CALL *clEnqueueAcquireEGLObjectsKHR_fn)(
cl_command_queue command_queue, cl_command_queue command_queue,
cl_uint num_objects, cl_uint num_objects,
const cl_mem * mem_objects, const cl_mem *mem_objects,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event * event_wait_list, const cl_event *event_wait_list,
cl_event * event); cl_event *event);
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueReleaseEGLObjectsKHR(cl_command_queue command_queue, clEnqueueReleaseEGLObjectsKHR(cl_command_queue command_queue,
cl_uint num_objects, cl_uint num_objects,
const cl_mem * mem_objects, const cl_mem *mem_objects,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event * event_wait_list, const cl_event *event_wait_list,
cl_event * event) CL_API_SUFFIX__VERSION_1_0; cl_event *event) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseEGLObjectsKHR_fn)( typedef CL_API_ENTRY cl_int(CL_API_CALL *clEnqueueReleaseEGLObjectsKHR_fn)(
cl_command_queue command_queue, cl_command_queue command_queue,
cl_uint num_objects, cl_uint num_objects,
const cl_mem * mem_objects, const cl_mem *mem_objects,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event * event_wait_list, const cl_event *event_wait_list,
cl_event * event); cl_event *event);
#define cl_khr_egl_event 1 #define cl_khr_egl_event 1
@ -105,13 +105,13 @@ extern CL_API_ENTRY cl_event CL_API_CALL
clCreateEventFromEGLSyncKHR(cl_context context, clCreateEventFromEGLSyncKHR(cl_context context,
CLeglSyncKHR sync, CLeglSyncKHR sync,
CLeglDisplayKHR display, CLeglDisplayKHR display,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_event (CL_API_CALL *clCreateEventFromEGLSyncKHR_fn)( typedef CL_API_ENTRY cl_event(CL_API_CALL *clCreateEventFromEGLSyncKHR_fn)(
cl_context context, cl_context context,
CLeglSyncKHR sync, CLeglSyncKHR sync,
CLeglDisplayKHR display, CLeglDisplayKHR display,
cl_int * errcode_ret); cl_int *errcode_ret);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -54,9 +54,9 @@ extern "C" {
* before using. * before using.
*/ */
#define cl_APPLE_SetMemObjectDestructor 1 #define cl_APPLE_SetMemObjectDestructor 1
cl_int CL_API_ENTRY clSetMemObjectDestructorAPPLE( cl_mem memobj, cl_int CL_API_ENTRY clSetMemObjectDestructorAPPLE(cl_mem memobj,
void (* pfn_notify)(cl_mem memobj, void * user_data), void (* pfn_notify)(cl_mem memobj, void *user_data),
void * user_data) CL_EXT_SUFFIX__VERSION_1_0; void *user_data) CL_EXT_SUFFIX__VERSION_1_0;
/* Context Logging Functions /* Context Logging Functions
@ -68,22 +68,22 @@ cl_int CL_API_ENTRY clSetMemObjectDestructorAPPLE( cl_mem memobj,
* clLogMessagesToSystemLog forwards on all log messages to the Apple System Logger * clLogMessagesToSystemLog forwards on all log messages to the Apple System Logger
*/ */
#define cl_APPLE_ContextLoggingFunctions 1 #define cl_APPLE_ContextLoggingFunctions 1
extern void CL_API_ENTRY clLogMessagesToSystemLogAPPLE( const char * errstr, extern void CL_API_ENTRY clLogMessagesToSystemLogAPPLE(const char *errstr,
const void * private_info, const void *private_info,
size_t cb, size_t cb,
void * user_data) CL_EXT_SUFFIX__VERSION_1_0; void *user_data) CL_EXT_SUFFIX__VERSION_1_0;
/* clLogMessagesToStdout sends all log messages to the file descriptor stdout */ /* clLogMessagesToStdout sends all log messages to the file descriptor stdout */
extern void CL_API_ENTRY clLogMessagesToStdoutAPPLE( const char * errstr, extern void CL_API_ENTRY clLogMessagesToStdoutAPPLE(const char *errstr,
const void * private_info, const void *private_info,
size_t cb, size_t cb,
void * user_data) CL_EXT_SUFFIX__VERSION_1_0; void *user_data) CL_EXT_SUFFIX__VERSION_1_0;
/* clLogMessagesToStderr sends all log messages to the file descriptor stderr */ /* clLogMessagesToStderr sends all log messages to the file descriptor stderr */
extern void CL_API_ENTRY clLogMessagesToStderrAPPLE( const char * errstr, extern void CL_API_ENTRY clLogMessagesToStderrAPPLE(const char *errstr,
const void * private_info, const void *private_info,
size_t cb, size_t cb,
void * user_data) CL_EXT_SUFFIX__VERSION_1_0; void *user_data) CL_EXT_SUFFIX__VERSION_1_0;
/************************ /************************
@ -99,13 +99,13 @@ extern void CL_API_ENTRY clLogMessagesToStderrAPPLE( const char * errstr,
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clIcdGetPlatformIDsKHR(cl_uint num_entries, clIcdGetPlatformIDsKHR(cl_uint num_entries,
cl_platform_id * platforms, cl_platform_id *platforms,
cl_uint * num_platforms); cl_uint *num_platforms);
typedef CL_API_ENTRY cl_int typedef CL_API_ENTRY cl_int
(CL_API_CALL *clIcdGetPlatformIDsKHR_fn)(cl_uint num_entries, (CL_API_CALL *clIcdGetPlatformIDsKHR_fn)(cl_uint num_entries,
cl_platform_id * platforms, cl_platform_id *platforms,
cl_uint * num_platforms); cl_uint *num_platforms);
/******************************* /*******************************
@ -125,15 +125,15 @@ typedef CL_API_ENTRY cl_int
extern CL_API_ENTRY cl_program CL_API_CALL extern CL_API_ENTRY cl_program CL_API_CALL
clCreateProgramWithILKHR(cl_context context, clCreateProgramWithILKHR(cl_context context,
const void * il, const void *il,
size_t length, size_t length,
cl_int * errcode_ret); cl_int *errcode_ret);
typedef CL_API_ENTRY cl_program typedef CL_API_ENTRY cl_program
(CL_API_CALL *clCreateProgramWithILKHR_fn)(cl_context context, (CL_API_CALL *clCreateProgramWithILKHR_fn)(cl_context context,
const void * il, const void *il,
size_t length, size_t length,
cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_2; cl_int *errcode_ret) CL_EXT_SUFFIX__VERSION_1_2;
/* Extension: cl_khr_image2d_from_buffer /* Extension: cl_khr_image2d_from_buffer
* *
@ -203,14 +203,14 @@ typedef cl_properties cl_queue_properties_khr;
extern CL_API_ENTRY cl_command_queue CL_API_CALL extern CL_API_ENTRY cl_command_queue CL_API_CALL
clCreateCommandQueueWithPropertiesKHR(cl_context context, clCreateCommandQueueWithPropertiesKHR(cl_context context,
cl_device_id device, cl_device_id device,
const cl_queue_properties_khr* properties, const cl_queue_properties_khr *properties,
cl_int* errcode_ret) CL_EXT_SUFFIX__VERSION_1_2; cl_int *errcode_ret) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_command_queue typedef CL_API_ENTRY cl_command_queue
(CL_API_CALL *clCreateCommandQueueWithPropertiesKHR_fn)(cl_context context, (CL_API_CALL *clCreateCommandQueueWithPropertiesKHR_fn)(cl_context context,
cl_device_id device, cl_device_id device,
const cl_queue_properties_khr* properties, const cl_queue_properties_khr *properties,
cl_int* errcode_ret) CL_EXT_SUFFIX__VERSION_1_2; cl_int *errcode_ret) CL_EXT_SUFFIX__VERSION_1_2;
/****************************************** /******************************************
@ -282,17 +282,17 @@ typedef CL_API_ENTRY cl_int
typedef cl_ulong cl_device_partition_property_ext; typedef cl_ulong cl_device_partition_property_ext;
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clCreateSubDevicesEXT(cl_device_id in_device, clCreateSubDevicesEXT(cl_device_id in_device,
const cl_device_partition_property_ext * properties, const cl_device_partition_property_ext *properties,
cl_uint num_entries, cl_uint num_entries,
cl_device_id * out_devices, cl_device_id *out_devices,
cl_uint * num_devices) CL_EXT_SUFFIX__VERSION_1_1; cl_uint *num_devices) CL_EXT_SUFFIX__VERSION_1_1;
typedef CL_API_ENTRY cl_int typedef CL_API_ENTRY cl_int
(CL_API_CALL * clCreateSubDevicesEXT_fn)(cl_device_id in_device, (CL_API_CALL *clCreateSubDevicesEXT_fn)(cl_device_id in_device,
const cl_device_partition_property_ext * properties, const cl_device_partition_property_ext *properties,
cl_uint num_entries, cl_uint num_entries,
cl_device_id * out_devices, cl_device_id *out_devices,
cl_uint * num_devices) CL_EXT_SUFFIX__VERSION_1_1; cl_uint *num_devices) CL_EXT_SUFFIX__VERSION_1_1;
/* cl_device_partition_property_ext */ /* cl_device_partition_property_ext */
#define CL_DEVICE_PARTITION_EQUALLY_EXT 0x4050 #define CL_DEVICE_PARTITION_EQUALLY_EXT 0x4050
@ -340,20 +340,20 @@ typedef cl_bitfield cl_mem_migration_flags_ext;
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueMigrateMemObjectEXT(cl_command_queue command_queue, clEnqueueMigrateMemObjectEXT(cl_command_queue command_queue,
cl_uint num_mem_objects, cl_uint num_mem_objects,
const cl_mem * mem_objects, const cl_mem *mem_objects,
cl_mem_migration_flags_ext flags, cl_mem_migration_flags_ext flags,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event * event_wait_list, const cl_event *event_wait_list,
cl_event * event); cl_event *event);
typedef CL_API_ENTRY cl_int typedef CL_API_ENTRY cl_int
(CL_API_CALL *clEnqueueMigrateMemObjectEXT_fn)(cl_command_queue command_queue, (CL_API_CALL *clEnqueueMigrateMemObjectEXT_fn)(cl_command_queue command_queue,
cl_uint num_mem_objects, cl_uint num_mem_objects,
const cl_mem * mem_objects, const cl_mem *mem_objects,
cl_mem_migration_flags_ext flags, cl_mem_migration_flags_ext flags,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event * event_wait_list, const cl_event *event_wait_list,
cl_event * event); cl_event *event);
/********************************* /*********************************
@ -391,8 +391,7 @@ clGetDeviceImageInfoQCOM(cl_device_id device,
void *param_value, void *param_value,
size_t *param_value_size_ret); size_t *param_value_size_ret);
typedef struct _cl_mem_ext_host_ptr typedef struct _cl_mem_ext_host_ptr {
{
/* Type of external memory allocation. */ /* Type of external memory allocation. */
/* Legal values will be defined in layered extensions. */ /* Legal values will be defined in layered extensions. */
cl_uint allocation_type; cl_uint allocation_type;
@ -417,8 +416,7 @@ typedef struct _cl_mem_ext_host_ptr
#define CL_MEM_ION_HOST_PTR_QCOM 0x40A8 #define CL_MEM_ION_HOST_PTR_QCOM 0x40A8
typedef struct _cl_mem_ion_host_ptr typedef struct _cl_mem_ion_host_ptr {
{
/* Type of external memory allocation. */ /* Type of external memory allocation. */
/* Must be CL_MEM_ION_HOST_PTR_QCOM for ION allocations. */ /* Must be CL_MEM_ION_HOST_PTR_QCOM for ION allocations. */
cl_mem_ext_host_ptr ext_host_ptr; cl_mem_ext_host_ptr ext_host_ptr;
@ -427,7 +425,7 @@ typedef struct _cl_mem_ion_host_ptr
int ion_filedesc; int ion_filedesc;
/* Host pointer to the ION allocated memory */ /* Host pointer to the ION allocated memory */
void* ion_hostptr; void *ion_hostptr;
} cl_mem_ion_host_ptr; } cl_mem_ion_host_ptr;
@ -438,14 +436,13 @@ typedef struct _cl_mem_ion_host_ptr
#define CL_MEM_ANDROID_NATIVE_BUFFER_HOST_PTR_QCOM 0x40C6 #define CL_MEM_ANDROID_NATIVE_BUFFER_HOST_PTR_QCOM 0x40C6
typedef struct _cl_mem_android_native_buffer_host_ptr typedef struct _cl_mem_android_native_buffer_host_ptr {
{
/* Type of external memory allocation. */ /* Type of external memory allocation. */
/* Must be CL_MEM_ANDROID_NATIVE_BUFFER_HOST_PTR_QCOM for Android native buffers. */ /* Must be CL_MEM_ANDROID_NATIVE_BUFFER_HOST_PTR_QCOM for Android native buffers. */
cl_mem_ext_host_ptr ext_host_ptr; cl_mem_ext_host_ptr ext_host_ptr;
/* Virtual pointer to the android native buffer */ /* Virtual pointer to the android native buffer */
void* anb_ptr; void *anb_ptr;
} cl_mem_android_native_buffer_host_ptr; } cl_mem_android_native_buffer_host_ptr;
@ -487,18 +484,18 @@ typedef struct _cl_mem_android_native_buffer_host_ptr
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueAcquireGrallocObjectsIMG(cl_command_queue command_queue, clEnqueueAcquireGrallocObjectsIMG(cl_command_queue command_queue,
cl_uint num_objects, cl_uint num_objects,
const cl_mem * mem_objects, const cl_mem *mem_objects,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event * event_wait_list, const cl_event *event_wait_list,
cl_event * event) CL_EXT_SUFFIX__VERSION_1_2; cl_event *event) CL_EXT_SUFFIX__VERSION_1_2;
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueReleaseGrallocObjectsIMG(cl_command_queue command_queue, clEnqueueReleaseGrallocObjectsIMG(cl_command_queue command_queue,
cl_uint num_objects, cl_uint num_objects,
const cl_mem * mem_objects, const cl_mem *mem_objects,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event * event_wait_list, const cl_event *event_wait_list,
cl_event * event) CL_EXT_SUFFIX__VERSION_1_2; cl_event *event) CL_EXT_SUFFIX__VERSION_1_2;
/****************************************** /******************************************
* cl_img_generate_mipmap extension * * cl_img_generate_mipmap extension *
@ -561,20 +558,20 @@ clGetKernelSubGroupInfoKHR(cl_kernel in_kernel,
cl_device_id in_device, cl_device_id in_device,
cl_kernel_sub_group_info param_name, cl_kernel_sub_group_info param_name,
size_t input_value_size, size_t input_value_size,
const void * input_value, const void *input_value,
size_t param_value_size, size_t param_value_size,
void * param_value, void *param_value,
size_t * param_value_size_ret) CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED; size_t *param_value_size_ret) CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED;
typedef CL_API_ENTRY cl_int typedef CL_API_ENTRY cl_int
(CL_API_CALL * clGetKernelSubGroupInfoKHR_fn)(cl_kernel in_kernel, (CL_API_CALL *clGetKernelSubGroupInfoKHR_fn)(cl_kernel in_kernel,
cl_device_id in_device, cl_device_id in_device,
cl_kernel_sub_group_info param_name, cl_kernel_sub_group_info param_name,
size_t input_value_size, size_t input_value_size,
const void * input_value, const void *input_value,
size_t param_value_size, size_t param_value_size,
void * param_value, void *param_value,
size_t * param_value_size_ret) CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED; size_t *param_value_size_ret) CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED;
/********************************* /*********************************
@ -661,8 +658,7 @@ typedef cl_uint cl_version_khr;
#define CL_NAME_VERSION_MAX_NAME_SIZE_KHR 64 #define CL_NAME_VERSION_MAX_NAME_SIZE_KHR 64
typedef struct _cl_name_version_khr typedef struct _cl_name_version_khr {
{
cl_version_khr version; cl_version_khr version;
char name[CL_NAME_VERSION_MAX_NAME_SIZE_KHR]; char name[CL_NAME_VERSION_MAX_NAME_SIZE_KHR];
} cl_name_version_khr; } cl_name_version_khr;
@ -739,7 +735,7 @@ typedef intptr_t cl_import_properties_arm;
* function clCreateBuffer. * function clCreateBuffer.
*/ */
extern CL_API_ENTRY cl_mem CL_API_CALL extern CL_API_ENTRY cl_mem CL_API_CALL
clImportMemoryARM( cl_context context, clImportMemoryARM(cl_context context,
cl_mem_flags flags, cl_mem_flags flags,
const cl_import_properties_arm *properties, const cl_import_properties_arm *properties,
void *memory, void *memory,
@ -783,7 +779,7 @@ typedef cl_bitfield cl_svm_mem_flags_arm;
typedef cl_uint cl_kernel_exec_info_arm; typedef cl_uint cl_kernel_exec_info_arm;
typedef cl_bitfield cl_device_svm_capabilities_arm; typedef cl_bitfield cl_device_svm_capabilities_arm;
extern CL_API_ENTRY void * CL_API_CALL extern CL_API_ENTRY void *CL_API_CALL
clSVMAllocARM(cl_context context, clSVMAllocARM(cl_context context,
cl_svm_mem_flags_arm flags, cl_svm_mem_flags_arm flags,
size_t size, size_t size,
@ -791,68 +787,68 @@ clSVMAllocARM(cl_context context,
extern CL_API_ENTRY void CL_API_CALL extern CL_API_ENTRY void CL_API_CALL
clSVMFreeARM(cl_context context, clSVMFreeARM(cl_context context,
void * svm_pointer) CL_EXT_SUFFIX__VERSION_1_2; void *svm_pointer) CL_EXT_SUFFIX__VERSION_1_2;
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueSVMFreeARM(cl_command_queue command_queue, clEnqueueSVMFreeARM(cl_command_queue command_queue,
cl_uint num_svm_pointers, cl_uint num_svm_pointers,
void * svm_pointers[], void *svm_pointers[],
void (CL_CALLBACK * pfn_free_func)(cl_command_queue queue, void (CL_CALLBACK *pfn_free_func)(cl_command_queue queue,
cl_uint num_svm_pointers, cl_uint num_svm_pointers,
void * svm_pointers[], void *svm_pointers[],
void * user_data), void *user_data),
void * user_data, void *user_data,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event * event_wait_list, const cl_event *event_wait_list,
cl_event * event) CL_EXT_SUFFIX__VERSION_1_2; cl_event *event) CL_EXT_SUFFIX__VERSION_1_2;
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueSVMMemcpyARM(cl_command_queue command_queue, clEnqueueSVMMemcpyARM(cl_command_queue command_queue,
cl_bool blocking_copy, cl_bool blocking_copy,
void * dst_ptr, void *dst_ptr,
const void * src_ptr, const void *src_ptr,
size_t size, size_t size,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event * event_wait_list, const cl_event *event_wait_list,
cl_event * event) CL_EXT_SUFFIX__VERSION_1_2; cl_event *event) CL_EXT_SUFFIX__VERSION_1_2;
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueSVMMemFillARM(cl_command_queue command_queue, clEnqueueSVMMemFillARM(cl_command_queue command_queue,
void * svm_ptr, void *svm_ptr,
const void * pattern, const void *pattern,
size_t pattern_size, size_t pattern_size,
size_t size, size_t size,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event * event_wait_list, const cl_event *event_wait_list,
cl_event * event) CL_EXT_SUFFIX__VERSION_1_2; cl_event *event) CL_EXT_SUFFIX__VERSION_1_2;
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueSVMMapARM(cl_command_queue command_queue, clEnqueueSVMMapARM(cl_command_queue command_queue,
cl_bool blocking_map, cl_bool blocking_map,
cl_map_flags flags, cl_map_flags flags,
void * svm_ptr, void *svm_ptr,
size_t size, size_t size,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event * event_wait_list, const cl_event *event_wait_list,
cl_event * event) CL_EXT_SUFFIX__VERSION_1_2; cl_event *event) CL_EXT_SUFFIX__VERSION_1_2;
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueSVMUnmapARM(cl_command_queue command_queue, clEnqueueSVMUnmapARM(cl_command_queue command_queue,
void * svm_ptr, void *svm_ptr,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event * event_wait_list, const cl_event *event_wait_list,
cl_event * event) CL_EXT_SUFFIX__VERSION_1_2; cl_event *event) CL_EXT_SUFFIX__VERSION_1_2;
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clSetKernelArgSVMPointerARM(cl_kernel kernel, clSetKernelArgSVMPointerARM(cl_kernel kernel,
cl_uint arg_index, cl_uint arg_index,
const void * arg_value) CL_EXT_SUFFIX__VERSION_1_2; const void *arg_value) CL_EXT_SUFFIX__VERSION_1_2;
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clSetKernelExecInfoARM(cl_kernel kernel, clSetKernelExecInfoARM(cl_kernel kernel,
cl_kernel_exec_info_arm param_name, cl_kernel_exec_info_arm param_name,
size_t param_value_size, size_t param_value_size,
const void * param_value) CL_EXT_SUFFIX__VERSION_1_2; const void *param_value) CL_EXT_SUFFIX__VERSION_1_2;
/******************************** /********************************
* cl_arm_get_core_id extension * * cl_arm_get_core_id extension *

View file

@ -75,7 +75,7 @@ extern "C" {
#define cl_intel_motion_estimation 1 #define cl_intel_motion_estimation 1
#define cl_intel_advanced_motion_estimation 1 #define cl_intel_advanced_motion_estimation 1
typedef struct _cl_accelerator_intel* cl_accelerator_intel; typedef struct _cl_accelerator_intel *cl_accelerator_intel;
typedef cl_uint cl_accelerator_type_intel; typedef cl_uint cl_accelerator_type_intel;
typedef cl_uint cl_accelerator_info_intel; typedef cl_uint cl_accelerator_info_intel;
@ -171,43 +171,43 @@ clCreateAcceleratorINTEL(
cl_context context, cl_context context,
cl_accelerator_type_intel accelerator_type, cl_accelerator_type_intel accelerator_type,
size_t descriptor_size, size_t descriptor_size,
const void* descriptor, const void *descriptor,
cl_int* errcode_ret) CL_EXT_SUFFIX__VERSION_1_2; cl_int *errcode_ret) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_accelerator_intel (CL_API_CALL *clCreateAcceleratorINTEL_fn)( typedef CL_API_ENTRY cl_accelerator_intel(CL_API_CALL *clCreateAcceleratorINTEL_fn)(
cl_context context, cl_context context,
cl_accelerator_type_intel accelerator_type, cl_accelerator_type_intel accelerator_type,
size_t descriptor_size, size_t descriptor_size,
const void* descriptor, const void *descriptor,
cl_int* errcode_ret) CL_EXT_SUFFIX__VERSION_1_2; cl_int *errcode_ret) CL_EXT_SUFFIX__VERSION_1_2;
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clGetAcceleratorInfoINTEL( clGetAcceleratorInfoINTEL(
cl_accelerator_intel accelerator, cl_accelerator_intel accelerator,
cl_accelerator_info_intel param_name, cl_accelerator_info_intel param_name,
size_t param_value_size, size_t param_value_size,
void* param_value, void *param_value,
size_t* param_value_size_ret) CL_EXT_SUFFIX__VERSION_1_2; size_t *param_value_size_ret) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetAcceleratorInfoINTEL_fn)( typedef CL_API_ENTRY cl_int(CL_API_CALL *clGetAcceleratorInfoINTEL_fn)(
cl_accelerator_intel accelerator, cl_accelerator_intel accelerator,
cl_accelerator_info_intel param_name, cl_accelerator_info_intel param_name,
size_t param_value_size, size_t param_value_size,
void* param_value, void *param_value,
size_t* param_value_size_ret) CL_EXT_SUFFIX__VERSION_1_2; size_t *param_value_size_ret) CL_EXT_SUFFIX__VERSION_1_2;
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clRetainAcceleratorINTEL( clRetainAcceleratorINTEL(
cl_accelerator_intel accelerator) CL_EXT_SUFFIX__VERSION_1_2; cl_accelerator_intel accelerator) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clRetainAcceleratorINTEL_fn)( typedef CL_API_ENTRY cl_int(CL_API_CALL *clRetainAcceleratorINTEL_fn)(
cl_accelerator_intel accelerator) CL_EXT_SUFFIX__VERSION_1_2; cl_accelerator_intel accelerator) CL_EXT_SUFFIX__VERSION_1_2;
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clReleaseAcceleratorINTEL( clReleaseAcceleratorINTEL(
cl_accelerator_intel accelerator) CL_EXT_SUFFIX__VERSION_1_2; cl_accelerator_intel accelerator) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clReleaseAcceleratorINTEL_fn)( typedef CL_API_ENTRY cl_int(CL_API_CALL *clReleaseAcceleratorINTEL_fn)(
cl_accelerator_intel accelerator) CL_EXT_SUFFIX__VERSION_1_2; cl_accelerator_intel accelerator) CL_EXT_SUFFIX__VERSION_1_2;
/****************************************** /******************************************
@ -472,171 +472,171 @@ typedef cl_uint cl_mem_advice_intel;
#define CL_COMMAND_MIGRATEMEM_INTEL 0x4206 #define CL_COMMAND_MIGRATEMEM_INTEL 0x4206
#define CL_COMMAND_MEMADVISE_INTEL 0x4207 #define CL_COMMAND_MEMADVISE_INTEL 0x4207
extern CL_API_ENTRY void* CL_API_CALL extern CL_API_ENTRY void *CL_API_CALL
clHostMemAllocINTEL( clHostMemAllocINTEL(
cl_context context, cl_context context,
const cl_mem_properties_intel* properties, const cl_mem_properties_intel *properties,
size_t size, size_t size,
cl_uint alignment, cl_uint alignment,
cl_int* errcode_ret); cl_int *errcode_ret);
typedef CL_API_ENTRY void* (CL_API_CALL * typedef CL_API_ENTRY void *(CL_API_CALL *
clHostMemAllocINTEL_fn)( clHostMemAllocINTEL_fn)(
cl_context context, cl_context context,
const cl_mem_properties_intel* properties, const cl_mem_properties_intel *properties,
size_t size, size_t size,
cl_uint alignment, cl_uint alignment,
cl_int* errcode_ret); cl_int *errcode_ret);
extern CL_API_ENTRY void* CL_API_CALL extern CL_API_ENTRY void *CL_API_CALL
clDeviceMemAllocINTEL( clDeviceMemAllocINTEL(
cl_context context, cl_context context,
cl_device_id device, cl_device_id device,
const cl_mem_properties_intel* properties, const cl_mem_properties_intel *properties,
size_t size, size_t size,
cl_uint alignment, cl_uint alignment,
cl_int* errcode_ret); cl_int *errcode_ret);
typedef CL_API_ENTRY void* (CL_API_CALL * typedef CL_API_ENTRY void *(CL_API_CALL *
clDeviceMemAllocINTEL_fn)( clDeviceMemAllocINTEL_fn)(
cl_context context, cl_context context,
cl_device_id device, cl_device_id device,
const cl_mem_properties_intel* properties, const cl_mem_properties_intel *properties,
size_t size, size_t size,
cl_uint alignment, cl_uint alignment,
cl_int* errcode_ret); cl_int *errcode_ret);
extern CL_API_ENTRY void* CL_API_CALL extern CL_API_ENTRY void *CL_API_CALL
clSharedMemAllocINTEL( clSharedMemAllocINTEL(
cl_context context, cl_context context,
cl_device_id device, cl_device_id device,
const cl_mem_properties_intel* properties, const cl_mem_properties_intel *properties,
size_t size, size_t size,
cl_uint alignment, cl_uint alignment,
cl_int* errcode_ret); cl_int *errcode_ret);
typedef CL_API_ENTRY void* (CL_API_CALL * typedef CL_API_ENTRY void *(CL_API_CALL *
clSharedMemAllocINTEL_fn)( clSharedMemAllocINTEL_fn)(
cl_context context, cl_context context,
cl_device_id device, cl_device_id device,
const cl_mem_properties_intel* properties, const cl_mem_properties_intel *properties,
size_t size, size_t size,
cl_uint alignment, cl_uint alignment,
cl_int* errcode_ret); cl_int *errcode_ret);
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clMemFreeINTEL( clMemFreeINTEL(
cl_context context, cl_context context,
void* ptr); void *ptr);
typedef CL_API_ENTRY cl_int (CL_API_CALL * typedef CL_API_ENTRY cl_int(CL_API_CALL *
clMemFreeINTEL_fn)( clMemFreeINTEL_fn)(
cl_context context, cl_context context,
void* ptr); void *ptr);
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clMemBlockingFreeINTEL( clMemBlockingFreeINTEL(
cl_context context, cl_context context,
void* ptr); void *ptr);
typedef CL_API_ENTRY cl_int (CL_API_CALL * typedef CL_API_ENTRY cl_int(CL_API_CALL *
clMemBlockingFreeINTEL_fn)( clMemBlockingFreeINTEL_fn)(
cl_context context, cl_context context,
void* ptr); void *ptr);
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clGetMemAllocInfoINTEL( clGetMemAllocInfoINTEL(
cl_context context, cl_context context,
const void* ptr, const void *ptr,
cl_mem_info_intel param_name, cl_mem_info_intel param_name,
size_t param_value_size, size_t param_value_size,
void* param_value, void *param_value,
size_t* param_value_size_ret); size_t *param_value_size_ret);
typedef CL_API_ENTRY cl_int (CL_API_CALL * typedef CL_API_ENTRY cl_int(CL_API_CALL *
clGetMemAllocInfoINTEL_fn)( clGetMemAllocInfoINTEL_fn)(
cl_context context, cl_context context,
const void* ptr, const void *ptr,
cl_mem_info_intel param_name, cl_mem_info_intel param_name,
size_t param_value_size, size_t param_value_size,
void* param_value, void *param_value,
size_t* param_value_size_ret); size_t *param_value_size_ret);
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clSetKernelArgMemPointerINTEL( clSetKernelArgMemPointerINTEL(
cl_kernel kernel, cl_kernel kernel,
cl_uint arg_index, cl_uint arg_index,
const void* arg_value); const void *arg_value);
typedef CL_API_ENTRY cl_int (CL_API_CALL * typedef CL_API_ENTRY cl_int(CL_API_CALL *
clSetKernelArgMemPointerINTEL_fn)( clSetKernelArgMemPointerINTEL_fn)(
cl_kernel kernel, cl_kernel kernel,
cl_uint arg_index, cl_uint arg_index,
const void* arg_value); const void *arg_value);
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueMemsetINTEL( /* Deprecated */ clEnqueueMemsetINTEL( /* Deprecated */
cl_command_queue command_queue, cl_command_queue command_queue,
void* dst_ptr, void *dst_ptr,
cl_int value, cl_int value,
size_t size, size_t size,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event* event_wait_list, const cl_event *event_wait_list,
cl_event* event); cl_event *event);
typedef CL_API_ENTRY cl_int (CL_API_CALL * typedef CL_API_ENTRY cl_int(CL_API_CALL *
clEnqueueMemsetINTEL_fn)( /* Deprecated */ clEnqueueMemsetINTEL_fn)( /* Deprecated */
cl_command_queue command_queue, cl_command_queue command_queue,
void* dst_ptr, void *dst_ptr,
cl_int value, cl_int value,
size_t size, size_t size,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event* event_wait_list, const cl_event *event_wait_list,
cl_event* event); cl_event *event);
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueMemFillINTEL( clEnqueueMemFillINTEL(
cl_command_queue command_queue, cl_command_queue command_queue,
void* dst_ptr, void *dst_ptr,
const void* pattern, const void *pattern,
size_t pattern_size, size_t pattern_size,
size_t size, size_t size,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event* event_wait_list, const cl_event *event_wait_list,
cl_event* event); cl_event *event);
typedef CL_API_ENTRY cl_int (CL_API_CALL * typedef CL_API_ENTRY cl_int(CL_API_CALL *
clEnqueueMemFillINTEL_fn)( clEnqueueMemFillINTEL_fn)(
cl_command_queue command_queue, cl_command_queue command_queue,
void* dst_ptr, void *dst_ptr,
const void* pattern, const void *pattern,
size_t pattern_size, size_t pattern_size,
size_t size, size_t size,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event* event_wait_list, const cl_event *event_wait_list,
cl_event* event); cl_event *event);
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueMemcpyINTEL( clEnqueueMemcpyINTEL(
cl_command_queue command_queue, cl_command_queue command_queue,
cl_bool blocking, cl_bool blocking,
void* dst_ptr, void *dst_ptr,
const void* src_ptr, const void *src_ptr,
size_t size, size_t size,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event* event_wait_list, const cl_event *event_wait_list,
cl_event* event); cl_event *event);
typedef CL_API_ENTRY cl_int (CL_API_CALL * typedef CL_API_ENTRY cl_int(CL_API_CALL *
clEnqueueMemcpyINTEL_fn)( clEnqueueMemcpyINTEL_fn)(
cl_command_queue command_queue, cl_command_queue command_queue,
cl_bool blocking, cl_bool blocking,
void* dst_ptr, void *dst_ptr,
const void* src_ptr, const void *src_ptr,
size_t size, size_t size,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event* event_wait_list, const cl_event *event_wait_list,
cl_event* event); cl_event *event);
#ifdef CL_VERSION_1_2 #ifdef CL_VERSION_1_2
@ -646,44 +646,44 @@ clEnqueueMemcpyINTEL_fn)(
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueMigrateMemINTEL( clEnqueueMigrateMemINTEL(
cl_command_queue command_queue, cl_command_queue command_queue,
const void* ptr, const void *ptr,
size_t size, size_t size,
cl_mem_migration_flags flags, cl_mem_migration_flags flags,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event* event_wait_list, const cl_event *event_wait_list,
cl_event* event); cl_event *event);
typedef CL_API_ENTRY cl_int (CL_API_CALL * typedef CL_API_ENTRY cl_int(CL_API_CALL *
clEnqueueMigrateMemINTEL_fn)( clEnqueueMigrateMemINTEL_fn)(
cl_command_queue command_queue, cl_command_queue command_queue,
const void* ptr, const void *ptr,
size_t size, size_t size,
cl_mem_migration_flags flags, cl_mem_migration_flags flags,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event* event_wait_list, const cl_event *event_wait_list,
cl_event* event); cl_event *event);
#endif #endif
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueMemAdviseINTEL( clEnqueueMemAdviseINTEL(
cl_command_queue command_queue, cl_command_queue command_queue,
const void* ptr, const void *ptr,
size_t size, size_t size,
cl_mem_advice_intel advice, cl_mem_advice_intel advice,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event* event_wait_list, const cl_event *event_wait_list,
cl_event* event); cl_event *event);
typedef CL_API_ENTRY cl_int (CL_API_CALL * typedef CL_API_ENTRY cl_int(CL_API_CALL *
clEnqueueMemAdviseINTEL_fn)( clEnqueueMemAdviseINTEL_fn)(
cl_command_queue command_queue, cl_command_queue command_queue,
const void* ptr, const void *ptr,
size_t size, size_t size,
cl_mem_advice_intel advice, cl_mem_advice_intel advice,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event* event_wait_list, const cl_event *event_wait_list,
cl_event* event); cl_event *event);
/*************************************************** /***************************************************
* cl_intel_create_buffer_with_properties extension * * cl_intel_create_buffer_with_properties extension *
@ -694,20 +694,20 @@ clEnqueueMemAdviseINTEL_fn)(
extern CL_API_ENTRY cl_mem CL_API_CALL extern CL_API_ENTRY cl_mem CL_API_CALL
clCreateBufferWithPropertiesINTEL( clCreateBufferWithPropertiesINTEL(
cl_context context, cl_context context,
const cl_mem_properties_intel* properties, const cl_mem_properties_intel *properties,
cl_mem_flags flags, cl_mem_flags flags,
size_t size, size_t size,
void * host_ptr, void *host_ptr,
cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_0; cl_int *errcode_ret) CL_EXT_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_mem (CL_API_CALL * typedef CL_API_ENTRY cl_mem(CL_API_CALL *
clCreateBufferWithPropertiesINTEL_fn)( clCreateBufferWithPropertiesINTEL_fn)(
cl_context context, cl_context context,
const cl_mem_properties_intel* properties, const cl_mem_properties_intel *properties,
cl_mem_flags flags, cl_mem_flags flags,
size_t size, size_t size,
void * host_ptr, void *host_ptr,
cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_0; cl_int *errcode_ret) CL_EXT_SUFFIX__VERSION_1_0;
/****************************************** /******************************************
* cl_intel_mem_channel_property extension * * cl_intel_mem_channel_property extension *

View file

@ -52,7 +52,7 @@ extern CL_API_ENTRY cl_mem CL_API_CALL
clCreateFromGLBuffer(cl_context context, clCreateFromGLBuffer(cl_context context,
cl_mem_flags flags, cl_mem_flags flags,
cl_GLuint bufobj, cl_GLuint bufobj,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0;
#ifdef CL_VERSION_1_2 #ifdef CL_VERSION_1_2
@ -62,7 +62,7 @@ clCreateFromGLTexture(cl_context context,
cl_GLenum target, cl_GLenum target,
cl_GLint miplevel, cl_GLint miplevel,
cl_GLuint texture, cl_GLuint texture,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_2;
#endif #endif
@ -70,35 +70,35 @@ extern CL_API_ENTRY cl_mem CL_API_CALL
clCreateFromGLRenderbuffer(cl_context context, clCreateFromGLRenderbuffer(cl_context context,
cl_mem_flags flags, cl_mem_flags flags,
cl_GLuint renderbuffer, cl_GLuint renderbuffer,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0;
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clGetGLObjectInfo(cl_mem memobj, clGetGLObjectInfo(cl_mem memobj,
cl_gl_object_type * gl_object_type, cl_gl_object_type *gl_object_type,
cl_GLuint * gl_object_name) CL_API_SUFFIX__VERSION_1_0; cl_GLuint *gl_object_name) CL_API_SUFFIX__VERSION_1_0;
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clGetGLTextureInfo(cl_mem memobj, clGetGLTextureInfo(cl_mem memobj,
cl_gl_texture_info param_name, cl_gl_texture_info param_name,
size_t param_value_size, size_t param_value_size,
void * param_value, void *param_value,
size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0;
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueAcquireGLObjects(cl_command_queue command_queue, clEnqueueAcquireGLObjects(cl_command_queue command_queue,
cl_uint num_objects, cl_uint num_objects,
const cl_mem * mem_objects, const cl_mem *mem_objects,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event * event_wait_list, const cl_event *event_wait_list,
cl_event * event) CL_API_SUFFIX__VERSION_1_0; cl_event *event) CL_API_SUFFIX__VERSION_1_0;
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueReleaseGLObjects(cl_command_queue command_queue, clEnqueueReleaseGLObjects(cl_command_queue command_queue,
cl_uint num_objects, cl_uint num_objects,
const cl_mem * mem_objects, const cl_mem *mem_objects,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event * event_wait_list, const cl_event *event_wait_list,
cl_event * event) CL_API_SUFFIX__VERSION_1_0; cl_event *event) CL_API_SUFFIX__VERSION_1_0;
/* Deprecated OpenCL 1.1 APIs */ /* Deprecated OpenCL 1.1 APIs */
@ -108,7 +108,7 @@ clCreateFromGLTexture2D(cl_context context,
cl_GLenum target, cl_GLenum target,
cl_GLint miplevel, cl_GLint miplevel,
cl_GLuint texture, cl_GLuint texture,
cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; cl_int *errcode_ret) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL
clCreateFromGLTexture3D(cl_context context, clCreateFromGLTexture3D(cl_context context,
@ -116,7 +116,7 @@ clCreateFromGLTexture3D(cl_context context,
cl_GLenum target, cl_GLenum target,
cl_GLint miplevel, cl_GLint miplevel,
cl_GLuint texture, cl_GLuint texture,
cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; cl_int *errcode_ret) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
/* cl_khr_gl_sharing extension */ /* cl_khr_gl_sharing extension */
@ -139,18 +139,18 @@ typedef cl_uint cl_gl_context_info;
#define CL_CGL_SHAREGROUP_KHR 0x200C #define CL_CGL_SHAREGROUP_KHR 0x200C
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clGetGLContextInfoKHR(const cl_context_properties * properties, clGetGLContextInfoKHR(const cl_context_properties *properties,
cl_gl_context_info param_name, cl_gl_context_info param_name,
size_t param_value_size, size_t param_value_size,
void * param_value, void *param_value,
size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetGLContextInfoKHR_fn)( typedef CL_API_ENTRY cl_int(CL_API_CALL *clGetGLContextInfoKHR_fn)(
const cl_context_properties * properties, const cl_context_properties *properties,
cl_gl_context_info param_name, cl_gl_context_info param_name,
size_t param_value_size, size_t param_value_size,
void * param_value, void *param_value,
size_t * param_value_size_ret); size_t *param_value_size_ret);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -31,7 +31,7 @@ extern "C" {
extern CL_API_ENTRY cl_event CL_API_CALL extern CL_API_ENTRY cl_event CL_API_CALL
clCreateEventFromGLsyncKHR(cl_context context, clCreateEventFromGLsyncKHR(cl_context context,
cl_GLsync sync, cl_GLsync sync,
cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_1; cl_int *errcode_ret) CL_EXT_SUFFIX__VERSION_1_1;
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -41,8 +41,7 @@ extern "C" {
/** /**
* Rounding mode used when converting to cl_half. * Rounding mode used when converting to cl_half.
*/ */
typedef enum typedef enum {
{
CL_HALF_RTE, // round to nearest even CL_HALF_RTE, // round to nearest even
CL_HALF_RTZ, // round towards zero CL_HALF_RTZ, // round towards zero
CL_HALF_RTP, // round towards positive infinity CL_HALF_RTP, // round towards positive infinity
@ -59,20 +58,14 @@ typedef enum
* Utility to deal with values that overflow when converting to half precision. * Utility to deal with values that overflow when converting to half precision.
*/ */
static inline cl_half cl_half_handle_overflow(cl_half_rounding_mode rounding_mode, static inline cl_half cl_half_handle_overflow(cl_half_rounding_mode rounding_mode,
uint16_t sign) uint16_t sign) {
{ if (rounding_mode == CL_HALF_RTZ) {
if (rounding_mode == CL_HALF_RTZ)
{
// Round overflow towards zero -> largest finite number (preserving sign) // Round overflow towards zero -> largest finite number (preserving sign)
return (sign << 15) | CL_HALF_MAX_FINITE_MAG; return (sign << 15) | CL_HALF_MAX_FINITE_MAG;
} } else if (rounding_mode == CL_HALF_RTP && sign) {
else if (rounding_mode == CL_HALF_RTP && sign)
{
// Round negative overflow towards positive infinity -> most negative finite number // Round negative overflow towards positive infinity -> most negative finite number
return (1 << 15) | CL_HALF_MAX_FINITE_MAG; return (1 << 15) | CL_HALF_MAX_FINITE_MAG;
} } else if (rounding_mode == CL_HALF_RTN && !sign) {
else if (rounding_mode == CL_HALF_RTN && !sign)
{
// Round positive overflow towards negative infinity -> largest finite number // Round positive overflow towards negative infinity -> largest finite number
return CL_HALF_MAX_FINITE_MAG; return CL_HALF_MAX_FINITE_MAG;
} }
@ -85,15 +78,11 @@ static inline cl_half cl_half_handle_overflow(cl_half_rounding_mode rounding_mod
* Utility to deal with values that underflow when converting to half precision. * Utility to deal with values that underflow when converting to half precision.
*/ */
static inline cl_half cl_half_handle_underflow(cl_half_rounding_mode rounding_mode, static inline cl_half cl_half_handle_underflow(cl_half_rounding_mode rounding_mode,
uint16_t sign) uint16_t sign) {
{ if (rounding_mode == CL_HALF_RTP && !sign) {
if (rounding_mode == CL_HALF_RTP && !sign)
{
// Round underflow towards positive infinity -> smallest positive value // Round underflow towards positive infinity -> smallest positive value
return (sign << 15) | 1; return (sign << 15) | 1;
} } else if (rounding_mode == CL_HALF_RTN && sign) {
else if (rounding_mode == CL_HALF_RTN && sign)
{
// Round underflow towards negative infinity -> largest negative value // Round underflow towards negative infinity -> largest negative value
return (sign << 15) | 1; return (sign << 15) | 1;
} }
@ -106,11 +95,9 @@ static inline cl_half cl_half_handle_underflow(cl_half_rounding_mode rounding_mo
/** /**
* Convert a cl_float to a cl_half. * Convert a cl_float to a cl_half.
*/ */
static inline cl_half cl_half_from_float(cl_float f, cl_half_rounding_mode rounding_mode) static inline cl_half cl_half_from_float(cl_float f, cl_half_rounding_mode rounding_mode) {
{
// Type-punning to get direct access to underlying bits // Type-punning to get direct access to underlying bits
union union {
{
cl_float f; cl_float f;
uint32_t i; uint32_t i;
} f32; } f32;
@ -133,43 +120,35 @@ static inline cl_half cl_half_from_float(cl_float f, cl_half_rounding_mode round
uint32_t lsb_pos = CL_FLT_MANT_DIG - CL_HALF_MANT_DIG; uint32_t lsb_pos = CL_FLT_MANT_DIG - CL_HALF_MANT_DIG;
// Check for NaN / infinity // Check for NaN / infinity
if (f_exp == 0xFF) if (f_exp == 0xFF) {
{ if (f_mant) {
if (f_mant)
{
// NaN -> propagate mantissa and silence it // NaN -> propagate mantissa and silence it
uint16_t h_mant = (uint16_t)(f_mant >> lsb_pos); uint16_t h_mant = (uint16_t)(f_mant >> lsb_pos);
h_mant |= 0x200; h_mant |= 0x200;
return (sign << 15) | CL_HALF_EXP_MASK | h_mant; return (sign << 15) | CL_HALF_EXP_MASK | h_mant;
} } else {
else
{
// Infinity -> zero mantissa // Infinity -> zero mantissa
return (sign << 15) | CL_HALF_EXP_MASK; return (sign << 15) | CL_HALF_EXP_MASK;
} }
} }
// Check for zero // Check for zero
if (!f_exp && !f_mant) if (!f_exp && !f_mant) {
{
return (sign << 15); return (sign << 15);
} }
// Check for overflow // Check for overflow
if (exp >= CL_HALF_MAX_EXP) if (exp >= CL_HALF_MAX_EXP) {
{
return cl_half_handle_overflow(rounding_mode, sign); return cl_half_handle_overflow(rounding_mode, sign);
} }
// Check for underflow // Check for underflow
if (exp < (CL_HALF_MIN_EXP - CL_HALF_MANT_DIG - 1)) if (exp < (CL_HALF_MIN_EXP - CL_HALF_MANT_DIG - 1)) {
{
return cl_half_handle_underflow(rounding_mode, sign); return cl_half_handle_underflow(rounding_mode, sign);
} }
// Check for value that will become denormal // Check for value that will become denormal
if (exp < -14) if (exp < -14) {
{
// Denormal -> include the implicit 1 from the FP32 mantissa // Denormal -> include the implicit 1 from the FP32 mantissa
h_exp = 0; h_exp = 0;
f_mant |= 1 << (CL_FLT_MANT_DIG - 1); f_mant |= 1 << (CL_FLT_MANT_DIG - 1);
@ -184,16 +163,12 @@ static inline cl_half cl_half_from_float(cl_float f, cl_half_rounding_mode round
// Check whether we need to round // Check whether we need to round
uint32_t halfway = 1 << (lsb_pos - 1); uint32_t halfway = 1 << (lsb_pos - 1);
uint32_t mask = (halfway << 1) - 1; uint32_t mask = (halfway << 1) - 1;
switch (rounding_mode) switch (rounding_mode) {
{
case CL_HALF_RTE: case CL_HALF_RTE:
if ((f_mant & mask) > halfway) if ((f_mant & mask) > halfway) {
{
// More than halfway -> round up // More than halfway -> round up
h_mant += 1; h_mant += 1;
} } else if ((f_mant & mask) == halfway) {
else if ((f_mant & mask) == halfway)
{
// Exactly halfway -> round to nearest even // Exactly halfway -> round to nearest even
if (h_mant & 0x1) if (h_mant & 0x1)
h_mant += 1; h_mant += 1;
@ -203,15 +178,13 @@ static inline cl_half cl_half_from_float(cl_float f, cl_half_rounding_mode round
// Mantissa has already been truncated -> do nothing // Mantissa has already been truncated -> do nothing
break; break;
case CL_HALF_RTP: case CL_HALF_RTP:
if ((f_mant & mask) && !sign) if ((f_mant & mask) && !sign) {
{
// Round positive numbers up // Round positive numbers up
h_mant += 1; h_mant += 1;
} }
break; break;
case CL_HALF_RTN: case CL_HALF_RTN:
if ((f_mant & mask) && sign) if ((f_mant & mask) && sign) {
{
// Round negative numbers down // Round negative numbers down
h_mant += 1; h_mant += 1;
} }
@ -219,8 +192,7 @@ static inline cl_half cl_half_from_float(cl_float f, cl_half_rounding_mode round
} }
// Check for mantissa overflow // Check for mantissa overflow
if (h_mant & 0x400) if (h_mant & 0x400) {
{
h_exp += 1; h_exp += 1;
h_mant = 0; h_mant = 0;
} }
@ -232,11 +204,9 @@ static inline cl_half cl_half_from_float(cl_float f, cl_half_rounding_mode round
/** /**
* Convert a cl_double to a cl_half. * Convert a cl_double to a cl_half.
*/ */
static inline cl_half cl_half_from_double(cl_double d, cl_half_rounding_mode rounding_mode) static inline cl_half cl_half_from_double(cl_double d, cl_half_rounding_mode rounding_mode) {
{
// Type-punning to get direct access to underlying bits // Type-punning to get direct access to underlying bits
union union {
{
cl_double d; cl_double d;
uint64_t i; uint64_t i;
} f64; } f64;
@ -259,43 +229,35 @@ static inline cl_half cl_half_from_double(cl_double d, cl_half_rounding_mode rou
uint32_t lsb_pos = CL_DBL_MANT_DIG - CL_HALF_MANT_DIG; uint32_t lsb_pos = CL_DBL_MANT_DIG - CL_HALF_MANT_DIG;
// Check for NaN / infinity // Check for NaN / infinity
if (d_exp == 0x7FF) if (d_exp == 0x7FF) {
{ if (d_mant) {
if (d_mant)
{
// NaN -> propagate mantissa and silence it // NaN -> propagate mantissa and silence it
uint16_t h_mant = (uint16_t)(d_mant >> lsb_pos); uint16_t h_mant = (uint16_t)(d_mant >> lsb_pos);
h_mant |= 0x200; h_mant |= 0x200;
return (sign << 15) | CL_HALF_EXP_MASK | h_mant; return (sign << 15) | CL_HALF_EXP_MASK | h_mant;
} } else {
else
{
// Infinity -> zero mantissa // Infinity -> zero mantissa
return (sign << 15) | CL_HALF_EXP_MASK; return (sign << 15) | CL_HALF_EXP_MASK;
} }
} }
// Check for zero // Check for zero
if (!d_exp && !d_mant) if (!d_exp && !d_mant) {
{
return (sign << 15); return (sign << 15);
} }
// Check for overflow // Check for overflow
if (exp >= CL_HALF_MAX_EXP) if (exp >= CL_HALF_MAX_EXP) {
{
return cl_half_handle_overflow(rounding_mode, sign); return cl_half_handle_overflow(rounding_mode, sign);
} }
// Check for underflow // Check for underflow
if (exp < (CL_HALF_MIN_EXP - CL_HALF_MANT_DIG - 1)) if (exp < (CL_HALF_MIN_EXP - CL_HALF_MANT_DIG - 1)) {
{
return cl_half_handle_underflow(rounding_mode, sign); return cl_half_handle_underflow(rounding_mode, sign);
} }
// Check for value that will become denormal // Check for value that will become denormal
if (exp < -14) if (exp < -14) {
{
// Include the implicit 1 from the FP64 mantissa // Include the implicit 1 from the FP64 mantissa
h_exp = 0; h_exp = 0;
d_mant |= (uint64_t)1 << (CL_DBL_MANT_DIG - 1); d_mant |= (uint64_t)1 << (CL_DBL_MANT_DIG - 1);
@ -310,16 +272,12 @@ static inline cl_half cl_half_from_double(cl_double d, cl_half_rounding_mode rou
// Check whether we need to round // Check whether we need to round
uint64_t halfway = (uint64_t)1 << (lsb_pos - 1); uint64_t halfway = (uint64_t)1 << (lsb_pos - 1);
uint64_t mask = (halfway << 1) - 1; uint64_t mask = (halfway << 1) - 1;
switch (rounding_mode) switch (rounding_mode) {
{
case CL_HALF_RTE: case CL_HALF_RTE:
if ((d_mant & mask) > halfway) if ((d_mant & mask) > halfway) {
{
// More than halfway -> round up // More than halfway -> round up
h_mant += 1; h_mant += 1;
} } else if ((d_mant & mask) == halfway) {
else if ((d_mant & mask) == halfway)
{
// Exactly halfway -> round to nearest even // Exactly halfway -> round to nearest even
if (h_mant & 0x1) if (h_mant & 0x1)
h_mant += 1; h_mant += 1;
@ -329,15 +287,13 @@ static inline cl_half cl_half_from_double(cl_double d, cl_half_rounding_mode rou
// Mantissa has already been truncated -> do nothing // Mantissa has already been truncated -> do nothing
break; break;
case CL_HALF_RTP: case CL_HALF_RTP:
if ((d_mant & mask) && !sign) if ((d_mant & mask) && !sign) {
{
// Round positive numbers up // Round positive numbers up
h_mant += 1; h_mant += 1;
} }
break; break;
case CL_HALF_RTN: case CL_HALF_RTN:
if ((d_mant & mask) && sign) if ((d_mant & mask) && sign) {
{
// Round negative numbers down // Round negative numbers down
h_mant += 1; h_mant += 1;
} }
@ -345,8 +301,7 @@ static inline cl_half cl_half_from_double(cl_double d, cl_half_rounding_mode rou
} }
// Check for mantissa overflow // Check for mantissa overflow
if (h_mant & 0x400) if (h_mant & 0x400) {
{
h_exp += 1; h_exp += 1;
h_mant = 0; h_mant = 0;
} }
@ -358,11 +313,9 @@ static inline cl_half cl_half_from_double(cl_double d, cl_half_rounding_mode rou
/** /**
* Convert a cl_half to a cl_float. * Convert a cl_half to a cl_float.
*/ */
static inline cl_float cl_half_to_float(cl_half h) static inline cl_float cl_half_to_float(cl_half h) {
{
// Type-punning to get direct access to underlying bits // Type-punning to get direct access to underlying bits
union union {
{
cl_float f; cl_float f;
uint32_t i; uint32_t i;
} f32; } f32;
@ -381,18 +334,14 @@ static inline cl_float cl_half_to_float(cl_half h)
uint32_t f_exp = exp + CL_FLT_MAX_EXP - 1; uint32_t f_exp = exp + CL_FLT_MAX_EXP - 1;
// Check for NaN / infinity // Check for NaN / infinity
if (h_exp == 0x1F) if (h_exp == 0x1F) {
{ if (h_mant) {
if (h_mant)
{
// NaN -> propagate mantissa and silence it // NaN -> propagate mantissa and silence it
uint32_t f_mant = h_mant << (CL_FLT_MANT_DIG - CL_HALF_MANT_DIG); uint32_t f_mant = h_mant << (CL_FLT_MANT_DIG - CL_HALF_MANT_DIG);
f_mant |= 0x400000; f_mant |= 0x400000;
f32.i = (sign << 31) | 0x7F800000 | f_mant; f32.i = (sign << 31) | 0x7F800000 | f_mant;
return f32.f; return f32.f;
} } else {
else
{
// Infinity -> zero mantissa // Infinity -> zero mantissa
f32.i = (sign << 31) | 0x7F800000; f32.i = (sign << 31) | 0x7F800000;
return f32.f; return f32.f;
@ -400,21 +349,16 @@ static inline cl_float cl_half_to_float(cl_half h)
} }
// Check for zero / denormal // Check for zero / denormal
if (h_exp == 0) if (h_exp == 0) {
{ if (h_mant == 0) {
if (h_mant == 0)
{
// Zero -> zero exponent // Zero -> zero exponent
f_exp = 0; f_exp = 0;
} } else {
else
{
// Denormal -> normalize it // Denormal -> normalize it
// - Shift mantissa to make most-significant 1 implicit // - Shift mantissa to make most-significant 1 implicit
// - Adjust exponent accordingly // - Adjust exponent accordingly
uint32_t shift = 0; uint32_t shift = 0;
while ((h_mant & 0x400) == 0) while ((h_mant & 0x400) == 0) {
{
h_mant <<= 1; h_mant <<= 1;
shift++; shift++;
} }

View file

@ -163,10 +163,10 @@ typedef CL_API_ENTRY cl_mem(CL_API_CALL *cl_api_clCreateImageWithProperties)(
const cl_image_format *image_format, const cl_image_desc *image_desc, const cl_image_format *image_format, const cl_image_desc *image_desc,
void *host_ptr, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_3_0; void *host_ptr, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_3_0;
typedef CL_API_ENTRY cl_int(CL_API_CALL* cl_api_clSetContextDestructorCallback)( typedef CL_API_ENTRY cl_int(CL_API_CALL *cl_api_clSetContextDestructorCallback)(
cl_context context, cl_context context,
void(CL_CALLBACK* pfn_notify)(cl_context context, void* user_data), void(CL_CALLBACK *pfn_notify)(cl_context context, void *user_data),
void* user_data) CL_API_SUFFIX__VERSION_3_0; void *user_data) CL_API_SUFFIX__VERSION_3_0;
#else #else
@ -428,10 +428,10 @@ typedef CL_API_ENTRY cl_int(CL_API_CALL *cl_api_clGetEventInfo)(
void *param_value, size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; void *param_value, size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_int(CL_API_CALL *cl_api_clRetainEvent)(cl_event event) typedef CL_API_ENTRY cl_int(CL_API_CALL *cl_api_clRetainEvent)(cl_event event)
CL_API_SUFFIX__VERSION_1_0; CL_API_SUFFIX__VERSION_1_0;
typedef CL_API_ENTRY cl_int(CL_API_CALL *cl_api_clReleaseEvent)(cl_event event) typedef CL_API_ENTRY cl_int(CL_API_CALL *cl_api_clReleaseEvent)(cl_event event)
CL_API_SUFFIX__VERSION_1_0; CL_API_SUFFIX__VERSION_1_0;
// Profiling APIs // Profiling APIs
typedef CL_API_ENTRY cl_int(CL_API_CALL *cl_api_clGetEventProfilingInfo)( typedef CL_API_ENTRY cl_int(CL_API_CALL *cl_api_clGetEventProfilingInfo)(
@ -704,7 +704,7 @@ typedef void *cl_api_clEnqueueSVMUnmap;
typedef CL_API_ENTRY cl_int(CL_API_CALL *cl_api_clSetCommandQueueProperty)( typedef CL_API_ENTRY cl_int(CL_API_CALL *cl_api_clSetCommandQueueProperty)(
cl_command_queue command_queue, cl_command_queue_properties properties, cl_command_queue command_queue, cl_command_queue_properties properties,
cl_bool enable, cl_command_queue_properties *old_properties) cl_bool enable, cl_command_queue_properties *old_properties)
CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED; CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED;
typedef CL_API_ENTRY cl_mem(CL_API_CALL *cl_api_clCreateImage2D)( typedef CL_API_ENTRY cl_mem(CL_API_CALL *cl_api_clCreateImage2D)(
cl_context context, cl_mem_flags flags, const cl_image_format *image_format, cl_context context, cl_mem_flags flags, const cl_image_format *image_format,
@ -718,7 +718,7 @@ typedef CL_API_ENTRY cl_mem(CL_API_CALL *cl_api_clCreateImage3D)(
cl_int *errcode_ret) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; cl_int *errcode_ret) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
typedef CL_API_ENTRY cl_int(CL_API_CALL *cl_api_clUnloadCompiler)(void) typedef CL_API_ENTRY cl_int(CL_API_CALL *cl_api_clUnloadCompiler)(void)
CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
typedef CL_API_ENTRY cl_int(CL_API_CALL *cl_api_clEnqueueMarker)( typedef CL_API_ENTRY cl_int(CL_API_CALL *cl_api_clEnqueueMarker)(
cl_command_queue command_queue, cl_command_queue command_queue,

File diff suppressed because it is too large Load diff

View file

@ -88,69 +88,69 @@ extern CL_API_ENTRY cl_int CL_API_CALL
clGetDeviceIDsFromVA_APIMediaAdapterINTEL( clGetDeviceIDsFromVA_APIMediaAdapterINTEL(
cl_platform_id platform, cl_platform_id platform,
cl_va_api_device_source_intel media_adapter_type, cl_va_api_device_source_intel media_adapter_type,
void* media_adapter, void *media_adapter,
cl_va_api_device_set_intel media_adapter_set, cl_va_api_device_set_intel media_adapter_set,
cl_uint num_entries, cl_uint num_entries,
cl_device_id* devices, cl_device_id *devices,
cl_uint* num_devices) CL_EXT_SUFFIX__VERSION_1_2; cl_uint *num_devices) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int (CL_API_CALL * clGetDeviceIDsFromVA_APIMediaAdapterINTEL_fn)( typedef CL_API_ENTRY cl_int(CL_API_CALL *clGetDeviceIDsFromVA_APIMediaAdapterINTEL_fn)(
cl_platform_id platform, cl_platform_id platform,
cl_va_api_device_source_intel media_adapter_type, cl_va_api_device_source_intel media_adapter_type,
void* media_adapter, void *media_adapter,
cl_va_api_device_set_intel media_adapter_set, cl_va_api_device_set_intel media_adapter_set,
cl_uint num_entries, cl_uint num_entries,
cl_device_id* devices, cl_device_id *devices,
cl_uint* num_devices) CL_EXT_SUFFIX__VERSION_1_2; cl_uint *num_devices) CL_EXT_SUFFIX__VERSION_1_2;
extern CL_API_ENTRY cl_mem CL_API_CALL extern CL_API_ENTRY cl_mem CL_API_CALL
clCreateFromVA_APIMediaSurfaceINTEL( clCreateFromVA_APIMediaSurfaceINTEL(
cl_context context, cl_context context,
cl_mem_flags flags, cl_mem_flags flags,
VASurfaceID* surface, VASurfaceID *surface,
cl_uint plane, cl_uint plane,
cl_int* errcode_ret) CL_EXT_SUFFIX__VERSION_1_2; cl_int *errcode_ret) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_mem (CL_API_CALL * clCreateFromVA_APIMediaSurfaceINTEL_fn)( typedef CL_API_ENTRY cl_mem(CL_API_CALL *clCreateFromVA_APIMediaSurfaceINTEL_fn)(
cl_context context, cl_context context,
cl_mem_flags flags, cl_mem_flags flags,
VASurfaceID* surface, VASurfaceID *surface,
cl_uint plane, cl_uint plane,
cl_int* errcode_ret) CL_EXT_SUFFIX__VERSION_1_2; cl_int *errcode_ret) CL_EXT_SUFFIX__VERSION_1_2;
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueAcquireVA_APIMediaSurfacesINTEL( clEnqueueAcquireVA_APIMediaSurfacesINTEL(
cl_command_queue command_queue, cl_command_queue command_queue,
cl_uint num_objects, cl_uint num_objects,
const cl_mem* mem_objects, const cl_mem *mem_objects,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event* event_wait_list, const cl_event *event_wait_list,
cl_event* event) CL_EXT_SUFFIX__VERSION_1_2; cl_event *event) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireVA_APIMediaSurfacesINTEL_fn)( typedef CL_API_ENTRY cl_int(CL_API_CALL *clEnqueueAcquireVA_APIMediaSurfacesINTEL_fn)(
cl_command_queue command_queue, cl_command_queue command_queue,
cl_uint num_objects, cl_uint num_objects,
const cl_mem* mem_objects, const cl_mem *mem_objects,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event* event_wait_list, const cl_event *event_wait_list,
cl_event* event) CL_EXT_SUFFIX__VERSION_1_2; cl_event *event) CL_EXT_SUFFIX__VERSION_1_2;
extern CL_API_ENTRY cl_int CL_API_CALL extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueReleaseVA_APIMediaSurfacesINTEL( clEnqueueReleaseVA_APIMediaSurfacesINTEL(
cl_command_queue command_queue, cl_command_queue command_queue,
cl_uint num_objects, cl_uint num_objects,
const cl_mem* mem_objects, const cl_mem *mem_objects,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event* event_wait_list, const cl_event *event_wait_list,
cl_event* event) CL_EXT_SUFFIX__VERSION_1_2; cl_event *event) CL_EXT_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseVA_APIMediaSurfacesINTEL_fn)( typedef CL_API_ENTRY cl_int(CL_API_CALL *clEnqueueReleaseVA_APIMediaSurfacesINTEL_fn)(
cl_command_queue command_queue, cl_command_queue command_queue,
cl_uint num_objects, cl_uint num_objects,
const cl_mem* mem_objects, const cl_mem *mem_objects,
cl_uint num_events_in_wait_list, cl_uint num_events_in_wait_list,
const cl_event* event_wait_list, const cl_event *event_wait_list,
cl_event* event) CL_EXT_SUFFIX__VERSION_1_2; cl_event *event) CL_EXT_SUFFIX__VERSION_1_2;
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -4,16 +4,14 @@
//#if FORCE_HITAG2_FULL == 0 //#if FORCE_HITAG2_FULL == 0
// return a single bit from a value // return a single bit from a value
int bitn (uint64_t x, int bit) int bitn(uint64_t x, int bit) {
{
const uint64_t bitmask = (uint64_t)(1) << bit; const uint64_t bitmask = (uint64_t)(1) << bit;
return (x & bitmask) ? 1 : 0; return (x & bitmask) ? 1 : 0;
} }
// the sub-function R that rollback depends upon // the sub-function R that rollback depends upon
int fnR (uint64_t x) int fnR(uint64_t x) {
{
// renumbered bits because my state is 0-47, not 1-48 // renumbered bits because my state is 0-47, not 1-48
return (bitn(x, 1) ^ bitn(x, 2) ^ bitn(x, 5) ^ return (bitn(x, 1) ^ bitn(x, 2) ^ bitn(x, 5) ^
bitn(x, 6) ^ bitn(x, 7) ^ bitn(x, 15) ^ bitn(x, 6) ^ bitn(x, 7) ^ bitn(x, 15) ^
@ -32,8 +30,7 @@ int fb(unsigned int i) {
} }
// the filter function that generates a bit of output from the prng state // the filter function that generates a bit of output from the prng state
int fnf (uint64_t s) int fnf(uint64_t s) {
{
const unsigned int x1 = (unsigned int)((bitn(s, 2) << 0) | (bitn(s, 3) << 1) | (bitn(s, 5) << 2) | (bitn(s, 6) << 3)); const unsigned int x1 = (unsigned int)((bitn(s, 2) << 0) | (bitn(s, 3) << 1) | (bitn(s, 5) << 2) | (bitn(s, 6) << 3));
const unsigned int x2 = (unsigned int)((bitn(s, 8) << 0) | (bitn(s, 12) << 1) | (bitn(s, 14) << 2) | (bitn(s, 15) << 3)); const unsigned int x2 = (unsigned int)((bitn(s, 8) << 0) | (bitn(s, 12) << 1) | (bitn(s, 14) << 2) | (bitn(s, 15) << 3));
const unsigned int x3 = (unsigned int)((bitn(s, 17) << 0) | (bitn(s, 21) << 1) | (bitn(s, 23) << 2) | (bitn(s, 26) << 3)); const unsigned int x3 = (unsigned int)((bitn(s, 17) << 0) | (bitn(s, 21) << 1) | (bitn(s, 23) << 2) | (bitn(s, 26) << 3));
@ -42,10 +39,10 @@ int fnf (uint64_t s)
const unsigned int x6 = (unsigned int)((fa(x1) << 0) | (fb(x2) << 1) | (fb(x3) << 2) | (fb(x4) << 3) | (fa(x5) << 4)); const unsigned int x6 = (unsigned int)((fa(x1) << 0) | (fb(x2) << 1) | (fb(x3) << 2) | (fb(x4) << 3) | (fa(x5) << 4));
return bitn (0x7907287B, (int) x6); return bitn(0x7907287B, (int) x6);
} }
uint32_t hitag2_crypt (uint64_t x) { uint32_t hitag2_crypt(uint64_t x) {
const uint32_t ht2_function4a = 0x2C79; // 0010 1100 0111 1001 const uint32_t ht2_function4a = 0x2C79; // 0010 1100 0111 1001
const uint32_t ht2_function4b = 0x6671; // 0110 0110 0111 0001 const uint32_t ht2_function4b = 0x6671; // 0110 0110 0111 0001
const uint32_t ht2_function5c = 0x7907287B; // 0111 1001 0000 0111 0010 1000 0111 1011 const uint32_t ht2_function5c = 0x7907287B; // 0111 1001 0000 0111 0010 1000 0111 1011
@ -58,9 +55,9 @@ uint32_t hitag2_crypt (uint64_t x) {
bitindex |= ((ht2_function4b << 3) >> pickbits2_1_1(x, 27, 30, 32)) & 0x08; bitindex |= ((ht2_function4b << 3) >> pickbits2_1_1(x, 27, 30, 32)) & 0x08;
bitindex |= ((ht2_function4a << 4) >> pickbits1_2_1(x, 33, 42, 45)) & 0x10; bitindex |= ((ht2_function4a << 4) >> pickbits1_2_1(x, 33, 42, 45)) & 0x10;
#if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1 #if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1
printf ("hitag2_crypt bitindex = %02x\n", bitindex); printf("hitag2_crypt bitindex = %02x\n", bitindex);
#endif #endif
return (ht2_function5c >> bitindex) & 1; return (ht2_function5c >> bitindex) & 1;
} }
@ -99,13 +96,13 @@ uint32_t hitag2_nstep(Hitag_State *pstate, uint32_t steps) {
} }
} while (--steps); } while (--steps);
#if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1 #if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1
#ifdef _ISOC99_SOURCE #ifdef _ISOC99_SOURCE
printf ("hitag2_nstep cur_state = %012I64x, result %02x\n", cur_state, result); printf("hitag2_nstep cur_state = %012I64x, result %02x\n", cur_state, result);
#else #else
printf ("hitag2_nstep cur_state = %012" STR(OFF_FORMAT_X) ", result %02x\n", cur_state, result); printf("hitag2_nstep cur_state = %012" STR(OFF_FORMAT_X) ", result %02x\n", cur_state, result);
#endif #endif
#endif // DEBUG_HITAG2 #endif // DEBUG_HITAG2
pstate->shiftreg = cur_state; pstate->shiftreg = cur_state;
pstate->lfsr = lfsr; pstate->lfsr = lfsr;
@ -119,13 +116,12 @@ uint32_t hitag2_nstep(Hitag_State *pstate, uint32_t steps) {
* uint32_t serialnum - 32 bit tag serial number * uint32_t serialnum - 32 bit tag serial number
* uint32_t initvector - 32 bit random IV from reader, part of tag authentication * uint32_t initvector - 32 bit random IV from reader, part of tag authentication
*/ */
void hitag2_init (Hitag_State *pstate, uint64_t sharedkey, uint32_t serialnum, uint32_t initvector) void hitag2_init(Hitag_State *pstate, uint64_t sharedkey, uint32_t serialnum, uint32_t initvector) {
{
// init state, from serial number and lowest 16 bits of shared key // init state, from serial number and lowest 16 bits of shared key
uint64_t cur_state = ((sharedkey & 0xFFFF) << 32) | serialnum; uint64_t cur_state = ((sharedkey & 0xFFFF) << 32) | serialnum;
// mix the initialisation vector and highest 32 bits of the shared key // mix the initialisation vector and highest 32 bits of the shared key
initvector ^= (uint32_t) (sharedkey >> 16); initvector ^= (uint32_t)(sharedkey >> 16);
// move 16 bits from (IV xor Shared Key) to top of uint64_t state // move 16 bits from (IV xor Shared Key) to top of uint64_t state
// these will be XORed in turn with output of the crypto function // these will be XORed in turn with output of the crypto function
@ -145,16 +141,16 @@ void hitag2_init (Hitag_State *pstate, uint64_t sharedkey, uint32_t serialnum, u
for (i = 0; i < 15; i++) cur_state = (cur_state >> 1) ^ (uint64_t) hitag2_crypt(cur_state) << 46; for (i = 0; i < 15; i++) cur_state = (cur_state >> 1) ^ (uint64_t) hitag2_crypt(cur_state) << 46;
cur_state ^= (uint64_t) hitag2_crypt (cur_state) << 47; cur_state ^= (uint64_t) hitag2_crypt(cur_state) << 47;
pstate->shiftreg = cur_state; pstate->shiftreg = cur_state;
#if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1 #if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1
#ifdef _ISOC99_SOURCE #ifdef _ISOC99_SOURCE
printf ("hitag2_init shiftreg = %012I64x\n", pstate->shiftreg); printf("hitag2_init shiftreg = %012I64x\n", pstate->shiftreg);
#else #else
printf ("hitag2_init shiftreg = %012" STR(OFF_FORMAT_X) "\n", pstate->shiftreg); printf("hitag2_init shiftreg = %012" STR(OFF_FORMAT_X) "\n", pstate->shiftreg);
#endif #endif
#endif // DEBUG_HITAG2 #endif // DEBUG_HITAG2
/* naive version for reference, LFSR has 16 taps /* naive version for reference, LFSR has 16 taps
pstate->lfsr = state ^ (state >> 2) ^ (state >> 3) ^ (state >> 6) pstate->lfsr = state ^ (state >> 2) ^ (state >> 3) ^ (state >> 6)
@ -170,24 +166,23 @@ void hitag2_init (Hitag_State *pstate, uint64_t sharedkey, uint32_t serialnum, u
(cur_state >> 26) ^ (cur_state >> 30) ^ (cur_state >> 41) ^ (cur_state >> 26) ^ (cur_state >> 30) ^ (cur_state >> 41) ^
(temp >> 2) ^ (temp >> 7) ^ (temp >> 22) ^ (temp >> 42) ^ (temp >> 46); (temp >> 2) ^ (temp >> 7) ^ (temp >> 22) ^ (temp >> 42) ^ (temp >> 46);
#if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1 #if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1
#ifdef _ISOC99_SOURCE #ifdef _ISOC99_SOURCE
printf ("hitag2_init lfsr = %012I64x\n", pstate->lfsr); printf("hitag2_init lfsr = %012I64x\n", pstate->lfsr);
#else #else
printf ("hitag2_init lfsr = %012" STR(OFF_FORMAT_X) "\n", pstate->lfsr); printf("hitag2_init lfsr = %012" STR(OFF_FORMAT_X) "\n", pstate->lfsr);
#endif #endif
#endif // DEBUG_HITAG2 #endif // DEBUG_HITAG2
} }
// try state // try state
// todo, changes arguments, only what is needed // todo, changes arguments, only what is needed
bool try_state (uint64_t s, uint32_t uid, uint32_t aR2, uint32_t nR1, uint32_t nR2, uint64_t *key) bool try_state(uint64_t s, uint32_t uid, uint32_t aR2, uint32_t nR1, uint32_t nR2, uint64_t *key) {
{ #if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1
#if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1 printf("s : %lu, uid: %u, aR2: %u, nR1: %u, nR2: %u\n", s, uid, aR2, nR1, nR2);
printf ("s : %lu, uid: %u, aR2: %u, nR1: %u, nR2: %u\n", s, uid, aR2, nR1, nR2); fflush(stdout);
fflush (stdout); #endif
#endif
Hitag_State hstate; Hitag_State hstate;
uint64_t keyrev, nR1xk; uint64_t keyrev, nR1xk;
@ -199,56 +194,54 @@ bool try_state (uint64_t s, uint32_t uid, uint32_t aR2, uint32_t nR1, uint32_t n
hstate.shiftreg = (uint64_t)(((hstate.shiftreg << 1) & 0xffffffffffff) | (uint64_t)fnR(hstate.shiftreg)); hstate.shiftreg = (uint64_t)(((hstate.shiftreg << 1) & 0xffffffffffff) | (uint64_t)fnR(hstate.shiftreg));
hstate.shiftreg = (uint64_t)(((hstate.shiftreg << 1) & 0xffffffffffff) | (uint64_t)fnR(hstate.shiftreg)); hstate.shiftreg = (uint64_t)(((hstate.shiftreg << 1) & 0xffffffffffff) | (uint64_t)fnR(hstate.shiftreg));
#if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1 #if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1
printf ("shiftreg : %lu\n", hstate.shiftreg); printf("shiftreg : %lu\n", hstate.shiftreg);
fflush (stdout); fflush(stdout);
#endif #endif
// recover key // recover key
keyrev = hstate.shiftreg & 0xffff; keyrev = hstate.shiftreg & 0xffff;
nR1xk = (hstate.shiftreg >> 16) & 0xffffffff; nR1xk = (hstate.shiftreg >> 16) & 0xffffffff;
#if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1 #if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1
printf ("keyrev: %lu, nR1xk: %lu\n", keyrev, nR1xk); printf("keyrev: %lu, nR1xk: %lu\n", keyrev, nR1xk);
fflush (stdout); fflush(stdout);
#endif #endif
for (int i = 0; i < 32; i++) for (int i = 0; i < 32; i++) {
{
hstate.shiftreg = ((hstate.shiftreg) << 1) | ((uid >> (31 - i)) & 0x1); hstate.shiftreg = ((hstate.shiftreg) << 1) | ((uid >> (31 - i)) & 0x1);
b = (b << 1) | (unsigned int) fnf(hstate.shiftreg); b = (b << 1) | (unsigned int) fnf(hstate.shiftreg);
} }
#if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1 #if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1
printf ("shiftreg: %lu\n", hstate.shiftreg); printf("shiftreg: %lu\n", hstate.shiftreg);
fflush (stdout); fflush(stdout);
#endif #endif
keyrev |= (nR1xk ^ nR1 ^ b) << 16; keyrev |= (nR1xk ^ nR1 ^ b) << 16;
#if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1 #if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1
printf ("keyrev: %lu\n", keyrev); printf("keyrev: %lu\n", keyrev);
fflush (stdout); fflush(stdout);
#endif #endif
// test key // test key
hitag2_init (&hstate, keyrev, uid, nR2); hitag2_init(&hstate, keyrev, uid, nR2);
if ((aR2 ^ hitag2_nstep (&hstate, 32)) == 0xffffffff) if ((aR2 ^ hitag2_nstep(&hstate, 32)) == 0xffffffff) {
{ *key = rev64(keyrev);
*key = rev64 (keyrev);
#if DEBUGME >= 2 #if DEBUGME >= 2
#if ENABLE_EMOJ == 1 #if ENABLE_EMOJ == 1
printf ("\nKey found ╭☞ "); printf("\nKey found ╭☞ ");
#else #else
printf ("\nKey found: "); printf("\nKey found: ");
#endif #endif
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
printf ("%02X", (uint8_t)(*key & 0xff)); printf("%02X", (uint8_t)(*key & 0xff));
*key = *key >> 8; *key = *key >> 8;
} }
printf ("\n"); printf("\n");
#endif #endif
return true; return true;
} }

View file

@ -27,17 +27,16 @@
#define rev32(X) (rev16(X) + (rev16(X >> 16) << 16)) #define rev32(X) (rev16(X) + (rev16(X >> 16) << 16))
#define rev64(X) (rev32(X) + (rev32(X >> 32) << 32)) #define rev64(X) (rev32(X) + (rev32(X >> 32) << 32))
typedef struct typedef struct {
{
uint64_t shiftreg; // naive shift register, required for nonlinear fn input uint64_t shiftreg; // naive shift register, required for nonlinear fn input
uint64_t lfsr; // fast lfsr, used to make software faster uint64_t lfsr; // fast lfsr, used to make software faster
} Hitag_State; } Hitag_State;
// return a single bit from a value // return a single bit from a value
int bitn (uint64_t x, int bit); int bitn(uint64_t x, int bit);
// the sub-function R that rollback depends upon // the sub-function R that rollback depends upon
int fnR (uint64_t x); int fnR(uint64_t x);
// the three filter sub-functions that feed fnf // the three filter sub-functions that feed fnf
int fa(unsigned int i); int fa(unsigned int i);
@ -45,7 +44,7 @@ int fa(unsigned int i);
int fb(unsigned int i); int fb(unsigned int i);
// the filter function that generates a bit of output from the prng state // the filter function that generates a bit of output from the prng state
int fnf (uint64_t s); int fnf(uint64_t s);
// macros to pick out 4 bits in various patterns of 1s & 2s & make a new number // macros to pick out 4 bits in various patterns of 1s & 2s & make a new number
#define pickbits2_2(S, A, B) ( ((S >> A) & 3) | ((S >> (B - 2)) & 0xC) ) #define pickbits2_2(S, A, B) ( ((S >> A) & 3) | ((S >> (B - 2)) & 0xC) )
@ -54,7 +53,7 @@ int fnf (uint64_t s);
#define pickbits2_1_1(S, A, B, C) ( ((S >> A) & 3) | ((S >> (B - 2)) & 4) | ((S >> (C - 3)) & 8) ) #define pickbits2_1_1(S, A, B, C) ( ((S >> A) & 3) | ((S >> (B - 2)) & 4) | ((S >> (C - 3)) & 8) )
#define pickbits1_2_1(S, A, B, C) ( ((S >> A) & 1) | ((S >> (B - 1)) & 6) | ((S >> (C - 3)) & 8) ) #define pickbits1_2_1(S, A, B, C) ( ((S >> A) & 1) | ((S >> (B - 1)) & 6) | ((S >> (C - 3)) & 8) )
uint32_t hitag2_crypt (uint64_t x); uint32_t hitag2_crypt(uint64_t x);
/* /*
* Return up to 32 crypto bits. * Return up to 32 crypto bits.
@ -76,9 +75,9 @@ uint32_t hitag2_nstep(Hitag_State *pstate, uint32_t steps);
* uint32_t serialnum - 32 bit tag serial number * uint32_t serialnum - 32 bit tag serial number
* uint32_t initvector - 32 bit random IV from reader, part of tag authentication * uint32_t initvector - 32 bit random IV from reader, part of tag authentication
*/ */
void hitag2_init (Hitag_State *pstate, uint64_t sharedkey, uint32_t serialnum, uint32_t initvector); void hitag2_init(Hitag_State *pstate, uint64_t sharedkey, uint32_t serialnum, uint32_t initvector);
// try_state // try_state
bool try_state (uint64_t s, uint32_t uid, uint32_t aR2, uint32_t nR1, uint32_t nR2, uint64_t *key); bool try_state(uint64_t s, uint32_t uid, uint32_t aR2, uint32_t nR1, uint32_t nR2, uint64_t *key);
#endif // HITAG2_H #endif // HITAG2_H

File diff suppressed because it is too large Load diff

View file

@ -24,133 +24,121 @@ License: GNU General Public License v3 or any later version (see LICENSE.txt)
#include "opencl.h" #include "opencl.h"
bool plat_dev_enabled (unsigned int id, unsigned int *sel, unsigned int cnt, unsigned int cur_type, unsigned int allow_type) bool plat_dev_enabled(unsigned int id, unsigned int *sel, unsigned int cnt, unsigned int cur_type, unsigned int allow_type) {
{
// usefull only with devices // usefull only with devices
if (allow_type != CL_DEVICE_TYPE_ALL) if (allow_type != CL_DEVICE_TYPE_ALL) {
{
if (cur_type != allow_type) return false; if (cur_type != allow_type) return false;
} }
if (sel[0] == 0xff) return true; // all if (sel[0] == 0xff) return true; // all
else else {
{ for (unsigned int i = 0; i < cnt; i++) {
for (unsigned int i = 0; i < cnt; i++) if (sel[i] == (id + 1)) return true;
{
if (sel[i] == (id+1)) return true;
} }
} }
return false; return false;
} }
int runKernel (opencl_ctx_t *ctx, uint32_t cand_base, uint64_t *matches, uint32_t *matches_found, size_t id) int runKernel(opencl_ctx_t *ctx, uint32_t cand_base, uint64_t *matches, uint32_t *matches_found, size_t id) {
{
int err = 0; int err = 0;
size_t global_ws[3] = { ctx->global_ws[id], GLOBAL_WS_1, GLOBAL_WS_2 }; size_t global_ws[3] = { ctx->global_ws[id], GLOBAL_WS_1, GLOBAL_WS_2 };
size_t local_ws[3] = { ctx->local_ws[id], 1, 1 }; size_t local_ws[3] = { ctx->local_ws[id], 1, 1 };
if (ctx->profiling) if (ctx->profiling) {
{ printf("[%zu] global_ws %zu, ctx->local_ws: %zu\n", id, global_ws[0], local_ws[0]);
printf ("[%zu] global_ws %zu, ctx->local_ws: %zu\n", id, global_ws[0], local_ws[0]); fflush(stdout);
fflush (stdout);
} }
*matches_found = 0; *matches_found = 0;
// Write our data set into the input array in device memory // Write our data set into the input array in device memory
err = clEnqueueWriteBuffer (ctx->commands[id], ctx->matches_found[id], CL_TRUE, 0, sizeof(uint32_t), matches_found, 0, NULL, NULL); err = clEnqueueWriteBuffer(ctx->commands[id], ctx->matches_found[id], CL_TRUE, 0, sizeof(uint32_t), matches_found, 0, NULL, NULL);
if (err != CL_SUCCESS) { if (err != CL_SUCCESS) {
printf ("[%zu] Error: clEnqueueWriteBuffer (matches_found) failed (%d)\n", id, err); printf("[%zu] Error: clEnqueueWriteBuffer (matches_found) failed (%d)\n", id, err);
return -1; return -1;
} }
// Set the arguments to our compute kernel // Set the arguments to our compute kernel
err = clSetKernelArg (ctx->kernels[id], 0, sizeof(uint32_t), &cand_base); err = clSetKernelArg(ctx->kernels[id], 0, sizeof(uint32_t), &cand_base);
err |= clSetKernelArg (ctx->kernels[id], 4, sizeof(cl_mem), &ctx->matches_found[id]); err |= clSetKernelArg(ctx->kernels[id], 4, sizeof(cl_mem), &ctx->matches_found[id]);
if (err != CL_SUCCESS) { if (err != CL_SUCCESS) {
printf ("[%zu] Error: clSetKernelArg (cand_base|ctx->matches_found) failed (%d)\n", id, err); printf("[%zu] Error: clSetKernelArg (cand_base|ctx->matches_found) failed (%d)\n", id, err);
return -1; return -1;
} }
cl_event event; cl_event event;
err = clEnqueueNDRangeKernel (ctx->commands[id], ctx->kernels[id], 2, NULL, global_ws, local_ws, 0, NULL, &event); err = clEnqueueNDRangeKernel(ctx->commands[id], ctx->kernels[id], 2, NULL, global_ws, local_ws, 0, NULL, &event);
if (err != CL_SUCCESS) { if (err != CL_SUCCESS) {
printf ("[%zu] Error: clEnqueueNDRangeKernel() failed (%d)\n", id, err); printf("[%zu] Error: clEnqueueNDRangeKernel() failed (%d)\n", id, err);
return -1; return -1;
} }
// todo, check if is possible remove // todo, check if is possible remove
err = clFlush (ctx->commands[id]); err = clFlush(ctx->commands[id]);
if (err != CL_SUCCESS) { if (err != CL_SUCCESS) {
printf ("[%zu] Error: clFlush() failed (%d)\n", id, err); printf("[%zu] Error: clFlush() failed (%d)\n", id, err);
return -1; return -1;
} }
if (ctx->profiling) if (ctx->profiling) {
{ err = clWaitForEvents(1, &event);
err = clWaitForEvents (1, &event);
if (err != CL_SUCCESS) { if (err != CL_SUCCESS) {
printf ("[%zu] Error: clWaitForEvents() failed (%d)\n", id, err); printf("[%zu] Error: clWaitForEvents() failed (%d)\n", id, err);
return -1; return -1;
} }
cl_ulong gpu_t_start = 0, gpu_t_end = 0; cl_ulong gpu_t_start = 0, gpu_t_end = 0;
err = clGetEventProfilingInfo (event, CL_PROFILING_COMMAND_START, sizeof (cl_ulong), &gpu_t_start, NULL); err = clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_START, sizeof(cl_ulong), &gpu_t_start, NULL);
err |= clGetEventProfilingInfo (event, CL_PROFILING_COMMAND_END, sizeof (cl_ulong), &gpu_t_end, NULL); err |= clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_END, sizeof(cl_ulong), &gpu_t_end, NULL);
if (err != CL_SUCCESS) { if (err != CL_SUCCESS) {
printf ("[%zu] Error: clGetEventOPENCL_PROFILINGInfo() failed (%d)\n", id, err); printf("[%zu] Error: clGetEventOPENCL_PROFILINGInfo() failed (%d)\n", id, err);
return -1; return -1;
} }
const double time_ms = (double) (gpu_t_end - gpu_t_start) / 1000000; const double time_ms = (double)(gpu_t_end - gpu_t_start) / 1000000;
printf ("[%zu] kernel exec time (ms): %.2f]\n", id, time_ms); printf("[%zu] kernel exec time (ms): %.2f]\n", id, time_ms);
fflush (stdout); fflush(stdout);
} }
err = clReleaseEvent (event); err = clReleaseEvent(event);
if (err != CL_SUCCESS) { if (err != CL_SUCCESS) {
printf ("[%zu] Error: clReleaseEvent() failed (%d)\n", id, err); printf("[%zu] Error: clReleaseEvent() failed (%d)\n", id, err);
return -1; return -1;
} }
// Wait for the command commands to get serviced before reading back results // Wait for the command commands to get serviced before reading back results
// todo, check if is possible remove, because of blocking clEnqueueReadBuffer (CL_TRUE) // todo, check if is possible remove, because of blocking clEnqueueReadBuffer (CL_TRUE)
err = clFinish (ctx->commands[id]); err = clFinish(ctx->commands[id]);
if (err != CL_SUCCESS) { if (err != CL_SUCCESS) {
printf ("[%zu] Error: clFinish() failed (%d)\n", id, err); printf("[%zu] Error: clFinish() failed (%d)\n", id, err);
return -1; return -1;
} }
// read back the matches counter first // read back the matches counter first
err = clEnqueueReadBuffer (ctx->commands[id], ctx->matches_found[id], CL_TRUE, 0, sizeof(uint32_t), matches_found, 0, NULL, NULL); err = clEnqueueReadBuffer(ctx->commands[id], ctx->matches_found[id], CL_TRUE, 0, sizeof(uint32_t), matches_found, 0, NULL, NULL);
if (err != CL_SUCCESS) { if (err != CL_SUCCESS) {
printf ("[%zu] Error: clEnqueueReadBuffer(matches_found) failed (%d)\n", id, err); printf("[%zu] Error: clEnqueueReadBuffer(matches_found) failed (%d)\n", id, err);
return -1; return -1;
} }
if (matches_found[0] > 0) if (matches_found[0] > 0) {
{ if (ctx->force_hitag2_opencl) {
if (ctx->force_hitag2_opencl) if (matches_found[0] != 1) printf("[%zu] BUG: if match the counter must be 1. Here %u are founds\n", id, matches_found[0]);
{ } else {
if (matches_found[0] != 1) printf ("[%zu] BUG: if match the counter must be 1. Here %u are founds\n", id, matches_found[0]); if (matches_found[0] > (uint32_t)(ctx->global_ws[id]*WGS_MATCHES_FACTOR)) {
} printf("[%zu] BUG: the next clEnqueueReadBuffer will crash. 'matches' buffer (%u) is lower than requested (%u)\n", id, (uint32_t)(ctx->global_ws[id]*WGS_MATCHES_FACTOR), matches_found[0]);
else
{
if (matches_found[0] > (uint32_t)(ctx->global_ws[id]*WGS_MATCHES_FACTOR))
{
printf ("[%zu] BUG: the next clEnqueueReadBuffer will crash. 'matches' buffer (%u) is lower than requested (%u)\n", id, (uint32_t)(ctx->global_ws[id]*WGS_MATCHES_FACTOR), matches_found[0]);
} }
} }
err = clEnqueueReadBuffer(ctx->commands[id], ctx->matches[id], CL_TRUE, 0, sizeof(uint64_t) * matches_found[0], matches, 0, NULL, NULL); err = clEnqueueReadBuffer(ctx->commands[id], ctx->matches[id], CL_TRUE, 0, sizeof(uint64_t) * matches_found[0], matches, 0, NULL, NULL);
if (err != CL_SUCCESS) { if (err != CL_SUCCESS) {
printf ("[%zu] Error: clEnqueueReadBuffer(matches) failed (%d)\n", id, err); printf("[%zu] Error: clEnqueueReadBuffer(matches) failed (%d)\n", id, err);
return -1; return -1;
} }

View file

@ -43,8 +43,7 @@ License: GNU General Public License v3 or any later version (see LICENSE.txt)
#define MAX_OPENCL_DEVICES 16 #define MAX_OPENCL_DEVICES 16
// defines structures // defines structures
typedef struct compute_device_ctx typedef struct compute_device_ctx {
{
char name[0xff]; char name[0xff];
char vendor[0x40]; char vendor[0x40];
char version[0x40]; char version[0x40];
@ -67,8 +66,7 @@ typedef struct compute_device_ctx
} compute_device_ctx_t; } compute_device_ctx_t;
typedef struct compute_platform_ctx typedef struct compute_platform_ctx {
{
unsigned int device_cnt; unsigned int device_cnt;
unsigned int compute_units_max; unsigned int compute_units_max;
@ -90,8 +88,7 @@ typedef struct compute_platform_ctx
} compute_platform_ctx_t; } compute_platform_ctx_t;
typedef struct opencl_ctx typedef struct opencl_ctx {
{
char *kernelSource[1]; char *kernelSource[1];
size_t kernelSource_len; size_t kernelSource_len;
@ -122,8 +119,8 @@ typedef struct opencl_ctx
} opencl_ctx_t; } opencl_ctx_t;
bool plat_dev_enabled (unsigned int id, unsigned int *sel, unsigned int cnt, unsigned int cur_type, unsigned int allow_type); bool plat_dev_enabled(unsigned int id, unsigned int *sel, unsigned int cnt, unsigned int cur_type, unsigned int allow_type);
int runKernel (opencl_ctx_t *ctx, uint32_t cand_base, uint64_t *matches, uint32_t *matches_found, size_t id); int runKernel(opencl_ctx_t *ctx, uint32_t cand_base, uint64_t *matches, uint32_t *matches_found, size_t id);
#endif // OPENCL_H #endif // OPENCL_H

View file

@ -25,8 +25,7 @@ License: GNU General Public License v3 or any later version (see LICENSE.txt)
#include "queue.h" #include "queue.h"
#if TEST_UNIT == 1 #if TEST_UNIT == 1
int wu_queue_print (wu_queue_ctx_t *ctx) int wu_queue_print(wu_queue_ctx_t *ctx) {
{
wu_queue_item_t *ptr = 0; //NULL; wu_queue_item_t *ptr = 0; //NULL;
size_t sum = 0; size_t sum = 0;
int ret = -1; int ret = -1;
@ -34,195 +33,187 @@ int wu_queue_print (wu_queue_ctx_t *ctx)
if (!ctx) return -1; if (!ctx) return -1;
if (!ctx->init) return ERROR_CTX_IS_NOT_INIT; if (!ctx->init) return ERROR_CTX_IS_NOT_INIT;
pthread_mutex_lock (&ctx->queue_mutex); pthread_mutex_lock(&ctx->queue_mutex);
if ((ret = wu_queue_done (ctx)) != 0) if ((ret = wu_queue_done(ctx)) != 0) {
{ pthread_mutex_unlock(&ctx->queue_mutex);
pthread_mutex_unlock (&ctx->queue_mutex);
return ret; return ret;
} }
switch (ctx->queue_type) switch (ctx->queue_type) {
{
case QUEUE_TYPE_FORWARD: case QUEUE_TYPE_FORWARD:
ptr = ctx->queue_head; ptr = ctx->queue_head;
printf ("> show queue contents in FORWARD mode, from head\n"); printf("> show queue contents in FORWARD mode, from head\n");
break; break;
case QUEUE_TYPE_REVERSE: case QUEUE_TYPE_REVERSE:
ptr = ctx->queue_tail; ptr = ctx->queue_tail;
printf ("> show queue contents in REVERSE mode, from tail\n"); printf("> show queue contents in REVERSE mode, from tail\n");
break; break;
case QUEUE_TYPE_RANDOM: case QUEUE_TYPE_RANDOM:
ptr = ctx->queue_head; ptr = ctx->queue_head;
printf ("> show queue contents in RANDOM mode, from head\n"); printf("> show queue contents in RANDOM mode, from head\n");
default: default:
pthread_mutex_unlock (&ctx->queue_mutex); pthread_mutex_unlock(&ctx->queue_mutex);
return ERROR_QUEUE_TYPE_INVALID; return ERROR_QUEUE_TYPE_INVALID;
} }
int cnt = 0; int cnt = 0;
printf ("# Queue size: %zu\n", ctx->queue_size); printf("# Queue size: %zu\n", ctx->queue_size);
do do {
{
sum += ptr->data.id; sum += ptr->data.id;
if (cnt++ < 4) printf ("# ID %zu, OFF %zu, MAX %zu\n", ptr->data.id, ptr->data.off, ptr->data.max); if (cnt++ < 4) printf("# ID %zu, OFF %zu, MAX %zu\n", ptr->data.id, ptr->data.off, ptr->data.max);
if (ctx->queue_type == QUEUE_TYPE_FORWARD || ctx->queue_type == QUEUE_TYPE_RANDOM) if (ctx->queue_type == QUEUE_TYPE_FORWARD || ctx->queue_type == QUEUE_TYPE_RANDOM) {
{
if (!ptr->next) break; if (!ptr->next) break;
ptr = ptr->next; ptr = ptr->next;
} } else if (ctx->queue_type == QUEUE_TYPE_REVERSE) {
else if (ctx->queue_type == QUEUE_TYPE_REVERSE)
{
if (!ptr->prev) break; if (!ptr->prev) break;
ptr = ptr->prev; ptr = ptr->prev;
} }
} while (ptr); } while (ptr);
if (!ptr) if (!ptr) {
{ printf("! Fail: ptr must be not null here\n");
printf ("! Fail: ptr must be not null here\n"); pthread_mutex_unlock(&ctx->queue_mutex);
pthread_mutex_unlock (&ctx->queue_mutex);
return -1; return -1;
} }
switch (ctx->queue_type) switch (ctx->queue_type) {
{
case QUEUE_TYPE_RANDOM: case QUEUE_TYPE_RANDOM:
printf ("> show queue contents in RANDOM mode, from end to head\n"); printf("> show queue contents in RANDOM mode, from end to head\n");
break; break;
case QUEUE_TYPE_FORWARD: case QUEUE_TYPE_FORWARD:
printf ("> show queue contents in FORWARD mode, from end to head\n"); printf("> show queue contents in FORWARD mode, from end to head\n");
break; break;
case QUEUE_TYPE_REVERSE: case QUEUE_TYPE_REVERSE:
printf ("> show queue contents in REVERSE mode, from start to tail\n"); printf("> show queue contents in REVERSE mode, from start to tail\n");
break; break;
} }
cnt = 0; cnt = 0;
do do {
{
sum -= ptr->data.id; sum -= ptr->data.id;
if (cnt++ < 4) printf ("# ID %zu, OFF %zu, MAX %zu\n", ptr->data.id, ptr->data.off, ptr->data.max); if (cnt++ < 4) printf("# ID %zu, OFF %zu, MAX %zu\n", ptr->data.id, ptr->data.off, ptr->data.max);
if (ctx->queue_type == QUEUE_TYPE_FORWARD || ctx->queue_type == QUEUE_TYPE_RANDOM) if (ctx->queue_type == QUEUE_TYPE_FORWARD || ctx->queue_type == QUEUE_TYPE_RANDOM) {
{
if (!ptr->prev) break; if (!ptr->prev) break;
ptr = ptr->prev; ptr = ptr->prev;
} } else if (ctx->queue_type == QUEUE_TYPE_REVERSE) {
else if (ctx->queue_type == QUEUE_TYPE_REVERSE)
{
if (!ptr->next) break; if (!ptr->next) break;
ptr = ptr->next; ptr = ptr->next;
} }
} while (ptr); } while (ptr);
if (sum != 0) if (sum != 0) {
{ printf("! Fail: sum is not zero\n");
printf ("! Fail: sum is not zero\n"); pthread_mutex_unlock(&ctx->queue_mutex);
pthread_mutex_unlock (&ctx->queue_mutex);
return -1; return -1;
} }
pthread_mutex_unlock (&ctx->queue_mutex); pthread_mutex_unlock(&ctx->queue_mutex);
return 0; return 0;
} }
#endif #endif
const char *wu_queue_strerror (int error) const char *wu_queue_strerror(int error) {
{ switch (error) {
switch (error) case QUEUE_EMPTY:
{ return (const char *) "QUERY_EMPTY";
case QUEUE_EMPTY: return (const char *) "QUERY_EMPTY"; case NO_ERROR:
case NO_ERROR: return (const char *) "NO_ERROR"; return (const char *) "NO_ERROR";
case ERROR_GENERIC: return (const char *) "ERROR_GENERIC"; case ERROR_GENERIC:
case ERROR_QUEUE_TYPE_INVALID: return (const char *) "ERROR_QUEUE_TYPE_INVALID"; return (const char *) "ERROR_GENERIC";
case ERROR_CTX_NULL: return (const char *) "ERROR_CTX_NULL"; case ERROR_QUEUE_TYPE_INVALID:
case ERROR_CTX_IS_INIT: return (const char *) "ERROR_CTX_IS_INIT"; return (const char *) "ERROR_QUEUE_TYPE_INVALID";
case ERROR_CTX_IS_NOT_INIT: return (const char *) "ERROR_CTX_IS_NOT_INIT"; case ERROR_CTX_NULL:
case ERROR_MUTEXATTR_INIT: return (const char *) "ERROR_MUTEXATTR_INIT"; return (const char *) "ERROR_CTX_NULL";
case ERROR_MUTEXATTR_SETTYPE: return (const char *) "ERROR_MUTEXATTR_SETTYPE"; case ERROR_CTX_IS_INIT:
case ERROR_MUTEX_INIT: return (const char *) "ERROR_MUTEX_INIT"; return (const char *) "ERROR_CTX_IS_INIT";
case ERROR_ALLOC: return (const char *) "ERROR_ALLOC"; case ERROR_CTX_IS_NOT_INIT:
return (const char *) "ERROR_CTX_IS_NOT_INIT";
case ERROR_MUTEXATTR_INIT:
return (const char *) "ERROR_MUTEXATTR_INIT";
case ERROR_MUTEXATTR_SETTYPE:
return (const char *) "ERROR_MUTEXATTR_SETTYPE";
case ERROR_MUTEX_INIT:
return (const char *) "ERROR_MUTEX_INIT";
case ERROR_ALLOC:
return (const char *) "ERROR_ALLOC";
case ERROR_UNDEFINED: case ERROR_UNDEFINED:
default: default:
return (const char *) "ERROR_UNDEFINED"; return (const char *) "ERROR_UNDEFINED";
} }
} }
const char *wu_queue_strdesc (wu_queue_type_t type) const char *wu_queue_strdesc(wu_queue_type_t type) {
{ switch (type) {
switch (type) case QUEUE_TYPE_FORWARD:
{ return (const char *) "FORWARD";
case QUEUE_TYPE_FORWARD: return (const char *) "FORWARD"; case QUEUE_TYPE_REVERSE:
case QUEUE_TYPE_REVERSE: return (const char *) "REVERSE"; return (const char *) "REVERSE";
case QUEUE_TYPE_RANDOM: return (const char *) "RANDOM"; case QUEUE_TYPE_RANDOM:
return (const char *) "RANDOM";
} }
return (const char *) "UNKNOWN"; return (const char *) "UNKNOWN";
} }
int wu_queue_init (wu_queue_ctx_t *ctx, wu_queue_type_t queue_type) int wu_queue_init(wu_queue_ctx_t *ctx, wu_queue_type_t queue_type) {
{ #if TEST_UNIT == 1
#if TEST_UNIT == 1 fprintf(stdout, "[%s] enter\n", __func__);
fprintf (stdout, "[%s] enter\n", __func__); fflush(stdout);
fflush (stdout); #endif
#endif
if (!ctx) return ERROR_CTX_NULL; if (!ctx) return ERROR_CTX_NULL;
// Conditional jump or move depends on uninitialised value(s). It's good as it // Conditional jump or move depends on uninitialised value(s). It's good as it
if (ctx->init) return ERROR_CTX_IS_INIT; if (ctx->init) return ERROR_CTX_IS_INIT;
if (queue_type == QUEUE_TYPE_RANDOM) srand ((unsigned int) time(0)); if (queue_type == QUEUE_TYPE_RANDOM) srand((unsigned int) time(0));
else if (queue_type != QUEUE_TYPE_FORWARD && queue_type != QUEUE_TYPE_REVERSE) else if (queue_type != QUEUE_TYPE_FORWARD && queue_type != QUEUE_TYPE_REVERSE) {
{ #if TEST_UNIT == 1
#if TEST_UNIT == 1 fprintf(stderr, "! Error, invalid 'queue_type'.\n");
fprintf (stderr, "! Error, invalid 'queue_type'.\n"); #endif
#endif
return ERROR_QUEUE_TYPE_INVALID; return ERROR_QUEUE_TYPE_INVALID;
} }
memset (ctx, 0, sizeof (wu_queue_ctx_t)); memset(ctx, 0, sizeof(wu_queue_ctx_t));
ctx->queue_type = queue_type; ctx->queue_type = queue_type;
ctx->queue_head = 0; //NULL; ctx->queue_head = 0; //NULL;
ctx->queue_tail = 0; //NULL; ctx->queue_tail = 0; //NULL;
int ret = 0; int ret = 0;
if ((ret = pthread_mutexattr_init (&ctx->queue_mutex_attr)) != 0) if ((ret = pthread_mutexattr_init(&ctx->queue_mutex_attr)) != 0) {
{ #if TEST_UNIT == 1
#if TEST_UNIT == 1 fprintf(stderr, "! Error, pthread_mutexattr_init() failed (%d): %s\n", ret, strerror(ret));
fprintf (stderr, "! Error, pthread_mutexattr_init() failed (%d): %s\n", ret, strerror (ret)); #endif
#endif memset(ctx, 0, sizeof(wu_queue_ctx_t));
memset (ctx, 0, sizeof (wu_queue_ctx_t));
return ERROR_MUTEXATTR_INIT; return ERROR_MUTEXATTR_INIT;
} }
if ((ret = pthread_mutexattr_settype (&ctx->queue_mutex_attr, PTHREAD_MUTEX_ERRORCHECK)) != 0) if ((ret = pthread_mutexattr_settype(&ctx->queue_mutex_attr, PTHREAD_MUTEX_ERRORCHECK)) != 0) {
{ #if TEST_UNIT == 1
#if TEST_UNIT == 1 fprintf(stderr, "! Error, pthread_mutexattr_settype(PTHREAD_MUTEX_ERRORCHECK) failed (%d): %s\n", ret, strerror(ret));
fprintf (stderr, "! Error, pthread_mutexattr_settype(PTHREAD_MUTEX_ERRORCHECK) failed (%d): %s\n", ret, strerror (ret)); #endif
#endif pthread_mutexattr_destroy(&ctx->queue_mutex_attr);
pthread_mutexattr_destroy (&ctx->queue_mutex_attr); memset(ctx, 0, sizeof(wu_queue_ctx_t));
memset (ctx, 0, sizeof (wu_queue_ctx_t));
return ERROR_MUTEXATTR_SETTYPE; return ERROR_MUTEXATTR_SETTYPE;
} }
if ((ret = pthread_mutex_init (&ctx->queue_mutex, &ctx->queue_mutex_attr)) != 0) if ((ret = pthread_mutex_init(&ctx->queue_mutex, &ctx->queue_mutex_attr)) != 0) {
{ #if TEST_UNIT == 1
#if TEST_UNIT == 1 fprintf(stderr, "! Error, pthread_mutex_init() failed (%d): %s\n", ret, strerror(ret));
fprintf (stderr, "! Error, pthread_mutex_init() failed (%d): %s\n", ret, strerror (ret)); #endif
#endif pthread_mutexattr_destroy(&ctx->queue_mutex_attr);
pthread_mutexattr_destroy (&ctx->queue_mutex_attr); memset(ctx, 0, sizeof(wu_queue_ctx_t));
memset (ctx, 0, sizeof (wu_queue_ctx_t));
return ERROR_MUTEX_INIT; return ERROR_MUTEX_INIT;
} }
@ -230,27 +221,27 @@ int wu_queue_init (wu_queue_ctx_t *ctx, wu_queue_type_t queue_type)
return NO_ERROR; return NO_ERROR;
} }
int wu_queue_done (wu_queue_ctx_t *ctx) int wu_queue_done(wu_queue_ctx_t *ctx) {
{
if (!ctx) return ERROR_CTX_NULL; if (!ctx) return ERROR_CTX_NULL;
if (!ctx->init) return ERROR_CTX_IS_NOT_INIT; if (!ctx->init) return ERROR_CTX_IS_NOT_INIT;
switch (ctx->queue_type) switch (ctx->queue_type) {
{ case QUEUE_TYPE_RANDOM:
case QUEUE_TYPE_RANDOM: return (ctx->queue_head == NULL); return (ctx->queue_head == NULL);
case QUEUE_TYPE_FORWARD: return (ctx->queue_head == NULL); case QUEUE_TYPE_FORWARD:
case QUEUE_TYPE_REVERSE: return (ctx->queue_tail == NULL); return (ctx->queue_head == NULL);
case QUEUE_TYPE_REVERSE:
return (ctx->queue_tail == NULL);
} }
return ERROR_QUEUE_TYPE_INVALID; return ERROR_QUEUE_TYPE_INVALID;
} }
int wu_queue_push (wu_queue_ctx_t *ctx, size_t id, size_t off, size_t max) int wu_queue_push(wu_queue_ctx_t *ctx, size_t id, size_t off, size_t max) {
{
if (!ctx) return ERROR_CTX_NULL; if (!ctx) return ERROR_CTX_NULL;
if (!ctx->init) return ERROR_CTX_IS_NOT_INIT; if (!ctx->init) return ERROR_CTX_IS_NOT_INIT;
pthread_mutex_lock (&ctx->queue_mutex); pthread_mutex_lock(&ctx->queue_mutex);
wu_queue_item_t *ptr = 0; //NULL; wu_queue_item_t *ptr = 0; //NULL;
@ -258,12 +249,11 @@ int wu_queue_push (wu_queue_ctx_t *ctx, size_t id, size_t off, size_t max)
if (ctx->queue_head == 0) first = 1; if (ctx->queue_head == 0) first = 1;
if (!(ptr = (wu_queue_item_t *) malloc (sizeof (wu_queue_item_t)))) if (!(ptr = (wu_queue_item_t *) malloc(sizeof(wu_queue_item_t)))) {
{ #if TEST_UNIT == 1
#if TEST_UNIT == 1 fprintf(stderr, "! Error: malloc() failed (%d): %s\n", errno, strerror(errno));
fprintf (stderr, "! Error: malloc() failed (%d): %s\n", errno, strerror (errno)); #endif
#endif pthread_mutex_unlock(&ctx->queue_mutex);
pthread_mutex_unlock (&ctx->queue_mutex);
return ERROR_ALLOC; return ERROR_ALLOC;
} }
@ -277,7 +267,7 @@ int wu_queue_push (wu_queue_ctx_t *ctx, size_t id, size_t off, size_t max)
ctx->queue_head = ptr; ctx->queue_head = ptr;
ctx->queue_tail = ptr; ctx->queue_tail = ptr;
ctx->queue_size++; ctx->queue_size++;
pthread_mutex_unlock (&ctx->queue_mutex); pthread_mutex_unlock(&ctx->queue_mutex);
return NO_ERROR; return NO_ERROR;
} }
@ -291,12 +281,11 @@ int wu_queue_push (wu_queue_ctx_t *ctx, size_t id, size_t off, size_t max)
last->next = ptr; last->next = ptr;
ctx->queue_size++; ctx->queue_size++;
pthread_mutex_unlock (&ctx->queue_mutex); pthread_mutex_unlock(&ctx->queue_mutex);
return NO_ERROR; return NO_ERROR;
} }
int wu_queue_pop (wu_queue_ctx_t *ctx, wu_queue_data_t *wu, short remove) int wu_queue_pop(wu_queue_ctx_t *ctx, wu_queue_data_t *wu, short remove) {
{
if (!ctx) return ERROR_CTX_NULL; if (!ctx) return ERROR_CTX_NULL;
if (!ctx->init) return ERROR_CTX_IS_NOT_INIT; if (!ctx->init) return ERROR_CTX_IS_NOT_INIT;
@ -304,19 +293,17 @@ int wu_queue_pop (wu_queue_ctx_t *ctx, wu_queue_data_t *wu, short remove)
int rnd = 0; int rnd = 0;
wu_queue_item_t *ptr = 0, *ptrPrev = 0; wu_queue_item_t *ptr = 0, *ptrPrev = 0;
pthread_mutex_lock (&ctx->queue_mutex); pthread_mutex_lock(&ctx->queue_mutex);
if ((ret = wu_queue_done (ctx)) != 0) if ((ret = wu_queue_done(ctx)) != 0) {
{ #if TEST_UNIT == 1
#if TEST_UNIT == 1 fprintf(stderr, "ret from wu_queue_done() (%d): %s\n", ret, wu_queue_strerror(ret));
fprintf (stderr, "ret from wu_queue_done() (%d): %s\n", ret, wu_queue_strerror (ret)); #endif
#endif pthread_mutex_unlock(&ctx->queue_mutex);
pthread_mutex_unlock (&ctx->queue_mutex);
return ret; return ret;
} }
switch (ctx->queue_type) switch (ctx->queue_type) {
{
case QUEUE_TYPE_FORWARD: case QUEUE_TYPE_FORWARD:
ptr = ctx->queue_head; ptr = ctx->queue_head;
break; break;
@ -326,29 +313,25 @@ int wu_queue_pop (wu_queue_ctx_t *ctx, wu_queue_data_t *wu, short remove)
case QUEUE_TYPE_RANDOM: case QUEUE_TYPE_RANDOM:
ptr = ctx->queue_head; ptr = ctx->queue_head;
rnd = rand() % (int) ctx->queue_size; rnd = rand() % (int) ctx->queue_size;
for (int r = 0; r < rnd; r++) for (int r = 0; r < rnd; r++) {
{
ptrPrev = ptr; ptrPrev = ptr;
ptr = ptr->next; ptr = ptr->next;
} }
break; break;
} }
if (!ptr) if (!ptr) {
{ pthread_mutex_unlock(&ctx->queue_mutex);
pthread_mutex_unlock (&ctx->queue_mutex);
return ERROR_GENERIC; return ERROR_GENERIC;
} }
if (!remove) if (!remove) {
{
wu->id = ptr->data.id; wu->id = ptr->data.id;
wu->off = ptr->data.off; wu->off = ptr->data.off;
wu->max = ptr->data.max; wu->max = ptr->data.max;
} }
switch (ctx->queue_type) switch (ctx->queue_type) {
{
case QUEUE_TYPE_FORWARD: case QUEUE_TYPE_FORWARD:
ctx->queue_head = (ctx->queue_head)->next; ctx->queue_head = (ctx->queue_head)->next;
break; break;
@ -356,87 +339,80 @@ int wu_queue_pop (wu_queue_ctx_t *ctx, wu_queue_data_t *wu, short remove)
ctx->queue_tail = (ctx->queue_tail)->prev; ctx->queue_tail = (ctx->queue_tail)->prev;
break; break;
case QUEUE_TYPE_RANDOM: // from the head case QUEUE_TYPE_RANDOM: // from the head
#if TEST_UNIT == 1 #if TEST_UNIT == 1
fprintf (stdout, "pop id %ld\n", wu->id); fprintf(stdout, "pop id %ld\n", wu->id);
fflush (stdout); fflush(stdout);
#endif #endif
if (ptrPrev == NULL) if (ptrPrev == NULL) {
{
ctx->queue_head = (ctx->queue_head)->next; ctx->queue_head = (ctx->queue_head)->next;
} } else {
else
{
ptrPrev->next = ptr->next; ptrPrev->next = ptr->next;
} }
break; break;
} }
memset (ptr, 0, sizeof (wu_queue_item_t)); memset(ptr, 0, sizeof(wu_queue_item_t));
free (ptr); free(ptr);
ptr = 0; //NULL; ptr = 0; //NULL;
ctx->queue_size--; ctx->queue_size--;
if (!remove) wu->rem = ctx->queue_size; if (!remove) wu->rem = ctx->queue_size;
pthread_mutex_unlock (&ctx->queue_mutex); pthread_mutex_unlock(&ctx->queue_mutex);
return NO_ERROR; return NO_ERROR;
} }
int wu_queue_destroy (wu_queue_ctx_t *ctx) int wu_queue_destroy(wu_queue_ctx_t *ctx) {
{ #if TEST_UNIT == 1
#if TEST_UNIT == 1 fprintf(stdout, "[%s] enter\n", __func__);
fprintf (stdout, "[%s] enter\n", __func__); fflush(stdout);
fflush (stdout); #endif
#endif
if (!ctx) return ERROR_CTX_NULL; if (!ctx) return ERROR_CTX_NULL;
if (!ctx->init) return ERROR_CTX_IS_NOT_INIT; if (!ctx->init) return ERROR_CTX_IS_NOT_INIT;
pthread_mutex_lock (&ctx->queue_mutex); pthread_mutex_lock(&ctx->queue_mutex);
int ret = -1; int ret = -1;
// unload the queue // unload the queue
while ((ret = wu_queue_pop (ctx, 0, 1)) == 0) {}; while ((ret = wu_queue_pop(ctx, 0, 1)) == 0) {};
if (ret != QUEUE_EMPTY) if (ret != QUEUE_EMPTY) {
{ #if TEST_UNIT
#if TEST_UNIT fprintf(stderr, "! Error, wu_queue_pop() failed (%d): %s\n", ret, wu_queue_strerror(ret));
fprintf (stderr, "! Error, wu_queue_pop() failed (%d): %s\n", ret, wu_queue_strerror (ret)); #endif
#endif
return ret; return ret;
} }
#if TEST_UNIT == 1 #if TEST_UNIT == 1
printf ("ret from wu_queue_pop() (%d): %s\n", ret, wu_queue_strerror (ret)); printf("ret from wu_queue_pop() (%d): %s\n", ret, wu_queue_strerror(ret));
#endif #endif
#if TEST_UNIT == 1 #if TEST_UNIT == 1
if (ctx->queue_head != 0) fprintf (stderr, "queue_head not null\n"); if (ctx->queue_head != 0) fprintf(stderr, "queue_head not null\n");
if (ctx->queue_tail != 0) fprintf (stderr, "queue_tail not null\n"); if (ctx->queue_tail != 0) fprintf(stderr, "queue_tail not null\n");
#endif #endif
ctx->queue_head = 0; //NULL; ctx->queue_head = 0; //NULL;
ctx->queue_tail = 0; //NULL; ctx->queue_tail = 0; //NULL;
ctx->init = 0; ctx->init = 0;
pthread_mutex_unlock (&ctx->queue_mutex); pthread_mutex_unlock(&ctx->queue_mutex);
pthread_mutex_destroy (&ctx->queue_mutex); pthread_mutex_destroy(&ctx->queue_mutex);
pthread_mutexattr_destroy (&ctx->queue_mutex_attr); pthread_mutexattr_destroy(&ctx->queue_mutex_attr);
memset (ctx, 0, sizeof (wu_queue_ctx_t)); memset(ctx, 0, sizeof(wu_queue_ctx_t));
//ctx = 0; //NULL; //ctx = 0; //NULL;
return (ret == 1) ? NO_ERROR : ERROR_GENERIC; return (ret == 1) ? NO_ERROR : ERROR_GENERIC;
} }
#if TEST_UNIT == 1 #if TEST_UNIT == 1
int main (void) int main(void) {
{ unsigned int profiles[11][2] = {
unsigned int profiles[11][2] =
{
{ 16384, 5 }, // 0, best for Intel GPU's with Neo { 16384, 5 }, // 0, best for Intel GPU's with Neo
{ 8192, 6 }, // 1, only for Intel NEO { 8192, 6 }, // 1, only for Intel NEO
{ 4096, 7 }, // 2 (old 0) seems the best for all others (also NVIDIA) :D Apple/Intel GPU's stable here { 4096, 7 }, // 2 (old 0) seems the best for all others (also NVIDIA) :D Apple/Intel GPU's stable here
@ -458,35 +434,31 @@ int main (void)
int i = 0; int i = 0;
wu_queue_ctx_t ctx; wu_queue_ctx_t ctx;
memset (&ctx, 0, sizeof (wu_queue_ctx_t)); memset(&ctx, 0, sizeof(wu_queue_ctx_t));
printf("Selected the following config: max %zu, chunk %zu\n", max, chunk); printf("Selected the following config: max %zu, chunk %zu\n", max, chunk);
fflush (stdout); fflush(stdout);
wu_queue_type_t types[4] = { QUEUE_TYPE_FORWARD, QUEUE_TYPE_REVERSE, QUEUE_TYPE_RANDOM, 1234 }; wu_queue_type_t types[4] = { QUEUE_TYPE_FORWARD, QUEUE_TYPE_REVERSE, QUEUE_TYPE_RANDOM, 1234 };
int types_max = (int) (sizeof (types) / sizeof (wu_queue_type_t)); int types_max = (int)(sizeof(types) / sizeof(wu_queue_type_t));
int ret = 0; int ret = 0;
for (i = 0; i < types_max; i++) for (i = 0; i < types_max; i++) {
{ printf("[%d] trying wu_queue_init() in %s mode\n", i, wu_queue_strdesc(types[i]));
printf ("[%d] trying wu_queue_init() in %s mode\n", i, wu_queue_strdesc (types[i]));
if ((ret = wu_queue_init (&ctx, types[i])) != 0) if ((ret = wu_queue_init(&ctx, types[i])) != 0) {
{ fprintf(stderr, "[%d] Error: wu_queue_init(%s) failed (%d): %s\n", i, wu_queue_strdesc(types[i]), ret, wu_queue_strerror(ret));
fprintf (stderr, "[%d] Error: wu_queue_init(%s) failed (%d): %s\n", i, wu_queue_strdesc (types[i]), ret, wu_queue_strerror (ret));
err++; err++;
continue; continue;
} }
printf ("[%d] trying wu_queue_push()\n", i); printf("[%d] trying wu_queue_push()\n", i);
for (id = 0; id < max; id++) for (id = 0; id < max; id++) {
{
sum += id; sum += id;
ret = wu_queue_push (&ctx, id, id << chunk, max); ret = wu_queue_push(&ctx, id, id << chunk, max);
if (ret != 0) if (ret != 0) {
{ fprintf(stderr, "[%d] Error: wu_queue_push(%zu) failed (%d): %s\n", i, id, ret, wu_queue_strerror(ret));
fprintf (stderr, "[%d] Error: wu_queue_push(%zu) failed (%d): %s\n", i, id, ret, wu_queue_strerror (ret));
err++; err++;
continue; continue;
} }
@ -494,58 +466,52 @@ int main (void)
printf("[%d] push sum: %zu\n", i, sum); printf("[%d] push sum: %zu\n", i, sum);
if (wu_queue_print (&ctx) == -1) if (wu_queue_print(&ctx) == -1) {
{ fprintf(stderr, "[%d] wu_queue_print() error\n", i);
fprintf (stderr, "[%d] wu_queue_print() error\n", i);
err++; err++;
continue; continue;
} }
wu_queue_data_t wu; wu_queue_data_t wu;
while ((ret = wu_queue_pop (&ctx, &wu, 0)) == 0) sum -= wu.id; while ((ret = wu_queue_pop(&ctx, &wu, 0)) == 0) sum -= wu.id;
if (ret != QUEUE_EMPTY) if (ret != QUEUE_EMPTY) {
{ fprintf(stderr, "[%d] Error: wu_queue_pop() failed (%d): %s\n", i, ret, wu_queue_strerror(ret));
fprintf (stderr, "[%d] Error: wu_queue_pop() failed (%d): %s\n", i, ret, wu_queue_strerror (ret));
err++; err++;
continue; continue;
} }
printf("[%d] pop sum: %zu\n", i, sum); printf("[%d] pop sum: %zu\n", i, sum);
if (sum != 0) if (sum != 0) {
{ fprintf(stderr, "[%d] Fail: sum is not zero (%zu)\n", i, sum);
fprintf (stderr, "[%d] Fail: sum is not zero (%zu)\n", i, sum);
err++; err++;
continue; continue;
} }
if (wu_queue_print (&ctx) == -1) if (wu_queue_print(&ctx) == -1) {
{ fprintf(stderr, "[%d] wu_queue_print() error\n", i);
fprintf (stderr, "[%d] wu_queue_print() error\n", i);
err++; err++;
continue; continue;
} }
printf ("[%d] trying wu_queue_destroy()\n", i); printf("[%d] trying wu_queue_destroy()\n", i);
if ((ret = wu_queue_destroy (&ctx)) != 0) if ((ret = wu_queue_destroy(&ctx)) != 0) {
{ fprintf(stderr, "! Error: wu_queue_destroy() failed (%d): %s\n", ret, wu_queue_strerror(ret));
fprintf (stderr, "! Error: wu_queue_destroy() failed (%d): %s\n", ret, wu_queue_strerror (ret));
err++; err++;
continue; continue;
} }
} }
printf ("Catched %zu/%zu error(s).\n", err, err_max); printf("Catched %zu/%zu error(s).\n", err, err_max);
if (err == err_max) if (err == err_max) {
{ printf("Self-Test pass\n");
printf ("Self-Test pass\n");
return 0; return 0;
} }
printf ("Self-Test fail\n"); printf("Self-Test fail\n");
return -1; return -1;
} }
#endif // TEST_UNIT #endif // TEST_UNIT

View file

@ -42,8 +42,7 @@ License: GNU General Public License v3 or any later version (see LICENSE.txt)
#include <pthread.h> #include <pthread.h>
// enum errors // enum errors
typedef enum wu_queue_error typedef enum wu_queue_error {
{
QUEUE_EMPTY = 1, QUEUE_EMPTY = 1,
NO_ERROR = 0, NO_ERROR = 0,
ERROR_GENERIC = -1, ERROR_GENERIC = -1,
@ -60,8 +59,7 @@ typedef enum wu_queue_error
} wu_queue_error_t; } wu_queue_error_t;
// enum queue types // enum queue types
typedef enum wu_queue_type typedef enum wu_queue_type {
{
QUEUE_TYPE_FORWARD = 0, QUEUE_TYPE_FORWARD = 0,
QUEUE_TYPE_REVERSE, QUEUE_TYPE_REVERSE,
QUEUE_TYPE_RANDOM QUEUE_TYPE_RANDOM
@ -69,8 +67,7 @@ typedef enum wu_queue_type
} wu_queue_type_t; } wu_queue_type_t;
// hold wu data // hold wu data
typedef struct wu_queue_data typedef struct wu_queue_data {
{
size_t id; size_t id;
size_t off; size_t off;
size_t max; size_t max;
@ -80,16 +77,14 @@ typedef struct wu_queue_data
// lists // lists
typedef struct wu_queue_item wu_queue_item_t; typedef struct wu_queue_item wu_queue_item_t;
struct wu_queue_item struct wu_queue_item {
{
wu_queue_data_t data; wu_queue_data_t data;
wu_queue_item_t *next; wu_queue_item_t *next;
wu_queue_item_t *prev; wu_queue_item_t *prev;
}; };
// main ctx // main ctx
typedef struct wu_queue_ctx typedef struct wu_queue_ctx {
{
unsigned int init; unsigned int init;
wu_queue_type_t queue_type; wu_queue_type_t queue_type;
@ -106,17 +101,17 @@ typedef struct wu_queue_ctx
} wu_queue_ctx_t; } wu_queue_ctx_t;
// exports // exports
int wu_queue_init (wu_queue_ctx_t *ctx, wu_queue_type_t queue_type); int wu_queue_init(wu_queue_ctx_t *ctx, wu_queue_type_t queue_type);
int wu_queue_done (wu_queue_ctx_t *ctx); int wu_queue_done(wu_queue_ctx_t *ctx);
int wu_queue_push (wu_queue_ctx_t *ctx, size_t id, size_t off, size_t max); int wu_queue_push(wu_queue_ctx_t *ctx, size_t id, size_t off, size_t max);
int wu_queue_pop (wu_queue_ctx_t *ctx, wu_queue_data_t *wu, short remove); int wu_queue_pop(wu_queue_ctx_t *ctx, wu_queue_data_t *wu, short remove);
int wu_queue_destroy (wu_queue_ctx_t *ctx); int wu_queue_destroy(wu_queue_ctx_t *ctx);
const char *wu_queue_strdesc (wu_queue_type_t type); const char *wu_queue_strdesc(wu_queue_type_t type);
const char *wu_queue_strerror (int error); const char *wu_queue_strerror(int error);
#if TEST_UNIT == 1 #if TEST_UNIT == 1
int wu_queue_print (wu_queue_ctx_t *ctx); int wu_queue_print(wu_queue_ctx_t *ctx);
#endif #endif
#endif // QUEUE_H #endif // QUEUE_H

File diff suppressed because it is too large Load diff

View file

@ -34,8 +34,7 @@ License: GNU General Public License v3 or any later version (see LICENSE.txt)
#include "opencl.h" #include "opencl.h"
#include "hitag2.h" #include "hitag2.h"
typedef enum thread_status typedef enum thread_status {
{
TH_START = 0, TH_START = 0,
TH_WAIT, TH_WAIT,
TH_PROCESSING, TH_PROCESSING,
@ -46,15 +45,13 @@ typedef enum thread_status
} thread_status_t; } thread_status_t;
typedef enum thread_type typedef enum thread_type {
{
THREAD_TYPE_SEQ = 0, THREAD_TYPE_SEQ = 0,
THREAD_TYPE_ASYNC THREAD_TYPE_ASYNC
} thread_type_t; } thread_type_t;
typedef enum thread_error typedef enum thread_error {
{
THREAD_NOERROR = 0, THREAD_NOERROR = 0,
THREAD_ERROR_CTX_IS_NULL = -1, THREAD_ERROR_CTX_IS_NULL = -1,
THREAD_ERROR_CTX_IS_INIT = -2, THREAD_ERROR_CTX_IS_INIT = -2,
@ -73,8 +70,7 @@ typedef enum thread_error
} thread_error_t; } thread_error_t;
typedef struct threads_ctx typedef struct threads_ctx {
{
short init; short init;
short type; short type;
@ -99,8 +95,7 @@ typedef struct threads_ctx
} thread_ctx_t; } thread_ctx_t;
// used by threads engine // used by threads engine
typedef struct thread_arg typedef struct thread_arg {
{
thread_status_t status; thread_status_t status;
unsigned char pad1[4]; unsigned char pad1[4];
size_t max_threads; size_t max_threads;
@ -126,18 +121,18 @@ typedef struct thread_arg
} thread_args_t; } thread_args_t;
int thread_init (thread_ctx_t *ctx, short type, size_t thread_count); int thread_init(thread_ctx_t *ctx, short type, size_t thread_count);
int thread_start (thread_ctx_t *ctx, thread_args_t *args); int thread_start(thread_ctx_t *ctx, thread_args_t *args);
int thread_stop (thread_ctx_t *ctx); int thread_stop(thread_ctx_t *ctx);
void tprintf (const char * restrict format, ...); void tprintf(const char *restrict format, ...);
const char *thread_strerror (int error); const char *thread_strerror(int error);
const char *thread_status_strdesc (thread_status_t s); const char *thread_status_strdesc(thread_status_t s);
bool thread_setEnd (thread_ctx_t *ctx, thread_args_t *t_arg); bool thread_setEnd(thread_ctx_t *ctx, thread_args_t *t_arg);
void *computing_process (void *arg); void *computing_process(void *arg);
void *computing_process_async (void *arg); void *computing_process_async(void *arg);
int thread_destroy (thread_ctx_t *ctx); int thread_destroy(thread_ctx_t *ctx);
#endif // THREADS_H #endif // THREADS_H