mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-30 11:39:14 -07:00
make style
This commit is contained in:
parent
2fbdada593
commit
f2bc066858
33 changed files with 4734 additions and 5173 deletions
|
@ -878,19 +878,19 @@ static int CmdAnalyseNuid(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, "Self tests");
|
||||
bool test1 = (0 == memcmp(nuid, nuid_test1, sizeof(nuid)));
|
||||
PrintAndLogEx((test1) ? SUCCESS : FAILED, "1. %s -> %s ( %s )"
|
||||
, sprint_hex_inrow(uid_test1, sizeof(uid_test1))
|
||||
, sprint_hex(nuid, sizeof(nuid))
|
||||
, test1 ? _GREEN_("ok") : _RED_("fail")
|
||||
);
|
||||
, sprint_hex_inrow(uid_test1, sizeof(uid_test1))
|
||||
, sprint_hex(nuid, sizeof(nuid))
|
||||
, test1 ? _GREEN_("ok") : _RED_("fail")
|
||||
);
|
||||
|
||||
memcpy(uid, uid_test2, sizeof(uid));
|
||||
mfc_generate4b_nuid(uid, nuid);
|
||||
bool test2 = (0 == memcmp(nuid, nuid_test2, sizeof(nuid)));
|
||||
PrintAndLogEx((test2) ? SUCCESS : FAILED, "2. %s -> %s ( %s )\n"
|
||||
, sprint_hex_inrow(uid_test2, sizeof(uid_test2))
|
||||
, sprint_hex(nuid, sizeof(nuid))
|
||||
, test2 ? _GREEN_("ok") : _RED_("fail")
|
||||
);
|
||||
, sprint_hex_inrow(uid_test2, sizeof(uid_test2))
|
||||
, sprint_hex(nuid, sizeof(nuid))
|
||||
, test2 ? _GREEN_("ok") : _RED_("fail")
|
||||
);
|
||||
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
@ -987,7 +987,7 @@ static int CmdAnalyseFoo(const char *Cmd) {
|
|||
CLIParserInit(&ctx, "analyze foo",
|
||||
"experiments of cliparse",
|
||||
"analyse foo -r a0000000a0002021"
|
||||
);
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
|
|
|
@ -2873,9 +2873,9 @@ static int CmdHF14AMfuOtpTearoff(const char *Cmd) {
|
|||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
uint8_t teardata[8] = {0x00};
|
||||
memcpy(teardata, data, sizeof(data));
|
||||
memcpy(teardata + sizeof(data), test, sizeof(test));
|
||||
uint8_t teardata[8] = {0x00};
|
||||
memcpy(teardata, data, sizeof(data));
|
||||
memcpy(teardata + sizeof(data), test, sizeof(test));
|
||||
|
||||
PrintAndLogEx(INFO, "----------------- " _CYAN_("MFU Tear off") " ---------------------");
|
||||
PrintAndLogEx(INFO, "Starting Tear-off test");
|
||||
|
|
|
@ -817,7 +817,7 @@ static int CmdConnect(const char *Cmd) {
|
|||
|
||||
int p_len = FILE_PATH_SIZE;
|
||||
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);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
||||
char *r0 = (char*)calloc(56, sizeof(uint8_t));
|
||||
char *r1 = (char*)calloc(56, sizeof(uint8_t));
|
||||
char *r2 = (char*)calloc(56, sizeof(uint8_t));
|
||||
char *r3 = (char*)calloc(56, sizeof(uint8_t));
|
||||
char *r0 = (char *)calloc(56, sizeof(uint8_t));
|
||||
char *r1 = (char *)calloc(56, sizeof(uint8_t));
|
||||
char *r2 = (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(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);
|
||||
|
||||
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)" : "");
|
||||
at[n++] = arg_lit0(NULL, "all", r4);
|
||||
}
|
||||
|
@ -2876,7 +2876,7 @@ static int CmdT55xxWipe(const char *Cmd) {
|
|||
);
|
||||
|
||||
// 4 + (5 or 6)
|
||||
void *argtable[9] = {
|
||||
void *argtable[9] = {
|
||||
arg_param_begin,
|
||||
arg_str0("c", "cfg", "<hex>", "configuration block0 (4 hex bytes)"),
|
||||
arg_str0("p", "pwd", "<hex>", "password (4 hex bytes)"),
|
||||
|
@ -3181,7 +3181,7 @@ static int CmdT55xxBruteForce(const char *Cmd) {
|
|||
"lf t55xx bruteforce --r2 -s aaaaaa77 -e aaaaaa99\n"
|
||||
);
|
||||
|
||||
void *argtable[3 + 6] = {
|
||||
void *argtable[3 + 6] = {
|
||||
arg_param_begin,
|
||||
arg_str1("s", "start", "<hex>", "search start password (4 hex bytes)"),
|
||||
arg_str1("e", "end", "<hex>", "search end password (4 hex bytes)"),
|
||||
|
@ -3308,7 +3308,7 @@ static int CmdT55xxRecoverPW(const char *Cmd) {
|
|||
);
|
||||
|
||||
// 2 + (5 or 6)
|
||||
void *argtable[8] = {
|
||||
void *argtable[8] = {
|
||||
arg_param_begin,
|
||||
arg_str1("p", "pwd", "<hex>", "password (4 hex bytes)"),
|
||||
};
|
||||
|
@ -3548,7 +3548,7 @@ static int CmdT55xxDetectPage1(const char *Cmd) {
|
|||
);
|
||||
|
||||
// 2 + (5 or 6)
|
||||
void *argtable[7] = {
|
||||
void *argtable[7] = {
|
||||
arg_param_begin,
|
||||
arg_lit0("1", NULL, "extract using data from graphbuffer"),
|
||||
arg_str0("p", "pwd", "<hex>", "password (4 hex bytes)"),
|
||||
|
@ -3565,7 +3565,7 @@ static int CmdT55xxDetectPage1(const char *Cmd) {
|
|||
if (res == 2) {
|
||||
PrintAndLogEx(INFO, "Password should be 4 hex bytes");
|
||||
return PM3_EINVARG;
|
||||
} else if ( res == 1) {
|
||||
} else if (res == 1) {
|
||||
usepwd = true;
|
||||
}
|
||||
|
||||
|
@ -3644,7 +3644,7 @@ static int CmdT55xxSetDeviceConfig(const char *Cmd) {
|
|||
"lf t55xx deviceconfig -a 55 -b 14 -c 21 -d 30 -> default EM4305"
|
||||
);
|
||||
|
||||
void *argtable[10 + 5] = {
|
||||
void *argtable[10 + 5] = {
|
||||
arg_param_begin,
|
||||
arg_int0("a", NULL, "<8..255>", "Set start gap"),
|
||||
arg_int0("b", NULL, "<8..255>", "Set write gap"),
|
||||
|
@ -3755,7 +3755,7 @@ static int CmdT55xxProtect(const char *Cmd) {
|
|||
);
|
||||
|
||||
// 4 + (5 or 6)
|
||||
void *argtable[4 + 5] = {
|
||||
void *argtable[4 + 5] = {
|
||||
arg_param_begin,
|
||||
arg_lit0("o", "override", "override safety check"),
|
||||
arg_str1("p", "pwd", "<hex>", "password (4 hex bytes)"),
|
||||
|
@ -3776,7 +3776,7 @@ static int CmdT55xxProtect(const char *Cmd) {
|
|||
CLIParserFree(ctx);
|
||||
PrintAndLogEx(FAILED, "Error parsing password bytes");
|
||||
return PM3_EINVARG;
|
||||
} else if ( res == 1) {
|
||||
} else if (res == 1) {
|
||||
usepwd = true;
|
||||
override = 1;
|
||||
}
|
||||
|
|
|
@ -700,7 +700,7 @@ static int CmdSmartReader(const char *Cmd) {
|
|||
|
||||
if (resp.status != PM3_SUCCESS) {
|
||||
if (verbose) {
|
||||
PrintAndLogEx(WARNING, "smart card select failed");
|
||||
PrintAndLogEx(WARNING, "smart card select failed");
|
||||
}
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
@ -733,7 +733,7 @@ static int CmdSmartSetClock(const char *Cmd) {
|
|||
bool c4 = arg_get_lit(ctx, 3);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
if ((c16 + c8 + c4) > 1 ) {
|
||||
if ((c16 + c8 + c4) > 1) {
|
||||
PrintAndLogEx(WARNING, "Only one clock speed can be used at a time");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ static int CmdUsartConfig(const char *Cmd) {
|
|||
bool po = arg_get_lit(ctx, 4);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
if ((pn + pe + po) > 1 ) {
|
||||
if ((pn + pe + po) > 1) {
|
||||
PrintAndLogEx(WARNING, "Only one parity can be used at a time");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
@ -361,7 +361,7 @@ static int CmdUsartBtPin(const char *Cmd) {
|
|||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
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);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
|
|
|
@ -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 ((Path == NULL) && (session.defaultPaths[pathIndex] != NULL)) {
|
||||
free (session.defaultPaths[pathIndex]);
|
||||
free(session.defaultPaths[pathIndex]);
|
||||
session.defaultPaths[pathIndex] = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ typedef enum {
|
|||
|
||||
int fileExists(const char *filename);
|
||||
//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);
|
||||
|
||||
|
|
|
@ -55,27 +55,27 @@ int preferences_load(void) {
|
|||
session.show_hints = true;
|
||||
|
||||
session.bar_mode = STYLE_VALUE;
|
||||
setDefaultPath (spDefault, "");
|
||||
setDefaultPath (spDump, "");
|
||||
setDefaultPath (spTrace, "");
|
||||
setDefaultPath(spDefault, "");
|
||||
setDefaultPath(spDump, "");
|
||||
setDefaultPath(spTrace, "");
|
||||
|
||||
// default save path
|
||||
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
|
||||
setDefaultPath (spDefault, ".");
|
||||
setDefaultPath(spDefault, ".");
|
||||
|
||||
// default dump path
|
||||
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
|
||||
setDefaultPath (spDump, ".");
|
||||
setDefaultPath(spDump, ".");
|
||||
|
||||
// default dump path
|
||||
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
|
||||
setDefaultPath (spTrace, ".");
|
||||
setDefaultPath(spTrace, ".");
|
||||
|
||||
if (session.incognito) {
|
||||
PrintAndLogEx(INFO, "No preferences file will be loaded");
|
||||
|
@ -177,9 +177,9 @@ void preferences_save_callback(json_t *root) {
|
|||
|
||||
JsonSaveBoolean(root, "os.supports.colors", session.supports_colors);
|
||||
|
||||
JsonSaveStr(root, "file.default.savepath", session.defaultPaths[spDefault]);
|
||||
JsonSaveStr(root, "file.default.dumppath", session.defaultPaths[spDump]);
|
||||
JsonSaveStr(root, "file.default.tracepath", session.defaultPaths[spTrace]);
|
||||
JsonSaveStr(root, "file.default.savepath", session.defaultPaths[spDefault]);
|
||||
JsonSaveStr(root, "file.default.dumppath", session.defaultPaths[spDump]);
|
||||
JsonSaveStr(root, "file.default.tracepath", session.defaultPaths[spTrace]);
|
||||
|
||||
// Plot window
|
||||
JsonSaveInt(root, "window.plot.xpos", session.plot.x);
|
||||
|
@ -262,15 +262,15 @@ void preferences_load_callback(json_t *root) {
|
|||
|
||||
// default save path
|
||||
if (json_unpack_ex(root, &up_error, 0, "{s:s}", "file.default.savepath", &s1) == 0)
|
||||
setDefaultPath (spDefault, s1);
|
||||
setDefaultPath(spDefault, s1);
|
||||
|
||||
// default dump path
|
||||
if (json_unpack_ex(root, &up_error, 0, "{s:s}", "file.default.dumppath", &s1) == 0)
|
||||
setDefaultPath (spDump, s1);
|
||||
setDefaultPath(spDump, s1);
|
||||
|
||||
// default trace path
|
||||
if (json_unpack_ex(root, &up_error, 0, "{s:s}", "file.default.tracepath", &s1) == 0)
|
||||
setDefaultPath (spTrace, s1);
|
||||
setDefaultPath(spTrace, s1);
|
||||
|
||||
// window plot
|
||||
if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.plot.xpos", &i1) == 0)
|
||||
|
@ -424,49 +424,49 @@ static void showSavePathState(savePaths_t path_index, prefShowOpt_t opt) {
|
|||
char s[50];
|
||||
switch (path_index) {
|
||||
case spDefault:
|
||||
strcpy (s, "default save path......");
|
||||
strcpy(s, "default save path......");
|
||||
break;
|
||||
case spDump:
|
||||
strcpy (s, "dump save path.........");
|
||||
strcpy(s, "dump save path.........");
|
||||
break;
|
||||
case spTrace:
|
||||
strcpy (s, "trace save path........");
|
||||
strcpy(s, "trace save path........");
|
||||
break;
|
||||
case spItemCount:
|
||||
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)) {
|
||||
PrintAndLogEx(INFO, " %s %s "_WHITE_("not set"),
|
||||
prefShowMsg(opt),
|
||||
s
|
||||
);
|
||||
prefShowMsg(opt),
|
||||
s
|
||||
);
|
||||
} else {
|
||||
PrintAndLogEx(INFO, " %s %s "_GREEN_("%s"),
|
||||
prefShowMsg(opt),
|
||||
s,
|
||||
session.defaultPaths[path_index]
|
||||
);
|
||||
prefShowMsg(opt),
|
||||
s,
|
||||
session.defaultPaths[path_index]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static void showPlotPosState(void) {
|
||||
PrintAndLogEx(INFO, " Plot window............ X "_GREEN_("%4d")" Y "_GREEN_("%4d")" H "_GREEN_("%4d")" W "_GREEN_("%4d"),
|
||||
session.plot.x,
|
||||
session.plot.y,
|
||||
session.plot.h,
|
||||
session.plot.w
|
||||
);
|
||||
session.plot.x,
|
||||
session.plot.y,
|
||||
session.plot.h,
|
||||
session.plot.w
|
||||
);
|
||||
}
|
||||
|
||||
static void showOverlayPosState(void) {
|
||||
PrintAndLogEx(INFO, " Slider/Overlay window.. X "_GREEN_("%4d")" Y "_GREEN_("%4d")" H "_GREEN_("%4d")" W "_GREEN_("%4d"),
|
||||
session.overlay.x,
|
||||
session.overlay.y,
|
||||
session.overlay.h,
|
||||
session.overlay.w
|
||||
);
|
||||
session.overlay.x,
|
||||
session.overlay.y,
|
||||
session.overlay.h,
|
||||
session.overlay.w
|
||||
);
|
||||
}
|
||||
|
||||
static void showHintsState(prefShowOpt_t opt) {
|
||||
|
@ -522,7 +522,7 @@ static int setCmdEmoji(const char *Cmd) {
|
|||
bool show_none = arg_get_lit(ctx, 4);
|
||||
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");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
@ -572,7 +572,7 @@ static int setCmdColor(const char *Cmd) {
|
|||
bool use_n = arg_get_lit(ctx, 2);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
if ( (use_c + use_n) > 1) {
|
||||
if ((use_c + use_n) > 1) {
|
||||
PrintAndLogEx(FAILED, "Can only set one option");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
@ -618,7 +618,7 @@ static int setCmdDebug(const char *Cmd) {
|
|||
bool use_full = arg_get_lit(ctx, 3);
|
||||
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");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
@ -734,12 +734,12 @@ static int setCmdHint(const char *Cmd) {
|
|||
bool use_on = arg_get_lit(ctx, 2);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
if ( (use_off + use_on) > 1) {
|
||||
if ((use_off + use_on) > 1) {
|
||||
PrintAndLogEx(FAILED, "Can only set one option");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
bool new_value = session.show_hints;
|
||||
bool new_value = session.show_hints;
|
||||
if (use_off) {
|
||||
new_value = false;
|
||||
}
|
||||
|
@ -777,7 +777,7 @@ static int setCmdPlotSliders(const char *Cmd) {
|
|||
bool use_on = arg_get_lit(ctx, 2);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
if ( (use_off + use_on) > 1) {
|
||||
if ((use_off + use_on) > 1) {
|
||||
PrintAndLogEx(FAILED, "Can only set one option");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
@ -801,7 +801,7 @@ static int setCmdPlotSliders(const char *Cmd) {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int setCmdSavePaths (const char *Cmd) {
|
||||
static int setCmdSavePaths(const char *Cmd) {
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "pref set savepath",
|
||||
"Set presistent preference of file paths in the client",
|
||||
|
@ -861,7 +861,7 @@ static int setCmdSavePaths (const char *Cmd) {
|
|||
|
||||
// Check path
|
||||
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
|
||||
|
@ -871,7 +871,7 @@ static int setCmdSavePaths (const char *Cmd) {
|
|||
if (path_item < spItemCount) {
|
||||
if (strcmp(path, session.defaultPaths[path_item]) != 0) {
|
||||
showSavePathState(path_item, prefShowOLD);
|
||||
setDefaultPath (path_item, path);
|
||||
setDefaultPath(path_item, path);
|
||||
showSavePathState(path_item, prefShowNEW);
|
||||
preferences_save();
|
||||
} else {
|
||||
|
@ -902,7 +902,7 @@ static int setCmdBarMode(const char *Cmd) {
|
|||
bool show_val = arg_get_lit(ctx, 3);
|
||||
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");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
|
|
@ -506,7 +506,7 @@ Check column "offline" for their availability.
|
|||
|command |offline |description
|
||||
|------- |------- |-----------
|
||||
|`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 detectreader `|N |`Detect external reader field`
|
||||
|`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 readmem `|N |`Read memory at decimal address from flash`
|
||||
|`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 standalone `|N |`Jump to the standalone mode`
|
||||
|`hw status `|N |`Show runtime status information about the connected Proxmark3`
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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_d3d10_device_source_khr d3d_device_source,
|
||||
void * d3d_object,
|
||||
void *d3d_object,
|
||||
cl_d3d10_device_set_khr d3d_device_set,
|
||||
cl_uint num_entries,
|
||||
cl_device_id * devices,
|
||||
cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0;
|
||||
cl_device_id *devices,
|
||||
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_mem_flags flags,
|
||||
ID3D10Buffer * resource,
|
||||
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
|
||||
ID3D10Buffer *resource,
|
||||
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_mem_flags flags,
|
||||
ID3D10Texture2D * resource,
|
||||
ID3D10Texture2D *resource,
|
||||
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_mem_flags flags,
|
||||
ID3D10Texture3D * resource,
|
||||
ID3D10Texture3D *resource,
|
||||
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_uint num_objects,
|
||||
const cl_mem * mem_objects,
|
||||
const cl_mem *mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_API_SUFFIX__VERSION_1_0;
|
||||
const cl_event *event_wait_list,
|
||||
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_uint num_objects,
|
||||
const cl_mem * mem_objects,
|
||||
const cl_mem *mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_API_SUFFIX__VERSION_1_0;
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event) CL_API_SUFFIX__VERSION_1_0;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -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_d3d11_device_source_khr d3d_device_source,
|
||||
void * d3d_object,
|
||||
void *d3d_object,
|
||||
cl_d3d11_device_set_khr d3d_device_set,
|
||||
cl_uint num_entries,
|
||||
cl_device_id * devices,
|
||||
cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2;
|
||||
cl_device_id *devices,
|
||||
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_mem_flags flags,
|
||||
ID3D11Buffer * resource,
|
||||
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2;
|
||||
ID3D11Buffer *resource,
|
||||
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_mem_flags flags,
|
||||
ID3D11Texture2D * resource,
|
||||
ID3D11Texture2D *resource,
|
||||
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_mem_flags flags,
|
||||
ID3D11Texture3D * resource,
|
||||
ID3D11Texture3D *resource,
|
||||
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_uint num_objects,
|
||||
const cl_mem * mem_objects,
|
||||
const cl_mem *mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_API_SUFFIX__VERSION_1_2;
|
||||
const cl_event *event_wait_list,
|
||||
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_uint num_objects,
|
||||
const cl_mem * mem_objects,
|
||||
const cl_mem *mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_API_SUFFIX__VERSION_1_2;
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event) CL_API_SUFFIX__VERSION_1_2;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -33,8 +33,7 @@ typedef cl_uint cl_dx9_media_adapter_set_khr;
|
|||
|
||||
#if defined(_WIN32)
|
||||
#include <d3d9.h>
|
||||
typedef struct _cl_dx9_surface_info_khr
|
||||
{
|
||||
typedef struct _cl_dx9_surface_info_khr {
|
||||
IDirect3DSurface9 *resource;
|
||||
HANDLE shared_handle;
|
||||
} 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_uint num_media_adapters,
|
||||
cl_dx9_media_adapter_type_khr * media_adapter_type,
|
||||
void * media_adapters,
|
||||
cl_dx9_media_adapter_type_khr *media_adapter_type,
|
||||
void *media_adapters,
|
||||
cl_dx9_media_adapter_set_khr media_adapter_set,
|
||||
cl_uint num_entries,
|
||||
cl_device_id * devices,
|
||||
cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2;
|
||||
cl_device_id *devices,
|
||||
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_mem_flags flags,
|
||||
cl_dx9_media_adapter_type_khr adapter_type,
|
||||
void * surface_info,
|
||||
void *surface_info,
|
||||
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_uint num_objects,
|
||||
const cl_mem * mem_objects,
|
||||
const cl_mem *mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_API_SUFFIX__VERSION_1_2;
|
||||
const cl_event *event_wait_list,
|
||||
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_uint num_objects,
|
||||
const cl_mem * mem_objects,
|
||||
const cl_mem *mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_API_SUFFIX__VERSION_1_2;
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event) CL_API_SUFFIX__VERSION_1_2;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -96,71 +96,71 @@ extern CL_API_ENTRY cl_int CL_API_CALL
|
|||
clGetDeviceIDsFromDX9INTEL(
|
||||
cl_platform_id platform,
|
||||
cl_dx9_device_source_intel dx9_device_source,
|
||||
void* dx9_object,
|
||||
void *dx9_object,
|
||||
cl_dx9_device_set_intel dx9_device_set,
|
||||
cl_uint num_entries,
|
||||
cl_device_id* devices,
|
||||
cl_uint* num_devices) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
cl_device_id *devices,
|
||||
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_dx9_device_source_intel dx9_device_source,
|
||||
void* dx9_object,
|
||||
void *dx9_object,
|
||||
cl_dx9_device_set_intel dx9_device_set,
|
||||
cl_uint num_entries,
|
||||
cl_device_id* devices,
|
||||
cl_uint* num_devices) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
cl_device_id *devices,
|
||||
cl_uint *num_devices) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
|
||||
extern CL_API_ENTRY cl_mem CL_API_CALL
|
||||
clCreateFromDX9MediaSurfaceINTEL(
|
||||
cl_context context,
|
||||
cl_mem_flags flags,
|
||||
IDirect3DSurface9* resource,
|
||||
IDirect3DSurface9 *resource,
|
||||
HANDLE sharedHandle,
|
||||
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_mem_flags flags,
|
||||
IDirect3DSurface9* resource,
|
||||
IDirect3DSurface9 *resource,
|
||||
HANDLE sharedHandle,
|
||||
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
|
||||
clEnqueueAcquireDX9ObjectsINTEL(
|
||||
cl_command_queue command_queue,
|
||||
cl_uint num_objects,
|
||||
const cl_mem* mem_objects,
|
||||
const cl_mem *mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event* event_wait_list,
|
||||
cl_event* event) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
const cl_event *event_wait_list,
|
||||
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_uint num_objects,
|
||||
const cl_mem* mem_objects,
|
||||
const cl_mem *mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event* event_wait_list,
|
||||
cl_event* event) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueReleaseDX9ObjectsINTEL(
|
||||
cl_command_queue command_queue,
|
||||
cl_uint num_objects,
|
||||
cl_mem* mem_objects,
|
||||
cl_mem *mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event* event_wait_list,
|
||||
cl_event* event) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
const cl_event *event_wait_list,
|
||||
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_uint num_objects,
|
||||
cl_mem* mem_objects,
|
||||
cl_mem *mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event* event_wait_list,
|
||||
cl_event* event) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -34,13 +34,13 @@ extern "C" {
|
|||
#define CL_EGL_RESOURCE_NOT_ACQUIRED_KHR -1092
|
||||
|
||||
/* CLeglImageKHR is an opaque handle to an EGLImage */
|
||||
typedef void* CLeglImageKHR;
|
||||
typedef void *CLeglImageKHR;
|
||||
|
||||
/* CLeglDisplayKHR is an opaque handle to an EGLDisplay */
|
||||
typedef void* CLeglDisplayKHR;
|
||||
typedef void *CLeglDisplayKHR;
|
||||
|
||||
/* CLeglSyncKHR is an opaque handle to an EGLSync object */
|
||||
typedef void* CLeglSyncKHR;
|
||||
typedef void *CLeglSyncKHR;
|
||||
|
||||
/* properties passed to clCreateFromEGLImageKHR */
|
||||
typedef intptr_t cl_egl_image_properties_khr;
|
||||
|
@ -53,50 +53,50 @@ clCreateFromEGLImageKHR(cl_context context,
|
|||
CLeglDisplayKHR egldisplay,
|
||||
CLeglImageKHR eglimage,
|
||||
cl_mem_flags flags,
|
||||
const cl_egl_image_properties_khr * properties,
|
||||
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
|
||||
const cl_egl_image_properties_khr *properties,
|
||||
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,
|
||||
CLeglDisplayKHR egldisplay,
|
||||
CLeglImageKHR eglimage,
|
||||
cl_mem_flags flags,
|
||||
const cl_egl_image_properties_khr * properties,
|
||||
cl_int * errcode_ret);
|
||||
const cl_egl_image_properties_khr *properties,
|
||||
cl_int *errcode_ret);
|
||||
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueAcquireEGLObjectsKHR(cl_command_queue command_queue,
|
||||
cl_uint num_objects,
|
||||
const cl_mem * mem_objects,
|
||||
const cl_mem *mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_API_SUFFIX__VERSION_1_0;
|
||||
const cl_event *event_wait_list,
|
||||
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_uint num_objects,
|
||||
const cl_mem * mem_objects,
|
||||
const cl_mem *mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event);
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event);
|
||||
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueReleaseEGLObjectsKHR(cl_command_queue command_queue,
|
||||
cl_uint num_objects,
|
||||
const cl_mem * mem_objects,
|
||||
const cl_mem *mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_API_SUFFIX__VERSION_1_0;
|
||||
const cl_event *event_wait_list,
|
||||
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_uint num_objects,
|
||||
const cl_mem * mem_objects,
|
||||
const cl_mem *mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event);
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event);
|
||||
|
||||
|
||||
#define cl_khr_egl_event 1
|
||||
|
@ -105,13 +105,13 @@ extern CL_API_ENTRY cl_event CL_API_CALL
|
|||
clCreateEventFromEGLSyncKHR(cl_context context,
|
||||
CLeglSyncKHR sync,
|
||||
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,
|
||||
CLeglSyncKHR sync,
|
||||
CLeglDisplayKHR display,
|
||||
cl_int * errcode_ret);
|
||||
cl_int *errcode_ret);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -54,9 +54,9 @@ extern "C" {
|
|||
* before using.
|
||||
*/
|
||||
#define cl_APPLE_SetMemObjectDestructor 1
|
||||
cl_int CL_API_ENTRY clSetMemObjectDestructorAPPLE( cl_mem memobj,
|
||||
void (* pfn_notify)(cl_mem memobj, void * user_data),
|
||||
void * user_data) CL_EXT_SUFFIX__VERSION_1_0;
|
||||
cl_int CL_API_ENTRY clSetMemObjectDestructorAPPLE(cl_mem memobj,
|
||||
void (* pfn_notify)(cl_mem memobj, void *user_data),
|
||||
void *user_data) CL_EXT_SUFFIX__VERSION_1_0;
|
||||
|
||||
|
||||
/* 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
|
||||
*/
|
||||
#define cl_APPLE_ContextLoggingFunctions 1
|
||||
extern void CL_API_ENTRY clLogMessagesToSystemLogAPPLE( const char * errstr,
|
||||
const void * private_info,
|
||||
size_t cb,
|
||||
void * user_data) CL_EXT_SUFFIX__VERSION_1_0;
|
||||
extern void CL_API_ENTRY clLogMessagesToSystemLogAPPLE(const char *errstr,
|
||||
const void *private_info,
|
||||
size_t cb,
|
||||
void *user_data) CL_EXT_SUFFIX__VERSION_1_0;
|
||||
|
||||
/* clLogMessagesToStdout sends all log messages to the file descriptor stdout */
|
||||
extern void CL_API_ENTRY clLogMessagesToStdoutAPPLE( const char * errstr,
|
||||
const void * private_info,
|
||||
size_t cb,
|
||||
void * user_data) CL_EXT_SUFFIX__VERSION_1_0;
|
||||
extern void CL_API_ENTRY clLogMessagesToStdoutAPPLE(const char *errstr,
|
||||
const void *private_info,
|
||||
size_t cb,
|
||||
void *user_data) CL_EXT_SUFFIX__VERSION_1_0;
|
||||
|
||||
/* clLogMessagesToStderr sends all log messages to the file descriptor stderr */
|
||||
extern void CL_API_ENTRY clLogMessagesToStderrAPPLE( const char * errstr,
|
||||
const void * private_info,
|
||||
size_t cb,
|
||||
void * user_data) CL_EXT_SUFFIX__VERSION_1_0;
|
||||
extern void CL_API_ENTRY clLogMessagesToStderrAPPLE(const char *errstr,
|
||||
const void *private_info,
|
||||
size_t cb,
|
||||
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
|
||||
clIcdGetPlatformIDsKHR(cl_uint num_entries,
|
||||
cl_platform_id * platforms,
|
||||
cl_uint * num_platforms);
|
||||
cl_platform_id *platforms,
|
||||
cl_uint *num_platforms);
|
||||
|
||||
typedef CL_API_ENTRY cl_int
|
||||
(CL_API_CALL *clIcdGetPlatformIDsKHR_fn)(cl_uint num_entries,
|
||||
cl_platform_id * platforms,
|
||||
cl_uint * num_platforms);
|
||||
cl_platform_id *platforms,
|
||||
cl_uint *num_platforms);
|
||||
|
||||
|
||||
/*******************************
|
||||
|
@ -125,15 +125,15 @@ typedef CL_API_ENTRY cl_int
|
|||
|
||||
extern CL_API_ENTRY cl_program CL_API_CALL
|
||||
clCreateProgramWithILKHR(cl_context context,
|
||||
const void * il,
|
||||
const void *il,
|
||||
size_t length,
|
||||
cl_int * errcode_ret);
|
||||
cl_int *errcode_ret);
|
||||
|
||||
typedef CL_API_ENTRY cl_program
|
||||
(CL_API_CALL *clCreateProgramWithILKHR_fn)(cl_context context,
|
||||
const void * il,
|
||||
const void *il,
|
||||
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
|
||||
*
|
||||
|
@ -203,14 +203,14 @@ typedef cl_properties cl_queue_properties_khr;
|
|||
extern CL_API_ENTRY cl_command_queue CL_API_CALL
|
||||
clCreateCommandQueueWithPropertiesKHR(cl_context context,
|
||||
cl_device_id device,
|
||||
const cl_queue_properties_khr* properties,
|
||||
cl_int* errcode_ret) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
const cl_queue_properties_khr *properties,
|
||||
cl_int *errcode_ret) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
typedef CL_API_ENTRY cl_command_queue
|
||||
(CL_API_CALL *clCreateCommandQueueWithPropertiesKHR_fn)(cl_context context,
|
||||
cl_device_id device,
|
||||
const cl_queue_properties_khr* properties,
|
||||
cl_int* errcode_ret) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
const cl_queue_properties_khr *properties,
|
||||
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;
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
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_device_id * out_devices,
|
||||
cl_uint * num_devices) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
cl_device_id *out_devices,
|
||||
cl_uint *num_devices) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
|
||||
typedef CL_API_ENTRY cl_int
|
||||
(CL_API_CALL * clCreateSubDevicesEXT_fn)(cl_device_id in_device,
|
||||
const cl_device_partition_property_ext * properties,
|
||||
cl_uint num_entries,
|
||||
cl_device_id * out_devices,
|
||||
cl_uint * num_devices) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
(CL_API_CALL *clCreateSubDevicesEXT_fn)(cl_device_id in_device,
|
||||
const cl_device_partition_property_ext *properties,
|
||||
cl_uint num_entries,
|
||||
cl_device_id *out_devices,
|
||||
cl_uint *num_devices) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
|
||||
/* cl_device_partition_property_ext */
|
||||
#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
|
||||
clEnqueueMigrateMemObjectEXT(cl_command_queue command_queue,
|
||||
cl_uint num_mem_objects,
|
||||
const cl_mem * mem_objects,
|
||||
const cl_mem *mem_objects,
|
||||
cl_mem_migration_flags_ext flags,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event);
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event);
|
||||
|
||||
typedef CL_API_ENTRY cl_int
|
||||
(CL_API_CALL *clEnqueueMigrateMemObjectEXT_fn)(cl_command_queue command_queue,
|
||||
cl_uint num_mem_objects,
|
||||
const cl_mem * mem_objects,
|
||||
const cl_mem *mem_objects,
|
||||
cl_mem_migration_flags_ext flags,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event);
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event);
|
||||
|
||||
|
||||
/*********************************
|
||||
|
@ -391,8 +391,7 @@ clGetDeviceImageInfoQCOM(cl_device_id device,
|
|||
void *param_value,
|
||||
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. */
|
||||
/* Legal values will be defined in layered extensions. */
|
||||
cl_uint allocation_type;
|
||||
|
@ -417,8 +416,7 @@ typedef struct _cl_mem_ext_host_ptr
|
|||
|
||||
#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. */
|
||||
/* Must be CL_MEM_ION_HOST_PTR_QCOM for ION allocations. */
|
||||
cl_mem_ext_host_ptr ext_host_ptr;
|
||||
|
@ -427,7 +425,7 @@ typedef struct _cl_mem_ion_host_ptr
|
|||
int ion_filedesc;
|
||||
|
||||
/* Host pointer to the ION allocated memory */
|
||||
void* ion_hostptr;
|
||||
void *ion_hostptr;
|
||||
|
||||
} 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
|
||||
|
||||
typedef struct _cl_mem_android_native_buffer_host_ptr
|
||||
{
|
||||
typedef struct _cl_mem_android_native_buffer_host_ptr {
|
||||
/* Type of external memory allocation. */
|
||||
/* Must be CL_MEM_ANDROID_NATIVE_BUFFER_HOST_PTR_QCOM for Android native buffers. */
|
||||
cl_mem_ext_host_ptr ext_host_ptr;
|
||||
|
||||
/* Virtual pointer to the android native buffer */
|
||||
void* anb_ptr;
|
||||
void *anb_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
|
||||
clEnqueueAcquireGrallocObjectsIMG(cl_command_queue command_queue,
|
||||
cl_uint num_objects,
|
||||
const cl_mem * mem_objects,
|
||||
const cl_mem *mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueReleaseGrallocObjectsIMG(cl_command_queue command_queue,
|
||||
cl_uint num_objects,
|
||||
const cl_mem * mem_objects,
|
||||
const cl_mem *mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
/******************************************
|
||||
* cl_img_generate_mipmap extension *
|
||||
|
@ -561,20 +558,20 @@ clGetKernelSubGroupInfoKHR(cl_kernel in_kernel,
|
|||
cl_device_id in_device,
|
||||
cl_kernel_sub_group_info param_name,
|
||||
size_t input_value_size,
|
||||
const void * input_value,
|
||||
const void *input_value,
|
||||
size_t param_value_size,
|
||||
void * param_value,
|
||||
size_t * param_value_size_ret) CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED;
|
||||
void *param_value,
|
||||
size_t *param_value_size_ret) CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED;
|
||||
|
||||
typedef CL_API_ENTRY cl_int
|
||||
(CL_API_CALL * clGetKernelSubGroupInfoKHR_fn)(cl_kernel in_kernel,
|
||||
cl_device_id in_device,
|
||||
cl_kernel_sub_group_info param_name,
|
||||
size_t input_value_size,
|
||||
const void * input_value,
|
||||
size_t param_value_size,
|
||||
void * param_value,
|
||||
size_t * param_value_size_ret) CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED;
|
||||
(CL_API_CALL *clGetKernelSubGroupInfoKHR_fn)(cl_kernel in_kernel,
|
||||
cl_device_id in_device,
|
||||
cl_kernel_sub_group_info param_name,
|
||||
size_t input_value_size,
|
||||
const void *input_value,
|
||||
size_t param_value_size,
|
||||
void *param_value,
|
||||
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
|
||||
|
||||
typedef struct _cl_name_version_khr
|
||||
{
|
||||
typedef struct _cl_name_version_khr {
|
||||
cl_version_khr version;
|
||||
char name[CL_NAME_VERSION_MAX_NAME_SIZE_KHR];
|
||||
} cl_name_version_khr;
|
||||
|
@ -739,12 +735,12 @@ typedef intptr_t cl_import_properties_arm;
|
|||
* function clCreateBuffer.
|
||||
*/
|
||||
extern CL_API_ENTRY cl_mem CL_API_CALL
|
||||
clImportMemoryARM( cl_context context,
|
||||
cl_mem_flags flags,
|
||||
const cl_import_properties_arm *properties,
|
||||
void *memory,
|
||||
size_t size,
|
||||
cl_int *errcode_ret) CL_EXT_SUFFIX__VERSION_1_0;
|
||||
clImportMemoryARM(cl_context context,
|
||||
cl_mem_flags flags,
|
||||
const cl_import_properties_arm *properties,
|
||||
void *memory,
|
||||
size_t size,
|
||||
cl_int *errcode_ret) CL_EXT_SUFFIX__VERSION_1_0;
|
||||
|
||||
|
||||
/******************************************
|
||||
|
@ -783,7 +779,7 @@ typedef cl_bitfield cl_svm_mem_flags_arm;
|
|||
typedef cl_uint cl_kernel_exec_info_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,
|
||||
cl_svm_mem_flags_arm flags,
|
||||
size_t size,
|
||||
|
@ -791,68 +787,68 @@ clSVMAllocARM(cl_context context,
|
|||
|
||||
extern CL_API_ENTRY void CL_API_CALL
|
||||
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
|
||||
clEnqueueSVMFreeARM(cl_command_queue command_queue,
|
||||
cl_uint num_svm_pointers,
|
||||
void * svm_pointers[],
|
||||
void (CL_CALLBACK * pfn_free_func)(cl_command_queue queue,
|
||||
cl_uint num_svm_pointers,
|
||||
void * svm_pointers[],
|
||||
void * user_data),
|
||||
void * user_data,
|
||||
void *svm_pointers[],
|
||||
void (CL_CALLBACK *pfn_free_func)(cl_command_queue queue,
|
||||
cl_uint num_svm_pointers,
|
||||
void *svm_pointers[],
|
||||
void *user_data),
|
||||
void *user_data,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueSVMMemcpyARM(cl_command_queue command_queue,
|
||||
cl_bool blocking_copy,
|
||||
void * dst_ptr,
|
||||
const void * src_ptr,
|
||||
void *dst_ptr,
|
||||
const void *src_ptr,
|
||||
size_t size,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueSVMMemFillARM(cl_command_queue command_queue,
|
||||
void * svm_ptr,
|
||||
const void * pattern,
|
||||
void *svm_ptr,
|
||||
const void *pattern,
|
||||
size_t pattern_size,
|
||||
size_t size,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueSVMMapARM(cl_command_queue command_queue,
|
||||
cl_bool blocking_map,
|
||||
cl_map_flags flags,
|
||||
void * svm_ptr,
|
||||
void *svm_ptr,
|
||||
size_t size,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueSVMUnmapARM(cl_command_queue command_queue,
|
||||
void * svm_ptr,
|
||||
void *svm_ptr,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clSetKernelArgSVMPointerARM(cl_kernel kernel,
|
||||
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
|
||||
clSetKernelExecInfoARM(cl_kernel kernel,
|
||||
cl_kernel_exec_info_arm param_name,
|
||||
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 *
|
||||
|
|
|
@ -75,7 +75,7 @@ extern "C" {
|
|||
#define cl_intel_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_info_intel;
|
||||
|
||||
|
@ -171,43 +171,43 @@ clCreateAcceleratorINTEL(
|
|||
cl_context context,
|
||||
cl_accelerator_type_intel accelerator_type,
|
||||
size_t descriptor_size,
|
||||
const void* descriptor,
|
||||
cl_int* errcode_ret) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
const void *descriptor,
|
||||
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_accelerator_type_intel accelerator_type,
|
||||
size_t descriptor_size,
|
||||
const void* descriptor,
|
||||
cl_int* errcode_ret) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
const void *descriptor,
|
||||
cl_int *errcode_ret) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clGetAcceleratorInfoINTEL(
|
||||
cl_accelerator_intel accelerator,
|
||||
cl_accelerator_info_intel param_name,
|
||||
size_t param_value_size,
|
||||
void* param_value,
|
||||
size_t* param_value_size_ret) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
void *param_value,
|
||||
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_info_intel param_name,
|
||||
size_t param_value_size,
|
||||
void* param_value,
|
||||
size_t* param_value_size_ret) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
void *param_value,
|
||||
size_t *param_value_size_ret) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clRetainAcceleratorINTEL(
|
||||
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;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clReleaseAcceleratorINTEL(
|
||||
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;
|
||||
|
||||
/******************************************
|
||||
|
@ -472,171 +472,171 @@ typedef cl_uint cl_mem_advice_intel;
|
|||
#define CL_COMMAND_MIGRATEMEM_INTEL 0x4206
|
||||
#define CL_COMMAND_MEMADVISE_INTEL 0x4207
|
||||
|
||||
extern CL_API_ENTRY void* CL_API_CALL
|
||||
extern CL_API_ENTRY void *CL_API_CALL
|
||||
clHostMemAllocINTEL(
|
||||
cl_context context,
|
||||
const cl_mem_properties_intel* properties,
|
||||
size_t size,
|
||||
cl_uint alignment,
|
||||
cl_int* errcode_ret);
|
||||
cl_context context,
|
||||
const cl_mem_properties_intel *properties,
|
||||
size_t size,
|
||||
cl_uint alignment,
|
||||
cl_int *errcode_ret);
|
||||
|
||||
typedef CL_API_ENTRY void* (CL_API_CALL *
|
||||
clHostMemAllocINTEL_fn)(
|
||||
cl_context context,
|
||||
const cl_mem_properties_intel* properties,
|
||||
size_t size,
|
||||
cl_uint alignment,
|
||||
cl_int* errcode_ret);
|
||||
typedef CL_API_ENTRY void *(CL_API_CALL *
|
||||
clHostMemAllocINTEL_fn)(
|
||||
cl_context context,
|
||||
const cl_mem_properties_intel *properties,
|
||||
size_t size,
|
||||
cl_uint alignment,
|
||||
cl_int *errcode_ret);
|
||||
|
||||
extern CL_API_ENTRY void* CL_API_CALL
|
||||
extern CL_API_ENTRY void *CL_API_CALL
|
||||
clDeviceMemAllocINTEL(
|
||||
cl_context context,
|
||||
cl_device_id device,
|
||||
const cl_mem_properties_intel* properties,
|
||||
size_t size,
|
||||
cl_uint alignment,
|
||||
cl_int* errcode_ret);
|
||||
cl_context context,
|
||||
cl_device_id device,
|
||||
const cl_mem_properties_intel *properties,
|
||||
size_t size,
|
||||
cl_uint alignment,
|
||||
cl_int *errcode_ret);
|
||||
|
||||
typedef CL_API_ENTRY void* (CL_API_CALL *
|
||||
clDeviceMemAllocINTEL_fn)(
|
||||
cl_context context,
|
||||
cl_device_id device,
|
||||
const cl_mem_properties_intel* properties,
|
||||
size_t size,
|
||||
cl_uint alignment,
|
||||
cl_int* errcode_ret);
|
||||
typedef CL_API_ENTRY void *(CL_API_CALL *
|
||||
clDeviceMemAllocINTEL_fn)(
|
||||
cl_context context,
|
||||
cl_device_id device,
|
||||
const cl_mem_properties_intel *properties,
|
||||
size_t size,
|
||||
cl_uint alignment,
|
||||
cl_int *errcode_ret);
|
||||
|
||||
extern CL_API_ENTRY void* CL_API_CALL
|
||||
extern CL_API_ENTRY void *CL_API_CALL
|
||||
clSharedMemAllocINTEL(
|
||||
cl_context context,
|
||||
cl_device_id device,
|
||||
const cl_mem_properties_intel* properties,
|
||||
size_t size,
|
||||
cl_uint alignment,
|
||||
cl_int* errcode_ret);
|
||||
cl_context context,
|
||||
cl_device_id device,
|
||||
const cl_mem_properties_intel *properties,
|
||||
size_t size,
|
||||
cl_uint alignment,
|
||||
cl_int *errcode_ret);
|
||||
|
||||
typedef CL_API_ENTRY void* (CL_API_CALL *
|
||||
clSharedMemAllocINTEL_fn)(
|
||||
cl_context context,
|
||||
cl_device_id device,
|
||||
const cl_mem_properties_intel* properties,
|
||||
size_t size,
|
||||
cl_uint alignment,
|
||||
cl_int* errcode_ret);
|
||||
typedef CL_API_ENTRY void *(CL_API_CALL *
|
||||
clSharedMemAllocINTEL_fn)(
|
||||
cl_context context,
|
||||
cl_device_id device,
|
||||
const cl_mem_properties_intel *properties,
|
||||
size_t size,
|
||||
cl_uint alignment,
|
||||
cl_int *errcode_ret);
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clMemFreeINTEL(
|
||||
cl_context context,
|
||||
void* ptr);
|
||||
cl_context context,
|
||||
void *ptr);
|
||||
|
||||
typedef CL_API_ENTRY cl_int (CL_API_CALL *
|
||||
clMemFreeINTEL_fn)(
|
||||
cl_context context,
|
||||
void* ptr);
|
||||
typedef CL_API_ENTRY cl_int(CL_API_CALL *
|
||||
clMemFreeINTEL_fn)(
|
||||
cl_context context,
|
||||
void *ptr);
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clMemBlockingFreeINTEL(
|
||||
cl_context context,
|
||||
void* ptr);
|
||||
cl_context context,
|
||||
void *ptr);
|
||||
|
||||
typedef CL_API_ENTRY cl_int (CL_API_CALL *
|
||||
clMemBlockingFreeINTEL_fn)(
|
||||
cl_context context,
|
||||
void* ptr);
|
||||
typedef CL_API_ENTRY cl_int(CL_API_CALL *
|
||||
clMemBlockingFreeINTEL_fn)(
|
||||
cl_context context,
|
||||
void *ptr);
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clGetMemAllocInfoINTEL(
|
||||
cl_context context,
|
||||
const void* ptr,
|
||||
cl_mem_info_intel param_name,
|
||||
size_t param_value_size,
|
||||
void* param_value,
|
||||
size_t* param_value_size_ret);
|
||||
cl_context context,
|
||||
const void *ptr,
|
||||
cl_mem_info_intel param_name,
|
||||
size_t param_value_size,
|
||||
void *param_value,
|
||||
size_t *param_value_size_ret);
|
||||
|
||||
typedef CL_API_ENTRY cl_int (CL_API_CALL *
|
||||
clGetMemAllocInfoINTEL_fn)(
|
||||
cl_context context,
|
||||
const void* ptr,
|
||||
cl_mem_info_intel param_name,
|
||||
size_t param_value_size,
|
||||
void* param_value,
|
||||
size_t* param_value_size_ret);
|
||||
typedef CL_API_ENTRY cl_int(CL_API_CALL *
|
||||
clGetMemAllocInfoINTEL_fn)(
|
||||
cl_context context,
|
||||
const void *ptr,
|
||||
cl_mem_info_intel param_name,
|
||||
size_t param_value_size,
|
||||
void *param_value,
|
||||
size_t *param_value_size_ret);
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clSetKernelArgMemPointerINTEL(
|
||||
cl_kernel kernel,
|
||||
cl_uint arg_index,
|
||||
const void* arg_value);
|
||||
cl_kernel kernel,
|
||||
cl_uint arg_index,
|
||||
const void *arg_value);
|
||||
|
||||
typedef CL_API_ENTRY cl_int (CL_API_CALL *
|
||||
clSetKernelArgMemPointerINTEL_fn)(
|
||||
cl_kernel kernel,
|
||||
cl_uint arg_index,
|
||||
const void* arg_value);
|
||||
typedef CL_API_ENTRY cl_int(CL_API_CALL *
|
||||
clSetKernelArgMemPointerINTEL_fn)(
|
||||
cl_kernel kernel,
|
||||
cl_uint arg_index,
|
||||
const void *arg_value);
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueMemsetINTEL( /* Deprecated */
|
||||
cl_command_queue command_queue,
|
||||
void* dst_ptr,
|
||||
cl_int value,
|
||||
size_t size,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event* event_wait_list,
|
||||
cl_event* event);
|
||||
cl_command_queue command_queue,
|
||||
void *dst_ptr,
|
||||
cl_int value,
|
||||
size_t size,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event);
|
||||
|
||||
typedef CL_API_ENTRY cl_int (CL_API_CALL *
|
||||
clEnqueueMemsetINTEL_fn)( /* Deprecated */
|
||||
cl_command_queue command_queue,
|
||||
void* dst_ptr,
|
||||
cl_int value,
|
||||
size_t size,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event* event_wait_list,
|
||||
cl_event* event);
|
||||
typedef CL_API_ENTRY cl_int(CL_API_CALL *
|
||||
clEnqueueMemsetINTEL_fn)( /* Deprecated */
|
||||
cl_command_queue command_queue,
|
||||
void *dst_ptr,
|
||||
cl_int value,
|
||||
size_t size,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event);
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueMemFillINTEL(
|
||||
cl_command_queue command_queue,
|
||||
void* dst_ptr,
|
||||
const void* pattern,
|
||||
size_t pattern_size,
|
||||
size_t size,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event* event_wait_list,
|
||||
cl_event* event);
|
||||
cl_command_queue command_queue,
|
||||
void *dst_ptr,
|
||||
const void *pattern,
|
||||
size_t pattern_size,
|
||||
size_t size,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event);
|
||||
|
||||
typedef CL_API_ENTRY cl_int (CL_API_CALL *
|
||||
clEnqueueMemFillINTEL_fn)(
|
||||
cl_command_queue command_queue,
|
||||
void* dst_ptr,
|
||||
const void* pattern,
|
||||
size_t pattern_size,
|
||||
size_t size,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event* event_wait_list,
|
||||
cl_event* event);
|
||||
typedef CL_API_ENTRY cl_int(CL_API_CALL *
|
||||
clEnqueueMemFillINTEL_fn)(
|
||||
cl_command_queue command_queue,
|
||||
void *dst_ptr,
|
||||
const void *pattern,
|
||||
size_t pattern_size,
|
||||
size_t size,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event);
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueMemcpyINTEL(
|
||||
cl_command_queue command_queue,
|
||||
cl_bool blocking,
|
||||
void* dst_ptr,
|
||||
const void* src_ptr,
|
||||
size_t size,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event* event_wait_list,
|
||||
cl_event* event);
|
||||
cl_command_queue command_queue,
|
||||
cl_bool blocking,
|
||||
void *dst_ptr,
|
||||
const void *src_ptr,
|
||||
size_t size,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event);
|
||||
|
||||
typedef CL_API_ENTRY cl_int (CL_API_CALL *
|
||||
clEnqueueMemcpyINTEL_fn)(
|
||||
cl_command_queue command_queue,
|
||||
cl_bool blocking,
|
||||
void* dst_ptr,
|
||||
const void* src_ptr,
|
||||
size_t size,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event* event_wait_list,
|
||||
cl_event* event);
|
||||
typedef CL_API_ENTRY cl_int(CL_API_CALL *
|
||||
clEnqueueMemcpyINTEL_fn)(
|
||||
cl_command_queue command_queue,
|
||||
cl_bool blocking,
|
||||
void *dst_ptr,
|
||||
const void *src_ptr,
|
||||
size_t size,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event);
|
||||
|
||||
#ifdef CL_VERSION_1_2
|
||||
|
||||
|
@ -645,45 +645,45 @@ clEnqueueMemcpyINTEL_fn)(
|
|||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueMigrateMemINTEL(
|
||||
cl_command_queue command_queue,
|
||||
const void* ptr,
|
||||
size_t size,
|
||||
cl_mem_migration_flags flags,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event* event_wait_list,
|
||||
cl_event* event);
|
||||
cl_command_queue command_queue,
|
||||
const void *ptr,
|
||||
size_t size,
|
||||
cl_mem_migration_flags flags,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event);
|
||||
|
||||
typedef CL_API_ENTRY cl_int (CL_API_CALL *
|
||||
clEnqueueMigrateMemINTEL_fn)(
|
||||
cl_command_queue command_queue,
|
||||
const void* ptr,
|
||||
size_t size,
|
||||
cl_mem_migration_flags flags,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event* event_wait_list,
|
||||
cl_event* event);
|
||||
typedef CL_API_ENTRY cl_int(CL_API_CALL *
|
||||
clEnqueueMigrateMemINTEL_fn)(
|
||||
cl_command_queue command_queue,
|
||||
const void *ptr,
|
||||
size_t size,
|
||||
cl_mem_migration_flags flags,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event);
|
||||
|
||||
#endif
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueMemAdviseINTEL(
|
||||
cl_command_queue command_queue,
|
||||
const void* ptr,
|
||||
size_t size,
|
||||
cl_mem_advice_intel advice,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event* event_wait_list,
|
||||
cl_event* event);
|
||||
cl_command_queue command_queue,
|
||||
const void *ptr,
|
||||
size_t size,
|
||||
cl_mem_advice_intel advice,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event);
|
||||
|
||||
typedef CL_API_ENTRY cl_int (CL_API_CALL *
|
||||
clEnqueueMemAdviseINTEL_fn)(
|
||||
cl_command_queue command_queue,
|
||||
const void* ptr,
|
||||
size_t size,
|
||||
cl_mem_advice_intel advice,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event* event_wait_list,
|
||||
cl_event* event);
|
||||
typedef CL_API_ENTRY cl_int(CL_API_CALL *
|
||||
clEnqueueMemAdviseINTEL_fn)(
|
||||
cl_command_queue command_queue,
|
||||
const void *ptr,
|
||||
size_t size,
|
||||
cl_mem_advice_intel advice,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event);
|
||||
|
||||
/***************************************************
|
||||
* cl_intel_create_buffer_with_properties extension *
|
||||
|
@ -694,20 +694,20 @@ clEnqueueMemAdviseINTEL_fn)(
|
|||
extern CL_API_ENTRY cl_mem CL_API_CALL
|
||||
clCreateBufferWithPropertiesINTEL(
|
||||
cl_context context,
|
||||
const cl_mem_properties_intel* properties,
|
||||
const cl_mem_properties_intel *properties,
|
||||
cl_mem_flags flags,
|
||||
size_t size,
|
||||
void * host_ptr,
|
||||
cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_0;
|
||||
void *host_ptr,
|
||||
cl_int *errcode_ret) CL_EXT_SUFFIX__VERSION_1_0;
|
||||
|
||||
typedef CL_API_ENTRY cl_mem (CL_API_CALL *
|
||||
clCreateBufferWithPropertiesINTEL_fn)(
|
||||
cl_context context,
|
||||
const cl_mem_properties_intel* properties,
|
||||
cl_mem_flags flags,
|
||||
size_t size,
|
||||
void * host_ptr,
|
||||
cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_0;
|
||||
typedef CL_API_ENTRY cl_mem(CL_API_CALL *
|
||||
clCreateBufferWithPropertiesINTEL_fn)(
|
||||
cl_context context,
|
||||
const cl_mem_properties_intel *properties,
|
||||
cl_mem_flags flags,
|
||||
size_t size,
|
||||
void *host_ptr,
|
||||
cl_int *errcode_ret) CL_EXT_SUFFIX__VERSION_1_0;
|
||||
|
||||
/******************************************
|
||||
* cl_intel_mem_channel_property extension *
|
||||
|
|
|
@ -52,7 +52,7 @@ extern CL_API_ENTRY cl_mem CL_API_CALL
|
|||
clCreateFromGLBuffer(cl_context context,
|
||||
cl_mem_flags flags,
|
||||
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
|
||||
|
||||
|
@ -62,7 +62,7 @@ clCreateFromGLTexture(cl_context context,
|
|||
cl_GLenum target,
|
||||
cl_GLint miplevel,
|
||||
cl_GLuint texture,
|
||||
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2;
|
||||
cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_2;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -70,35 +70,35 @@ extern CL_API_ENTRY cl_mem CL_API_CALL
|
|||
clCreateFromGLRenderbuffer(cl_context context,
|
||||
cl_mem_flags flags,
|
||||
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
|
||||
clGetGLObjectInfo(cl_mem memobj,
|
||||
cl_gl_object_type * gl_object_type,
|
||||
cl_GLuint * gl_object_name) CL_API_SUFFIX__VERSION_1_0;
|
||||
cl_gl_object_type *gl_object_type,
|
||||
cl_GLuint *gl_object_name) CL_API_SUFFIX__VERSION_1_0;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clGetGLTextureInfo(cl_mem memobj,
|
||||
cl_gl_texture_info param_name,
|
||||
size_t param_value_size,
|
||||
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;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueAcquireGLObjects(cl_command_queue command_queue,
|
||||
cl_uint num_objects,
|
||||
const cl_mem * mem_objects,
|
||||
const cl_mem *mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_API_SUFFIX__VERSION_1_0;
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event) CL_API_SUFFIX__VERSION_1_0;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueReleaseGLObjects(cl_command_queue command_queue,
|
||||
cl_uint num_objects,
|
||||
const cl_mem * mem_objects,
|
||||
const cl_mem *mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_API_SUFFIX__VERSION_1_0;
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event) CL_API_SUFFIX__VERSION_1_0;
|
||||
|
||||
|
||||
/* Deprecated OpenCL 1.1 APIs */
|
||||
|
@ -108,7 +108,7 @@ clCreateFromGLTexture2D(cl_context context,
|
|||
cl_GLenum target,
|
||||
cl_GLint miplevel,
|
||||
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
|
||||
clCreateFromGLTexture3D(cl_context context,
|
||||
|
@ -116,7 +116,7 @@ clCreateFromGLTexture3D(cl_context context,
|
|||
cl_GLenum target,
|
||||
cl_GLint miplevel,
|
||||
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 */
|
||||
|
||||
|
@ -139,18 +139,18 @@ typedef cl_uint cl_gl_context_info;
|
|||
#define CL_CGL_SHAREGROUP_KHR 0x200C
|
||||
|
||||
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,
|
||||
size_t param_value_size,
|
||||
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 *clGetGLContextInfoKHR_fn)(
|
||||
const cl_context_properties * properties,
|
||||
typedef CL_API_ENTRY cl_int(CL_API_CALL *clGetGLContextInfoKHR_fn)(
|
||||
const cl_context_properties *properties,
|
||||
cl_gl_context_info param_name,
|
||||
size_t param_value_size,
|
||||
void * param_value,
|
||||
size_t * param_value_size_ret);
|
||||
void *param_value,
|
||||
size_t *param_value_size_ret);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ extern "C" {
|
|||
extern CL_API_ENTRY cl_event CL_API_CALL
|
||||
clCreateEventFromGLsyncKHR(cl_context context,
|
||||
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
|
||||
}
|
||||
|
|
|
@ -41,12 +41,11 @@ extern "C" {
|
|||
/**
|
||||
* Rounding mode used when converting to cl_half.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
CL_HALF_RTE, // round to nearest even
|
||||
CL_HALF_RTZ, // round towards zero
|
||||
CL_HALF_RTP, // round towards positive infinity
|
||||
CL_HALF_RTN, // round towards negative infinity
|
||||
typedef enum {
|
||||
CL_HALF_RTE, // round to nearest even
|
||||
CL_HALF_RTZ, // round towards zero
|
||||
CL_HALF_RTP, // round towards positive infinity
|
||||
CL_HALF_RTN, // round towards negative infinity
|
||||
} cl_half_rounding_mode;
|
||||
|
||||
|
||||
|
@ -59,372 +58,317 @@ typedef enum
|
|||
* 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,
|
||||
uint16_t sign)
|
||||
{
|
||||
if (rounding_mode == CL_HALF_RTZ)
|
||||
{
|
||||
// Round overflow towards zero -> largest finite number (preserving sign)
|
||||
return (sign << 15) | CL_HALF_MAX_FINITE_MAG;
|
||||
}
|
||||
else if (rounding_mode == CL_HALF_RTP && sign)
|
||||
{
|
||||
// Round negative overflow towards positive infinity -> most negative finite number
|
||||
return (1 << 15) | CL_HALF_MAX_FINITE_MAG;
|
||||
}
|
||||
else if (rounding_mode == CL_HALF_RTN && !sign)
|
||||
{
|
||||
// Round positive overflow towards negative infinity -> largest finite number
|
||||
return CL_HALF_MAX_FINITE_MAG;
|
||||
}
|
||||
uint16_t sign) {
|
||||
if (rounding_mode == CL_HALF_RTZ) {
|
||||
// Round overflow towards zero -> largest finite number (preserving sign)
|
||||
return (sign << 15) | CL_HALF_MAX_FINITE_MAG;
|
||||
} else if (rounding_mode == CL_HALF_RTP && sign) {
|
||||
// Round negative overflow towards positive infinity -> most negative finite number
|
||||
return (1 << 15) | CL_HALF_MAX_FINITE_MAG;
|
||||
} else if (rounding_mode == CL_HALF_RTN && !sign) {
|
||||
// Round positive overflow towards negative infinity -> largest finite number
|
||||
return CL_HALF_MAX_FINITE_MAG;
|
||||
}
|
||||
|
||||
// Overflow to infinity
|
||||
return (sign << 15) | CL_HALF_EXP_MASK;
|
||||
// Overflow to infinity
|
||||
return (sign << 15) | CL_HALF_EXP_MASK;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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,
|
||||
uint16_t sign)
|
||||
{
|
||||
if (rounding_mode == CL_HALF_RTP && !sign)
|
||||
{
|
||||
// Round underflow towards positive infinity -> smallest positive value
|
||||
return (sign << 15) | 1;
|
||||
}
|
||||
else if (rounding_mode == CL_HALF_RTN && sign)
|
||||
{
|
||||
// Round underflow towards negative infinity -> largest negative value
|
||||
return (sign << 15) | 1;
|
||||
}
|
||||
uint16_t sign) {
|
||||
if (rounding_mode == CL_HALF_RTP && !sign) {
|
||||
// Round underflow towards positive infinity -> smallest positive value
|
||||
return (sign << 15) | 1;
|
||||
} else if (rounding_mode == CL_HALF_RTN && sign) {
|
||||
// Round underflow towards negative infinity -> largest negative value
|
||||
return (sign << 15) | 1;
|
||||
}
|
||||
|
||||
// Flush to zero
|
||||
return (sign << 15);
|
||||
// Flush to zero
|
||||
return (sign << 15);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
// Type-punning to get direct access to underlying bits
|
||||
union
|
||||
{
|
||||
cl_float f;
|
||||
uint32_t i;
|
||||
} f32;
|
||||
f32.f = f;
|
||||
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
|
||||
union {
|
||||
cl_float f;
|
||||
uint32_t i;
|
||||
} f32;
|
||||
f32.f = f;
|
||||
|
||||
// Extract sign bit
|
||||
uint16_t sign = f32.i >> 31;
|
||||
// Extract sign bit
|
||||
uint16_t sign = f32.i >> 31;
|
||||
|
||||
// Extract FP32 exponent and mantissa
|
||||
uint32_t f_exp = (f32.i >> (CL_FLT_MANT_DIG - 1)) & 0xFF;
|
||||
uint32_t f_mant = f32.i & ((1 << (CL_FLT_MANT_DIG - 1)) - 1);
|
||||
// Extract FP32 exponent and mantissa
|
||||
uint32_t f_exp = (f32.i >> (CL_FLT_MANT_DIG - 1)) & 0xFF;
|
||||
uint32_t f_mant = f32.i & ((1 << (CL_FLT_MANT_DIG - 1)) - 1);
|
||||
|
||||
// Remove FP32 exponent bias
|
||||
int32_t exp = f_exp - CL_FLT_MAX_EXP + 1;
|
||||
// Remove FP32 exponent bias
|
||||
int32_t exp = f_exp - CL_FLT_MAX_EXP + 1;
|
||||
|
||||
// Add FP16 exponent bias
|
||||
uint16_t h_exp = (uint16_t)(exp + CL_HALF_MAX_EXP - 1);
|
||||
// Add FP16 exponent bias
|
||||
uint16_t h_exp = (uint16_t)(exp + CL_HALF_MAX_EXP - 1);
|
||||
|
||||
// Position of the bit that will become the FP16 mantissa LSB
|
||||
uint32_t lsb_pos = CL_FLT_MANT_DIG - CL_HALF_MANT_DIG;
|
||||
// Position of the bit that will become the FP16 mantissa LSB
|
||||
uint32_t lsb_pos = CL_FLT_MANT_DIG - CL_HALF_MANT_DIG;
|
||||
|
||||
// Check for NaN / infinity
|
||||
if (f_exp == 0xFF)
|
||||
{
|
||||
if (f_mant)
|
||||
{
|
||||
// NaN -> propagate mantissa and silence it
|
||||
uint16_t h_mant = (uint16_t)(f_mant >> lsb_pos);
|
||||
h_mant |= 0x200;
|
||||
return (sign << 15) | CL_HALF_EXP_MASK | h_mant;
|
||||
// Check for NaN / infinity
|
||||
if (f_exp == 0xFF) {
|
||||
if (f_mant) {
|
||||
// NaN -> propagate mantissa and silence it
|
||||
uint16_t h_mant = (uint16_t)(f_mant >> lsb_pos);
|
||||
h_mant |= 0x200;
|
||||
return (sign << 15) | CL_HALF_EXP_MASK | h_mant;
|
||||
} else {
|
||||
// Infinity -> zero mantissa
|
||||
return (sign << 15) | CL_HALF_EXP_MASK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Infinity -> zero mantissa
|
||||
return (sign << 15) | CL_HALF_EXP_MASK;
|
||||
|
||||
// Check for zero
|
||||
if (!f_exp && !f_mant) {
|
||||
return (sign << 15);
|
||||
}
|
||||
}
|
||||
|
||||
// Check for zero
|
||||
if (!f_exp && !f_mant)
|
||||
{
|
||||
return (sign << 15);
|
||||
}
|
||||
// Check for overflow
|
||||
if (exp >= CL_HALF_MAX_EXP) {
|
||||
return cl_half_handle_overflow(rounding_mode, sign);
|
||||
}
|
||||
|
||||
// Check for overflow
|
||||
if (exp >= CL_HALF_MAX_EXP)
|
||||
{
|
||||
return cl_half_handle_overflow(rounding_mode, sign);
|
||||
}
|
||||
// Check for underflow
|
||||
if (exp < (CL_HALF_MIN_EXP - CL_HALF_MANT_DIG - 1)) {
|
||||
return cl_half_handle_underflow(rounding_mode, sign);
|
||||
}
|
||||
|
||||
// Check for underflow
|
||||
if (exp < (CL_HALF_MIN_EXP - CL_HALF_MANT_DIG - 1))
|
||||
{
|
||||
return cl_half_handle_underflow(rounding_mode, sign);
|
||||
}
|
||||
// Check for value that will become denormal
|
||||
if (exp < -14) {
|
||||
// Denormal -> include the implicit 1 from the FP32 mantissa
|
||||
h_exp = 0;
|
||||
f_mant |= 1 << (CL_FLT_MANT_DIG - 1);
|
||||
|
||||
// Check for value that will become denormal
|
||||
if (exp < -14)
|
||||
{
|
||||
// Denormal -> include the implicit 1 from the FP32 mantissa
|
||||
h_exp = 0;
|
||||
f_mant |= 1 << (CL_FLT_MANT_DIG - 1);
|
||||
// Mantissa shift amount depends on exponent
|
||||
lsb_pos = -exp + (CL_FLT_MANT_DIG - 25);
|
||||
}
|
||||
|
||||
// Mantissa shift amount depends on exponent
|
||||
lsb_pos = -exp + (CL_FLT_MANT_DIG - 25);
|
||||
}
|
||||
// Generate FP16 mantissa by shifting FP32 mantissa
|
||||
uint16_t h_mant = (uint16_t)(f_mant >> lsb_pos);
|
||||
|
||||
// Generate FP16 mantissa by shifting FP32 mantissa
|
||||
uint16_t h_mant = (uint16_t)(f_mant >> lsb_pos);
|
||||
// Check whether we need to round
|
||||
uint32_t halfway = 1 << (lsb_pos - 1);
|
||||
uint32_t mask = (halfway << 1) - 1;
|
||||
switch (rounding_mode) {
|
||||
case CL_HALF_RTE:
|
||||
if ((f_mant & mask) > halfway) {
|
||||
// More than halfway -> round up
|
||||
h_mant += 1;
|
||||
} else if ((f_mant & mask) == halfway) {
|
||||
// Exactly halfway -> round to nearest even
|
||||
if (h_mant & 0x1)
|
||||
h_mant += 1;
|
||||
}
|
||||
break;
|
||||
case CL_HALF_RTZ:
|
||||
// Mantissa has already been truncated -> do nothing
|
||||
break;
|
||||
case CL_HALF_RTP:
|
||||
if ((f_mant & mask) && !sign) {
|
||||
// Round positive numbers up
|
||||
h_mant += 1;
|
||||
}
|
||||
break;
|
||||
case CL_HALF_RTN:
|
||||
if ((f_mant & mask) && sign) {
|
||||
// Round negative numbers down
|
||||
h_mant += 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Check whether we need to round
|
||||
uint32_t halfway = 1 << (lsb_pos - 1);
|
||||
uint32_t mask = (halfway << 1) - 1;
|
||||
switch (rounding_mode)
|
||||
{
|
||||
case CL_HALF_RTE:
|
||||
if ((f_mant & mask) > halfway)
|
||||
{
|
||||
// More than halfway -> round up
|
||||
h_mant += 1;
|
||||
}
|
||||
else if ((f_mant & mask) == halfway)
|
||||
{
|
||||
// Exactly halfway -> round to nearest even
|
||||
if (h_mant & 0x1)
|
||||
h_mant += 1;
|
||||
}
|
||||
break;
|
||||
case CL_HALF_RTZ:
|
||||
// Mantissa has already been truncated -> do nothing
|
||||
break;
|
||||
case CL_HALF_RTP:
|
||||
if ((f_mant & mask) && !sign)
|
||||
{
|
||||
// Round positive numbers up
|
||||
h_mant += 1;
|
||||
}
|
||||
break;
|
||||
case CL_HALF_RTN:
|
||||
if ((f_mant & mask) && sign)
|
||||
{
|
||||
// Round negative numbers down
|
||||
h_mant += 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Check for mantissa overflow
|
||||
if (h_mant & 0x400) {
|
||||
h_exp += 1;
|
||||
h_mant = 0;
|
||||
}
|
||||
|
||||
// Check for mantissa overflow
|
||||
if (h_mant & 0x400)
|
||||
{
|
||||
h_exp += 1;
|
||||
h_mant = 0;
|
||||
}
|
||||
|
||||
return (sign << 15) | (h_exp << 10) | h_mant;
|
||||
return (sign << 15) | (h_exp << 10) | h_mant;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
// Type-punning to get direct access to underlying bits
|
||||
union
|
||||
{
|
||||
cl_double d;
|
||||
uint64_t i;
|
||||
} f64;
|
||||
f64.d = d;
|
||||
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
|
||||
union {
|
||||
cl_double d;
|
||||
uint64_t i;
|
||||
} f64;
|
||||
f64.d = d;
|
||||
|
||||
// Extract sign bit
|
||||
uint16_t sign = f64.i >> 63;
|
||||
// Extract sign bit
|
||||
uint16_t sign = f64.i >> 63;
|
||||
|
||||
// Extract FP64 exponent and mantissa
|
||||
uint64_t d_exp = (f64.i >> (CL_DBL_MANT_DIG - 1)) & 0x7FF;
|
||||
uint64_t d_mant = f64.i & (((uint64_t)1 << (CL_DBL_MANT_DIG - 1)) - 1);
|
||||
// Extract FP64 exponent and mantissa
|
||||
uint64_t d_exp = (f64.i >> (CL_DBL_MANT_DIG - 1)) & 0x7FF;
|
||||
uint64_t d_mant = f64.i & (((uint64_t)1 << (CL_DBL_MANT_DIG - 1)) - 1);
|
||||
|
||||
// Remove FP64 exponent bias
|
||||
int64_t exp = d_exp - CL_DBL_MAX_EXP + 1;
|
||||
// Remove FP64 exponent bias
|
||||
int64_t exp = d_exp - CL_DBL_MAX_EXP + 1;
|
||||
|
||||
// Add FP16 exponent bias
|
||||
uint16_t h_exp = (uint16_t)(exp + CL_HALF_MAX_EXP - 1);
|
||||
// Add FP16 exponent bias
|
||||
uint16_t h_exp = (uint16_t)(exp + CL_HALF_MAX_EXP - 1);
|
||||
|
||||
// Position of the bit that will become the FP16 mantissa LSB
|
||||
uint32_t lsb_pos = CL_DBL_MANT_DIG - CL_HALF_MANT_DIG;
|
||||
// Position of the bit that will become the FP16 mantissa LSB
|
||||
uint32_t lsb_pos = CL_DBL_MANT_DIG - CL_HALF_MANT_DIG;
|
||||
|
||||
// Check for NaN / infinity
|
||||
if (d_exp == 0x7FF)
|
||||
{
|
||||
if (d_mant)
|
||||
{
|
||||
// NaN -> propagate mantissa and silence it
|
||||
uint16_t h_mant = (uint16_t)(d_mant >> lsb_pos);
|
||||
h_mant |= 0x200;
|
||||
return (sign << 15) | CL_HALF_EXP_MASK | h_mant;
|
||||
// Check for NaN / infinity
|
||||
if (d_exp == 0x7FF) {
|
||||
if (d_mant) {
|
||||
// NaN -> propagate mantissa and silence it
|
||||
uint16_t h_mant = (uint16_t)(d_mant >> lsb_pos);
|
||||
h_mant |= 0x200;
|
||||
return (sign << 15) | CL_HALF_EXP_MASK | h_mant;
|
||||
} else {
|
||||
// Infinity -> zero mantissa
|
||||
return (sign << 15) | CL_HALF_EXP_MASK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Infinity -> zero mantissa
|
||||
return (sign << 15) | CL_HALF_EXP_MASK;
|
||||
|
||||
// Check for zero
|
||||
if (!d_exp && !d_mant) {
|
||||
return (sign << 15);
|
||||
}
|
||||
}
|
||||
|
||||
// Check for zero
|
||||
if (!d_exp && !d_mant)
|
||||
{
|
||||
return (sign << 15);
|
||||
}
|
||||
// Check for overflow
|
||||
if (exp >= CL_HALF_MAX_EXP) {
|
||||
return cl_half_handle_overflow(rounding_mode, sign);
|
||||
}
|
||||
|
||||
// Check for overflow
|
||||
if (exp >= CL_HALF_MAX_EXP)
|
||||
{
|
||||
return cl_half_handle_overflow(rounding_mode, sign);
|
||||
}
|
||||
// Check for underflow
|
||||
if (exp < (CL_HALF_MIN_EXP - CL_HALF_MANT_DIG - 1)) {
|
||||
return cl_half_handle_underflow(rounding_mode, sign);
|
||||
}
|
||||
|
||||
// Check for underflow
|
||||
if (exp < (CL_HALF_MIN_EXP - CL_HALF_MANT_DIG - 1))
|
||||
{
|
||||
return cl_half_handle_underflow(rounding_mode, sign);
|
||||
}
|
||||
// Check for value that will become denormal
|
||||
if (exp < -14) {
|
||||
// Include the implicit 1 from the FP64 mantissa
|
||||
h_exp = 0;
|
||||
d_mant |= (uint64_t)1 << (CL_DBL_MANT_DIG - 1);
|
||||
|
||||
// Check for value that will become denormal
|
||||
if (exp < -14)
|
||||
{
|
||||
// Include the implicit 1 from the FP64 mantissa
|
||||
h_exp = 0;
|
||||
d_mant |= (uint64_t)1 << (CL_DBL_MANT_DIG - 1);
|
||||
// Mantissa shift amount depends on exponent
|
||||
lsb_pos = (uint32_t)(-exp + (CL_DBL_MANT_DIG - 25));
|
||||
}
|
||||
|
||||
// Mantissa shift amount depends on exponent
|
||||
lsb_pos = (uint32_t)(-exp + (CL_DBL_MANT_DIG - 25));
|
||||
}
|
||||
// Generate FP16 mantissa by shifting FP64 mantissa
|
||||
uint16_t h_mant = (uint16_t)(d_mant >> lsb_pos);
|
||||
|
||||
// Generate FP16 mantissa by shifting FP64 mantissa
|
||||
uint16_t h_mant = (uint16_t)(d_mant >> lsb_pos);
|
||||
// Check whether we need to round
|
||||
uint64_t halfway = (uint64_t)1 << (lsb_pos - 1);
|
||||
uint64_t mask = (halfway << 1) - 1;
|
||||
switch (rounding_mode) {
|
||||
case CL_HALF_RTE:
|
||||
if ((d_mant & mask) > halfway) {
|
||||
// More than halfway -> round up
|
||||
h_mant += 1;
|
||||
} else if ((d_mant & mask) == halfway) {
|
||||
// Exactly halfway -> round to nearest even
|
||||
if (h_mant & 0x1)
|
||||
h_mant += 1;
|
||||
}
|
||||
break;
|
||||
case CL_HALF_RTZ:
|
||||
// Mantissa has already been truncated -> do nothing
|
||||
break;
|
||||
case CL_HALF_RTP:
|
||||
if ((d_mant & mask) && !sign) {
|
||||
// Round positive numbers up
|
||||
h_mant += 1;
|
||||
}
|
||||
break;
|
||||
case CL_HALF_RTN:
|
||||
if ((d_mant & mask) && sign) {
|
||||
// Round negative numbers down
|
||||
h_mant += 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Check whether we need to round
|
||||
uint64_t halfway = (uint64_t)1 << (lsb_pos - 1);
|
||||
uint64_t mask = (halfway << 1) - 1;
|
||||
switch (rounding_mode)
|
||||
{
|
||||
case CL_HALF_RTE:
|
||||
if ((d_mant & mask) > halfway)
|
||||
{
|
||||
// More than halfway -> round up
|
||||
h_mant += 1;
|
||||
}
|
||||
else if ((d_mant & mask) == halfway)
|
||||
{
|
||||
// Exactly halfway -> round to nearest even
|
||||
if (h_mant & 0x1)
|
||||
h_mant += 1;
|
||||
}
|
||||
break;
|
||||
case CL_HALF_RTZ:
|
||||
// Mantissa has already been truncated -> do nothing
|
||||
break;
|
||||
case CL_HALF_RTP:
|
||||
if ((d_mant & mask) && !sign)
|
||||
{
|
||||
// Round positive numbers up
|
||||
h_mant += 1;
|
||||
}
|
||||
break;
|
||||
case CL_HALF_RTN:
|
||||
if ((d_mant & mask) && sign)
|
||||
{
|
||||
// Round negative numbers down
|
||||
h_mant += 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Check for mantissa overflow
|
||||
if (h_mant & 0x400) {
|
||||
h_exp += 1;
|
||||
h_mant = 0;
|
||||
}
|
||||
|
||||
// Check for mantissa overflow
|
||||
if (h_mant & 0x400)
|
||||
{
|
||||
h_exp += 1;
|
||||
h_mant = 0;
|
||||
}
|
||||
|
||||
return (sign << 15) | (h_exp << 10) | h_mant;
|
||||
return (sign << 15) | (h_exp << 10) | h_mant;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a cl_half to a cl_float.
|
||||
*/
|
||||
static inline cl_float cl_half_to_float(cl_half h)
|
||||
{
|
||||
// Type-punning to get direct access to underlying bits
|
||||
union
|
||||
{
|
||||
cl_float f;
|
||||
uint32_t i;
|
||||
} f32;
|
||||
static inline cl_float cl_half_to_float(cl_half h) {
|
||||
// Type-punning to get direct access to underlying bits
|
||||
union {
|
||||
cl_float f;
|
||||
uint32_t i;
|
||||
} f32;
|
||||
|
||||
// Extract sign bit
|
||||
uint16_t sign = h >> 15;
|
||||
// Extract sign bit
|
||||
uint16_t sign = h >> 15;
|
||||
|
||||
// Extract FP16 exponent and mantissa
|
||||
uint16_t h_exp = (h >> (CL_HALF_MANT_DIG - 1)) & 0x1F;
|
||||
uint16_t h_mant = h & 0x3FF;
|
||||
// Extract FP16 exponent and mantissa
|
||||
uint16_t h_exp = (h >> (CL_HALF_MANT_DIG - 1)) & 0x1F;
|
||||
uint16_t h_mant = h & 0x3FF;
|
||||
|
||||
// Remove FP16 exponent bias
|
||||
int32_t exp = h_exp - CL_HALF_MAX_EXP + 1;
|
||||
// Remove FP16 exponent bias
|
||||
int32_t exp = h_exp - CL_HALF_MAX_EXP + 1;
|
||||
|
||||
// Add FP32 exponent bias
|
||||
uint32_t f_exp = exp + CL_FLT_MAX_EXP - 1;
|
||||
// Add FP32 exponent bias
|
||||
uint32_t f_exp = exp + CL_FLT_MAX_EXP - 1;
|
||||
|
||||
// Check for NaN / infinity
|
||||
if (h_exp == 0x1F)
|
||||
{
|
||||
if (h_mant)
|
||||
{
|
||||
// NaN -> propagate mantissa and silence it
|
||||
uint32_t f_mant = h_mant << (CL_FLT_MANT_DIG - CL_HALF_MANT_DIG);
|
||||
f_mant |= 0x400000;
|
||||
f32.i = (sign << 31) | 0x7F800000 | f_mant;
|
||||
return f32.f;
|
||||
// Check for NaN / infinity
|
||||
if (h_exp == 0x1F) {
|
||||
if (h_mant) {
|
||||
// NaN -> propagate mantissa and silence it
|
||||
uint32_t f_mant = h_mant << (CL_FLT_MANT_DIG - CL_HALF_MANT_DIG);
|
||||
f_mant |= 0x400000;
|
||||
f32.i = (sign << 31) | 0x7F800000 | f_mant;
|
||||
return f32.f;
|
||||
} else {
|
||||
// Infinity -> zero mantissa
|
||||
f32.i = (sign << 31) | 0x7F800000;
|
||||
return f32.f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Infinity -> zero mantissa
|
||||
f32.i = (sign << 31) | 0x7F800000;
|
||||
return f32.f;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for zero / denormal
|
||||
if (h_exp == 0)
|
||||
{
|
||||
if (h_mant == 0)
|
||||
{
|
||||
// Zero -> zero exponent
|
||||
f_exp = 0;
|
||||
// Check for zero / denormal
|
||||
if (h_exp == 0) {
|
||||
if (h_mant == 0) {
|
||||
// Zero -> zero exponent
|
||||
f_exp = 0;
|
||||
} else {
|
||||
// Denormal -> normalize it
|
||||
// - Shift mantissa to make most-significant 1 implicit
|
||||
// - Adjust exponent accordingly
|
||||
uint32_t shift = 0;
|
||||
while ((h_mant & 0x400) == 0) {
|
||||
h_mant <<= 1;
|
||||
shift++;
|
||||
}
|
||||
h_mant &= 0x3FF;
|
||||
f_exp -= shift - 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Denormal -> normalize it
|
||||
// - Shift mantissa to make most-significant 1 implicit
|
||||
// - Adjust exponent accordingly
|
||||
uint32_t shift = 0;
|
||||
while ((h_mant & 0x400) == 0)
|
||||
{
|
||||
h_mant <<= 1;
|
||||
shift++;
|
||||
}
|
||||
h_mant &= 0x3FF;
|
||||
f_exp -= shift - 1;
|
||||
}
|
||||
}
|
||||
|
||||
f32.i = (sign << 31) | (f_exp << 23) | (h_mant << 13);
|
||||
return f32.f;
|
||||
f32.i = (sign << 31) | (f_exp << 23) | (h_mant << 13);
|
||||
return f32.f;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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,
|
||||
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,
|
||||
void(CL_CALLBACK* pfn_notify)(cl_context context, void* user_data),
|
||||
void* user_data) CL_API_SUFFIX__VERSION_3_0;
|
||||
void(CL_CALLBACK *pfn_notify)(cl_context context, void *user_data),
|
||||
void *user_data) CL_API_SUFFIX__VERSION_3_0;
|
||||
|
||||
#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;
|
||||
|
||||
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)
|
||||
CL_API_SUFFIX__VERSION_1_0;
|
||||
CL_API_SUFFIX__VERSION_1_0;
|
||||
|
||||
// Profiling APIs
|
||||
typedef CL_API_ENTRY cl_int(CL_API_CALL *cl_api_clGetEventProfilingInfo)(
|
||||
|
@ -637,8 +637,8 @@ typedef CL_API_ENTRY cl_int(CL_API_CALL *cl_api_clEnqueueBarrierWithWaitList)(
|
|||
|
||||
typedef CL_API_ENTRY void *(
|
||||
CL_API_CALL *cl_api_clGetExtensionFunctionAddressForPlatform)(
|
||||
cl_platform_id platform,
|
||||
const char *function_name)CL_API_SUFFIX__VERSION_1_2;
|
||||
cl_platform_id platform,
|
||||
const char *function_name)CL_API_SUFFIX__VERSION_1_2;
|
||||
|
||||
#else
|
||||
|
||||
|
@ -704,7 +704,7 @@ typedef void *cl_api_clEnqueueSVMUnmap;
|
|||
typedef CL_API_ENTRY cl_int(CL_API_CALL *cl_api_clSetCommandQueueProperty)(
|
||||
cl_command_queue command_queue, cl_command_queue_properties 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)(
|
||||
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;
|
||||
|
||||
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)(
|
||||
cl_command_queue command_queue,
|
||||
|
@ -1102,188 +1102,188 @@ typedef void *cl_api_clGetHostTimer;
|
|||
/* Vendor dispatch table struture */
|
||||
|
||||
typedef struct _cl_icd_dispatch {
|
||||
/* OpenCL 1.0 */
|
||||
cl_api_clGetPlatformIDs clGetPlatformIDs;
|
||||
cl_api_clGetPlatformInfo clGetPlatformInfo;
|
||||
cl_api_clGetDeviceIDs clGetDeviceIDs;
|
||||
cl_api_clGetDeviceInfo clGetDeviceInfo;
|
||||
cl_api_clCreateContext clCreateContext;
|
||||
cl_api_clCreateContextFromType clCreateContextFromType;
|
||||
cl_api_clRetainContext clRetainContext;
|
||||
cl_api_clReleaseContext clReleaseContext;
|
||||
cl_api_clGetContextInfo clGetContextInfo;
|
||||
cl_api_clCreateCommandQueue clCreateCommandQueue;
|
||||
cl_api_clRetainCommandQueue clRetainCommandQueue;
|
||||
cl_api_clReleaseCommandQueue clReleaseCommandQueue;
|
||||
cl_api_clGetCommandQueueInfo clGetCommandQueueInfo;
|
||||
cl_api_clSetCommandQueueProperty clSetCommandQueueProperty;
|
||||
cl_api_clCreateBuffer clCreateBuffer;
|
||||
cl_api_clCreateImage2D clCreateImage2D;
|
||||
cl_api_clCreateImage3D clCreateImage3D;
|
||||
cl_api_clRetainMemObject clRetainMemObject;
|
||||
cl_api_clReleaseMemObject clReleaseMemObject;
|
||||
cl_api_clGetSupportedImageFormats clGetSupportedImageFormats;
|
||||
cl_api_clGetMemObjectInfo clGetMemObjectInfo;
|
||||
cl_api_clGetImageInfo clGetImageInfo;
|
||||
cl_api_clCreateSampler clCreateSampler;
|
||||
cl_api_clRetainSampler clRetainSampler;
|
||||
cl_api_clReleaseSampler clReleaseSampler;
|
||||
cl_api_clGetSamplerInfo clGetSamplerInfo;
|
||||
cl_api_clCreateProgramWithSource clCreateProgramWithSource;
|
||||
cl_api_clCreateProgramWithBinary clCreateProgramWithBinary;
|
||||
cl_api_clRetainProgram clRetainProgram;
|
||||
cl_api_clReleaseProgram clReleaseProgram;
|
||||
cl_api_clBuildProgram clBuildProgram;
|
||||
cl_api_clUnloadCompiler clUnloadCompiler;
|
||||
cl_api_clGetProgramInfo clGetProgramInfo;
|
||||
cl_api_clGetProgramBuildInfo clGetProgramBuildInfo;
|
||||
cl_api_clCreateKernel clCreateKernel;
|
||||
cl_api_clCreateKernelsInProgram clCreateKernelsInProgram;
|
||||
cl_api_clRetainKernel clRetainKernel;
|
||||
cl_api_clReleaseKernel clReleaseKernel;
|
||||
cl_api_clSetKernelArg clSetKernelArg;
|
||||
cl_api_clGetKernelInfo clGetKernelInfo;
|
||||
cl_api_clGetKernelWorkGroupInfo clGetKernelWorkGroupInfo;
|
||||
cl_api_clWaitForEvents clWaitForEvents;
|
||||
cl_api_clGetEventInfo clGetEventInfo;
|
||||
cl_api_clRetainEvent clRetainEvent;
|
||||
cl_api_clReleaseEvent clReleaseEvent;
|
||||
cl_api_clGetEventProfilingInfo clGetEventProfilingInfo;
|
||||
cl_api_clFlush clFlush;
|
||||
cl_api_clFinish clFinish;
|
||||
cl_api_clEnqueueReadBuffer clEnqueueReadBuffer;
|
||||
cl_api_clEnqueueWriteBuffer clEnqueueWriteBuffer;
|
||||
cl_api_clEnqueueCopyBuffer clEnqueueCopyBuffer;
|
||||
cl_api_clEnqueueReadImage clEnqueueReadImage;
|
||||
cl_api_clEnqueueWriteImage clEnqueueWriteImage;
|
||||
cl_api_clEnqueueCopyImage clEnqueueCopyImage;
|
||||
cl_api_clEnqueueCopyImageToBuffer clEnqueueCopyImageToBuffer;
|
||||
cl_api_clEnqueueCopyBufferToImage clEnqueueCopyBufferToImage;
|
||||
cl_api_clEnqueueMapBuffer clEnqueueMapBuffer;
|
||||
cl_api_clEnqueueMapImage clEnqueueMapImage;
|
||||
cl_api_clEnqueueUnmapMemObject clEnqueueUnmapMemObject;
|
||||
cl_api_clEnqueueNDRangeKernel clEnqueueNDRangeKernel;
|
||||
cl_api_clEnqueueTask clEnqueueTask;
|
||||
cl_api_clEnqueueNativeKernel clEnqueueNativeKernel;
|
||||
cl_api_clEnqueueMarker clEnqueueMarker;
|
||||
cl_api_clEnqueueWaitForEvents clEnqueueWaitForEvents;
|
||||
cl_api_clEnqueueBarrier clEnqueueBarrier;
|
||||
cl_api_clGetExtensionFunctionAddress clGetExtensionFunctionAddress;
|
||||
cl_api_clCreateFromGLBuffer clCreateFromGLBuffer;
|
||||
cl_api_clCreateFromGLTexture2D clCreateFromGLTexture2D;
|
||||
cl_api_clCreateFromGLTexture3D clCreateFromGLTexture3D;
|
||||
cl_api_clCreateFromGLRenderbuffer clCreateFromGLRenderbuffer;
|
||||
cl_api_clGetGLObjectInfo clGetGLObjectInfo;
|
||||
cl_api_clGetGLTextureInfo clGetGLTextureInfo;
|
||||
cl_api_clEnqueueAcquireGLObjects clEnqueueAcquireGLObjects;
|
||||
cl_api_clEnqueueReleaseGLObjects clEnqueueReleaseGLObjects;
|
||||
cl_api_clGetGLContextInfoKHR clGetGLContextInfoKHR;
|
||||
/* OpenCL 1.0 */
|
||||
cl_api_clGetPlatformIDs clGetPlatformIDs;
|
||||
cl_api_clGetPlatformInfo clGetPlatformInfo;
|
||||
cl_api_clGetDeviceIDs clGetDeviceIDs;
|
||||
cl_api_clGetDeviceInfo clGetDeviceInfo;
|
||||
cl_api_clCreateContext clCreateContext;
|
||||
cl_api_clCreateContextFromType clCreateContextFromType;
|
||||
cl_api_clRetainContext clRetainContext;
|
||||
cl_api_clReleaseContext clReleaseContext;
|
||||
cl_api_clGetContextInfo clGetContextInfo;
|
||||
cl_api_clCreateCommandQueue clCreateCommandQueue;
|
||||
cl_api_clRetainCommandQueue clRetainCommandQueue;
|
||||
cl_api_clReleaseCommandQueue clReleaseCommandQueue;
|
||||
cl_api_clGetCommandQueueInfo clGetCommandQueueInfo;
|
||||
cl_api_clSetCommandQueueProperty clSetCommandQueueProperty;
|
||||
cl_api_clCreateBuffer clCreateBuffer;
|
||||
cl_api_clCreateImage2D clCreateImage2D;
|
||||
cl_api_clCreateImage3D clCreateImage3D;
|
||||
cl_api_clRetainMemObject clRetainMemObject;
|
||||
cl_api_clReleaseMemObject clReleaseMemObject;
|
||||
cl_api_clGetSupportedImageFormats clGetSupportedImageFormats;
|
||||
cl_api_clGetMemObjectInfo clGetMemObjectInfo;
|
||||
cl_api_clGetImageInfo clGetImageInfo;
|
||||
cl_api_clCreateSampler clCreateSampler;
|
||||
cl_api_clRetainSampler clRetainSampler;
|
||||
cl_api_clReleaseSampler clReleaseSampler;
|
||||
cl_api_clGetSamplerInfo clGetSamplerInfo;
|
||||
cl_api_clCreateProgramWithSource clCreateProgramWithSource;
|
||||
cl_api_clCreateProgramWithBinary clCreateProgramWithBinary;
|
||||
cl_api_clRetainProgram clRetainProgram;
|
||||
cl_api_clReleaseProgram clReleaseProgram;
|
||||
cl_api_clBuildProgram clBuildProgram;
|
||||
cl_api_clUnloadCompiler clUnloadCompiler;
|
||||
cl_api_clGetProgramInfo clGetProgramInfo;
|
||||
cl_api_clGetProgramBuildInfo clGetProgramBuildInfo;
|
||||
cl_api_clCreateKernel clCreateKernel;
|
||||
cl_api_clCreateKernelsInProgram clCreateKernelsInProgram;
|
||||
cl_api_clRetainKernel clRetainKernel;
|
||||
cl_api_clReleaseKernel clReleaseKernel;
|
||||
cl_api_clSetKernelArg clSetKernelArg;
|
||||
cl_api_clGetKernelInfo clGetKernelInfo;
|
||||
cl_api_clGetKernelWorkGroupInfo clGetKernelWorkGroupInfo;
|
||||
cl_api_clWaitForEvents clWaitForEvents;
|
||||
cl_api_clGetEventInfo clGetEventInfo;
|
||||
cl_api_clRetainEvent clRetainEvent;
|
||||
cl_api_clReleaseEvent clReleaseEvent;
|
||||
cl_api_clGetEventProfilingInfo clGetEventProfilingInfo;
|
||||
cl_api_clFlush clFlush;
|
||||
cl_api_clFinish clFinish;
|
||||
cl_api_clEnqueueReadBuffer clEnqueueReadBuffer;
|
||||
cl_api_clEnqueueWriteBuffer clEnqueueWriteBuffer;
|
||||
cl_api_clEnqueueCopyBuffer clEnqueueCopyBuffer;
|
||||
cl_api_clEnqueueReadImage clEnqueueReadImage;
|
||||
cl_api_clEnqueueWriteImage clEnqueueWriteImage;
|
||||
cl_api_clEnqueueCopyImage clEnqueueCopyImage;
|
||||
cl_api_clEnqueueCopyImageToBuffer clEnqueueCopyImageToBuffer;
|
||||
cl_api_clEnqueueCopyBufferToImage clEnqueueCopyBufferToImage;
|
||||
cl_api_clEnqueueMapBuffer clEnqueueMapBuffer;
|
||||
cl_api_clEnqueueMapImage clEnqueueMapImage;
|
||||
cl_api_clEnqueueUnmapMemObject clEnqueueUnmapMemObject;
|
||||
cl_api_clEnqueueNDRangeKernel clEnqueueNDRangeKernel;
|
||||
cl_api_clEnqueueTask clEnqueueTask;
|
||||
cl_api_clEnqueueNativeKernel clEnqueueNativeKernel;
|
||||
cl_api_clEnqueueMarker clEnqueueMarker;
|
||||
cl_api_clEnqueueWaitForEvents clEnqueueWaitForEvents;
|
||||
cl_api_clEnqueueBarrier clEnqueueBarrier;
|
||||
cl_api_clGetExtensionFunctionAddress clGetExtensionFunctionAddress;
|
||||
cl_api_clCreateFromGLBuffer clCreateFromGLBuffer;
|
||||
cl_api_clCreateFromGLTexture2D clCreateFromGLTexture2D;
|
||||
cl_api_clCreateFromGLTexture3D clCreateFromGLTexture3D;
|
||||
cl_api_clCreateFromGLRenderbuffer clCreateFromGLRenderbuffer;
|
||||
cl_api_clGetGLObjectInfo clGetGLObjectInfo;
|
||||
cl_api_clGetGLTextureInfo clGetGLTextureInfo;
|
||||
cl_api_clEnqueueAcquireGLObjects clEnqueueAcquireGLObjects;
|
||||
cl_api_clEnqueueReleaseGLObjects clEnqueueReleaseGLObjects;
|
||||
cl_api_clGetGLContextInfoKHR clGetGLContextInfoKHR;
|
||||
|
||||
/* cl_khr_d3d10_sharing */
|
||||
cl_api_clGetDeviceIDsFromD3D10KHR clGetDeviceIDsFromD3D10KHR;
|
||||
cl_api_clCreateFromD3D10BufferKHR clCreateFromD3D10BufferKHR;
|
||||
cl_api_clCreateFromD3D10Texture2DKHR clCreateFromD3D10Texture2DKHR;
|
||||
cl_api_clCreateFromD3D10Texture3DKHR clCreateFromD3D10Texture3DKHR;
|
||||
cl_api_clEnqueueAcquireD3D10ObjectsKHR clEnqueueAcquireD3D10ObjectsKHR;
|
||||
cl_api_clEnqueueReleaseD3D10ObjectsKHR clEnqueueReleaseD3D10ObjectsKHR;
|
||||
/* cl_khr_d3d10_sharing */
|
||||
cl_api_clGetDeviceIDsFromD3D10KHR clGetDeviceIDsFromD3D10KHR;
|
||||
cl_api_clCreateFromD3D10BufferKHR clCreateFromD3D10BufferKHR;
|
||||
cl_api_clCreateFromD3D10Texture2DKHR clCreateFromD3D10Texture2DKHR;
|
||||
cl_api_clCreateFromD3D10Texture3DKHR clCreateFromD3D10Texture3DKHR;
|
||||
cl_api_clEnqueueAcquireD3D10ObjectsKHR clEnqueueAcquireD3D10ObjectsKHR;
|
||||
cl_api_clEnqueueReleaseD3D10ObjectsKHR clEnqueueReleaseD3D10ObjectsKHR;
|
||||
|
||||
/* OpenCL 1.1 */
|
||||
cl_api_clSetEventCallback clSetEventCallback;
|
||||
cl_api_clCreateSubBuffer clCreateSubBuffer;
|
||||
cl_api_clSetMemObjectDestructorCallback clSetMemObjectDestructorCallback;
|
||||
cl_api_clCreateUserEvent clCreateUserEvent;
|
||||
cl_api_clSetUserEventStatus clSetUserEventStatus;
|
||||
cl_api_clEnqueueReadBufferRect clEnqueueReadBufferRect;
|
||||
cl_api_clEnqueueWriteBufferRect clEnqueueWriteBufferRect;
|
||||
cl_api_clEnqueueCopyBufferRect clEnqueueCopyBufferRect;
|
||||
/* OpenCL 1.1 */
|
||||
cl_api_clSetEventCallback clSetEventCallback;
|
||||
cl_api_clCreateSubBuffer clCreateSubBuffer;
|
||||
cl_api_clSetMemObjectDestructorCallback clSetMemObjectDestructorCallback;
|
||||
cl_api_clCreateUserEvent clCreateUserEvent;
|
||||
cl_api_clSetUserEventStatus clSetUserEventStatus;
|
||||
cl_api_clEnqueueReadBufferRect clEnqueueReadBufferRect;
|
||||
cl_api_clEnqueueWriteBufferRect clEnqueueWriteBufferRect;
|
||||
cl_api_clEnqueueCopyBufferRect clEnqueueCopyBufferRect;
|
||||
|
||||
/* cl_ext_device_fission */
|
||||
cl_api_clCreateSubDevicesEXT clCreateSubDevicesEXT;
|
||||
cl_api_clRetainDeviceEXT clRetainDeviceEXT;
|
||||
cl_api_clReleaseDeviceEXT clReleaseDeviceEXT;
|
||||
/* cl_ext_device_fission */
|
||||
cl_api_clCreateSubDevicesEXT clCreateSubDevicesEXT;
|
||||
cl_api_clRetainDeviceEXT clRetainDeviceEXT;
|
||||
cl_api_clReleaseDeviceEXT clReleaseDeviceEXT;
|
||||
|
||||
/* cl_khr_gl_event */
|
||||
cl_api_clCreateEventFromGLsyncKHR clCreateEventFromGLsyncKHR;
|
||||
/* cl_khr_gl_event */
|
||||
cl_api_clCreateEventFromGLsyncKHR clCreateEventFromGLsyncKHR;
|
||||
|
||||
/* OpenCL 1.2 */
|
||||
cl_api_clCreateSubDevices clCreateSubDevices;
|
||||
cl_api_clRetainDevice clRetainDevice;
|
||||
cl_api_clReleaseDevice clReleaseDevice;
|
||||
cl_api_clCreateImage clCreateImage;
|
||||
cl_api_clCreateProgramWithBuiltInKernels clCreateProgramWithBuiltInKernels;
|
||||
cl_api_clCompileProgram clCompileProgram;
|
||||
cl_api_clLinkProgram clLinkProgram;
|
||||
cl_api_clUnloadPlatformCompiler clUnloadPlatformCompiler;
|
||||
cl_api_clGetKernelArgInfo clGetKernelArgInfo;
|
||||
cl_api_clEnqueueFillBuffer clEnqueueFillBuffer;
|
||||
cl_api_clEnqueueFillImage clEnqueueFillImage;
|
||||
cl_api_clEnqueueMigrateMemObjects clEnqueueMigrateMemObjects;
|
||||
cl_api_clEnqueueMarkerWithWaitList clEnqueueMarkerWithWaitList;
|
||||
cl_api_clEnqueueBarrierWithWaitList clEnqueueBarrierWithWaitList;
|
||||
cl_api_clGetExtensionFunctionAddressForPlatform
|
||||
clGetExtensionFunctionAddressForPlatform;
|
||||
cl_api_clCreateFromGLTexture clCreateFromGLTexture;
|
||||
/* OpenCL 1.2 */
|
||||
cl_api_clCreateSubDevices clCreateSubDevices;
|
||||
cl_api_clRetainDevice clRetainDevice;
|
||||
cl_api_clReleaseDevice clReleaseDevice;
|
||||
cl_api_clCreateImage clCreateImage;
|
||||
cl_api_clCreateProgramWithBuiltInKernels clCreateProgramWithBuiltInKernels;
|
||||
cl_api_clCompileProgram clCompileProgram;
|
||||
cl_api_clLinkProgram clLinkProgram;
|
||||
cl_api_clUnloadPlatformCompiler clUnloadPlatformCompiler;
|
||||
cl_api_clGetKernelArgInfo clGetKernelArgInfo;
|
||||
cl_api_clEnqueueFillBuffer clEnqueueFillBuffer;
|
||||
cl_api_clEnqueueFillImage clEnqueueFillImage;
|
||||
cl_api_clEnqueueMigrateMemObjects clEnqueueMigrateMemObjects;
|
||||
cl_api_clEnqueueMarkerWithWaitList clEnqueueMarkerWithWaitList;
|
||||
cl_api_clEnqueueBarrierWithWaitList clEnqueueBarrierWithWaitList;
|
||||
cl_api_clGetExtensionFunctionAddressForPlatform
|
||||
clGetExtensionFunctionAddressForPlatform;
|
||||
cl_api_clCreateFromGLTexture clCreateFromGLTexture;
|
||||
|
||||
/* cl_khr_d3d11_sharing */
|
||||
cl_api_clGetDeviceIDsFromD3D11KHR clGetDeviceIDsFromD3D11KHR;
|
||||
cl_api_clCreateFromD3D11BufferKHR clCreateFromD3D11BufferKHR;
|
||||
cl_api_clCreateFromD3D11Texture2DKHR clCreateFromD3D11Texture2DKHR;
|
||||
cl_api_clCreateFromD3D11Texture3DKHR clCreateFromD3D11Texture3DKHR;
|
||||
cl_api_clCreateFromDX9MediaSurfaceKHR clCreateFromDX9MediaSurfaceKHR;
|
||||
cl_api_clEnqueueAcquireD3D11ObjectsKHR clEnqueueAcquireD3D11ObjectsKHR;
|
||||
cl_api_clEnqueueReleaseD3D11ObjectsKHR clEnqueueReleaseD3D11ObjectsKHR;
|
||||
/* cl_khr_d3d11_sharing */
|
||||
cl_api_clGetDeviceIDsFromD3D11KHR clGetDeviceIDsFromD3D11KHR;
|
||||
cl_api_clCreateFromD3D11BufferKHR clCreateFromD3D11BufferKHR;
|
||||
cl_api_clCreateFromD3D11Texture2DKHR clCreateFromD3D11Texture2DKHR;
|
||||
cl_api_clCreateFromD3D11Texture3DKHR clCreateFromD3D11Texture3DKHR;
|
||||
cl_api_clCreateFromDX9MediaSurfaceKHR clCreateFromDX9MediaSurfaceKHR;
|
||||
cl_api_clEnqueueAcquireD3D11ObjectsKHR clEnqueueAcquireD3D11ObjectsKHR;
|
||||
cl_api_clEnqueueReleaseD3D11ObjectsKHR clEnqueueReleaseD3D11ObjectsKHR;
|
||||
|
||||
/* cl_khr_dx9_media_sharing */
|
||||
cl_api_clGetDeviceIDsFromDX9MediaAdapterKHR
|
||||
clGetDeviceIDsFromDX9MediaAdapterKHR;
|
||||
cl_api_clEnqueueAcquireDX9MediaSurfacesKHR
|
||||
clEnqueueAcquireDX9MediaSurfacesKHR;
|
||||
cl_api_clEnqueueReleaseDX9MediaSurfacesKHR
|
||||
clEnqueueReleaseDX9MediaSurfacesKHR;
|
||||
/* cl_khr_dx9_media_sharing */
|
||||
cl_api_clGetDeviceIDsFromDX9MediaAdapterKHR
|
||||
clGetDeviceIDsFromDX9MediaAdapterKHR;
|
||||
cl_api_clEnqueueAcquireDX9MediaSurfacesKHR
|
||||
clEnqueueAcquireDX9MediaSurfacesKHR;
|
||||
cl_api_clEnqueueReleaseDX9MediaSurfacesKHR
|
||||
clEnqueueReleaseDX9MediaSurfacesKHR;
|
||||
|
||||
/* cl_khr_egl_image */
|
||||
cl_api_clCreateFromEGLImageKHR clCreateFromEGLImageKHR;
|
||||
cl_api_clEnqueueAcquireEGLObjectsKHR clEnqueueAcquireEGLObjectsKHR;
|
||||
cl_api_clEnqueueReleaseEGLObjectsKHR clEnqueueReleaseEGLObjectsKHR;
|
||||
/* cl_khr_egl_image */
|
||||
cl_api_clCreateFromEGLImageKHR clCreateFromEGLImageKHR;
|
||||
cl_api_clEnqueueAcquireEGLObjectsKHR clEnqueueAcquireEGLObjectsKHR;
|
||||
cl_api_clEnqueueReleaseEGLObjectsKHR clEnqueueReleaseEGLObjectsKHR;
|
||||
|
||||
/* cl_khr_egl_event */
|
||||
cl_api_clCreateEventFromEGLSyncKHR clCreateEventFromEGLSyncKHR;
|
||||
/* cl_khr_egl_event */
|
||||
cl_api_clCreateEventFromEGLSyncKHR clCreateEventFromEGLSyncKHR;
|
||||
|
||||
/* OpenCL 2.0 */
|
||||
cl_api_clCreateCommandQueueWithProperties clCreateCommandQueueWithProperties;
|
||||
cl_api_clCreatePipe clCreatePipe;
|
||||
cl_api_clGetPipeInfo clGetPipeInfo;
|
||||
cl_api_clSVMAlloc clSVMAlloc;
|
||||
cl_api_clSVMFree clSVMFree;
|
||||
cl_api_clEnqueueSVMFree clEnqueueSVMFree;
|
||||
cl_api_clEnqueueSVMMemcpy clEnqueueSVMMemcpy;
|
||||
cl_api_clEnqueueSVMMemFill clEnqueueSVMMemFill;
|
||||
cl_api_clEnqueueSVMMap clEnqueueSVMMap;
|
||||
cl_api_clEnqueueSVMUnmap clEnqueueSVMUnmap;
|
||||
cl_api_clCreateSamplerWithProperties clCreateSamplerWithProperties;
|
||||
cl_api_clSetKernelArgSVMPointer clSetKernelArgSVMPointer;
|
||||
cl_api_clSetKernelExecInfo clSetKernelExecInfo;
|
||||
/* OpenCL 2.0 */
|
||||
cl_api_clCreateCommandQueueWithProperties clCreateCommandQueueWithProperties;
|
||||
cl_api_clCreatePipe clCreatePipe;
|
||||
cl_api_clGetPipeInfo clGetPipeInfo;
|
||||
cl_api_clSVMAlloc clSVMAlloc;
|
||||
cl_api_clSVMFree clSVMFree;
|
||||
cl_api_clEnqueueSVMFree clEnqueueSVMFree;
|
||||
cl_api_clEnqueueSVMMemcpy clEnqueueSVMMemcpy;
|
||||
cl_api_clEnqueueSVMMemFill clEnqueueSVMMemFill;
|
||||
cl_api_clEnqueueSVMMap clEnqueueSVMMap;
|
||||
cl_api_clEnqueueSVMUnmap clEnqueueSVMUnmap;
|
||||
cl_api_clCreateSamplerWithProperties clCreateSamplerWithProperties;
|
||||
cl_api_clSetKernelArgSVMPointer clSetKernelArgSVMPointer;
|
||||
cl_api_clSetKernelExecInfo clSetKernelExecInfo;
|
||||
|
||||
/* cl_khr_sub_groups */
|
||||
cl_api_clGetKernelSubGroupInfoKHR clGetKernelSubGroupInfoKHR;
|
||||
/* cl_khr_sub_groups */
|
||||
cl_api_clGetKernelSubGroupInfoKHR clGetKernelSubGroupInfoKHR;
|
||||
|
||||
/* OpenCL 2.1 */
|
||||
cl_api_clCloneKernel clCloneKernel;
|
||||
cl_api_clCreateProgramWithIL clCreateProgramWithIL;
|
||||
cl_api_clEnqueueSVMMigrateMem clEnqueueSVMMigrateMem;
|
||||
cl_api_clGetDeviceAndHostTimer clGetDeviceAndHostTimer;
|
||||
cl_api_clGetHostTimer clGetHostTimer;
|
||||
cl_api_clGetKernelSubGroupInfo clGetKernelSubGroupInfo;
|
||||
cl_api_clSetDefaultDeviceCommandQueue clSetDefaultDeviceCommandQueue;
|
||||
/* OpenCL 2.1 */
|
||||
cl_api_clCloneKernel clCloneKernel;
|
||||
cl_api_clCreateProgramWithIL clCreateProgramWithIL;
|
||||
cl_api_clEnqueueSVMMigrateMem clEnqueueSVMMigrateMem;
|
||||
cl_api_clGetDeviceAndHostTimer clGetDeviceAndHostTimer;
|
||||
cl_api_clGetHostTimer clGetHostTimer;
|
||||
cl_api_clGetKernelSubGroupInfo clGetKernelSubGroupInfo;
|
||||
cl_api_clSetDefaultDeviceCommandQueue clSetDefaultDeviceCommandQueue;
|
||||
|
||||
/* OpenCL 2.2 */
|
||||
cl_api_clSetProgramReleaseCallback clSetProgramReleaseCallback;
|
||||
cl_api_clSetProgramSpecializationConstant clSetProgramSpecializationConstant;
|
||||
/* OpenCL 2.2 */
|
||||
cl_api_clSetProgramReleaseCallback clSetProgramReleaseCallback;
|
||||
cl_api_clSetProgramSpecializationConstant clSetProgramSpecializationConstant;
|
||||
|
||||
/* OpenCL 3.0 */
|
||||
cl_api_clCreateBufferWithProperties clCreateBufferWithProperties;
|
||||
cl_api_clCreateImageWithProperties clCreateImageWithProperties;
|
||||
cl_api_clSetContextDestructorCallback clSetContextDestructorCallback;
|
||||
/* OpenCL 3.0 */
|
||||
cl_api_clCreateBufferWithProperties clCreateBufferWithProperties;
|
||||
cl_api_clCreateImageWithProperties clCreateImageWithProperties;
|
||||
cl_api_clSetContextDestructorCallback clSetContextDestructorCallback;
|
||||
|
||||
} cl_icd_dispatch;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -88,69 +88,69 @@ extern CL_API_ENTRY cl_int CL_API_CALL
|
|||
clGetDeviceIDsFromVA_APIMediaAdapterINTEL(
|
||||
cl_platform_id platform,
|
||||
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_uint num_entries,
|
||||
cl_device_id* devices,
|
||||
cl_uint* num_devices) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
cl_device_id *devices,
|
||||
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_va_api_device_source_intel media_adapter_type,
|
||||
void* media_adapter,
|
||||
void *media_adapter,
|
||||
cl_va_api_device_set_intel media_adapter_set,
|
||||
cl_uint num_entries,
|
||||
cl_device_id* devices,
|
||||
cl_uint* num_devices) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
cl_device_id *devices,
|
||||
cl_uint *num_devices) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
extern CL_API_ENTRY cl_mem CL_API_CALL
|
||||
clCreateFromVA_APIMediaSurfaceINTEL(
|
||||
cl_context context,
|
||||
cl_mem_flags flags,
|
||||
VASurfaceID* surface,
|
||||
VASurfaceID *surface,
|
||||
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_mem_flags flags,
|
||||
VASurfaceID* surface,
|
||||
VASurfaceID *surface,
|
||||
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
|
||||
clEnqueueAcquireVA_APIMediaSurfacesINTEL(
|
||||
cl_command_queue command_queue,
|
||||
cl_uint num_objects,
|
||||
const cl_mem* mem_objects,
|
||||
const cl_mem *mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event* event_wait_list,
|
||||
cl_event* event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
const cl_event *event_wait_list,
|
||||
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_uint num_objects,
|
||||
const cl_mem* mem_objects,
|
||||
const cl_mem *mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event* event_wait_list,
|
||||
cl_event* event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueReleaseVA_APIMediaSurfacesINTEL(
|
||||
cl_command_queue command_queue,
|
||||
cl_uint num_objects,
|
||||
const cl_mem* mem_objects,
|
||||
const cl_mem *mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event* event_wait_list,
|
||||
cl_event* event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
const cl_event *event_wait_list,
|
||||
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_uint num_objects,
|
||||
const cl_mem* mem_objects,
|
||||
const cl_mem *mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event* event_wait_list,
|
||||
cl_event* event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -4,65 +4,62 @@
|
|||
//#if FORCE_HITAG2_FULL == 0
|
||||
|
||||
// return a single bit from a value
|
||||
int bitn (uint64_t x, int bit)
|
||||
{
|
||||
const uint64_t bitmask = (uint64_t)(1) << bit;
|
||||
int bitn(uint64_t x, int 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
|
||||
int fnR (uint64_t x)
|
||||
{
|
||||
// renumbered bits because my state is 0-47, not 1-48
|
||||
return (bitn(x, 1) ^ bitn(x, 2) ^ bitn(x, 5) ^
|
||||
bitn(x, 6) ^ bitn(x, 7) ^ bitn(x, 15) ^
|
||||
bitn(x, 21) ^ bitn(x, 22) ^ bitn(x, 25) ^
|
||||
bitn(x, 29) ^ bitn(x, 40) ^ bitn(x, 41) ^
|
||||
bitn(x, 42) ^ bitn(x, 45) ^ bitn(x, 46) ^ bitn(x, 47));
|
||||
int fnR(uint64_t x) {
|
||||
// renumbered bits because my state is 0-47, not 1-48
|
||||
return (bitn(x, 1) ^ bitn(x, 2) ^ bitn(x, 5) ^
|
||||
bitn(x, 6) ^ bitn(x, 7) ^ bitn(x, 15) ^
|
||||
bitn(x, 21) ^ bitn(x, 22) ^ bitn(x, 25) ^
|
||||
bitn(x, 29) ^ bitn(x, 40) ^ bitn(x, 41) ^
|
||||
bitn(x, 42) ^ bitn(x, 45) ^ bitn(x, 46) ^ bitn(x, 47));
|
||||
}
|
||||
|
||||
// the three filter sub-functions that feed fnf
|
||||
int fa(unsigned int i) {
|
||||
return bitn(0x2C79, (int)i);
|
||||
return bitn(0x2C79, (int)i);
|
||||
}
|
||||
|
||||
int fb(unsigned int i) {
|
||||
return bitn(0x6671, (int)i);
|
||||
return bitn(0x6671, (int)i);
|
||||
}
|
||||
|
||||
// the filter function that generates a bit of output from the prng state
|
||||
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 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 x4 = (unsigned int)((bitn(s, 28) << 0) | (bitn(s, 29) << 1) | (bitn(s, 31) << 2) | (bitn(s, 33) << 3));
|
||||
const unsigned int x5 = (unsigned int)((bitn(s, 34) << 0) | (bitn(s, 43) << 1) | (bitn(s, 44) << 2) | (bitn(s, 46) << 3));
|
||||
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 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 x4 = (unsigned int)((bitn(s, 28) << 0) | (bitn(s, 29) << 1) | (bitn(s, 31) << 2) | (bitn(s, 33) << 3));
|
||||
const unsigned int x5 = (unsigned int)((bitn(s, 34) << 0) | (bitn(s, 43) << 1) | (bitn(s, 44) << 2) | (bitn(s, 46) << 3));
|
||||
|
||||
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) {
|
||||
const uint32_t ht2_function4a = 0x2C79; // 0010 1100 0111 1001
|
||||
const uint32_t ht2_function4b = 0x6671; // 0110 0110 0111 0001
|
||||
const uint32_t ht2_function5c = 0x7907287B; // 0111 1001 0000 0111 0010 1000 0111 1011
|
||||
uint32_t hitag2_crypt(uint64_t x) {
|
||||
const uint32_t ht2_function4a = 0x2C79; // 0010 1100 0111 1001
|
||||
const uint32_t ht2_function4b = 0x6671; // 0110 0110 0111 0001
|
||||
const uint32_t ht2_function5c = 0x7907287B; // 0111 1001 0000 0111 0010 1000 0111 1011
|
||||
|
||||
uint32_t bitindex;
|
||||
uint32_t bitindex;
|
||||
|
||||
bitindex = (ht2_function4a >> pickbits2_2(x, 1, 4)) & 1;
|
||||
bitindex |= ((ht2_function4b << 1) >> pickbits1_1_2(x, 7, 11, 13)) & 0x02;
|
||||
bitindex |= ((ht2_function4b << 2) >> pickbits1x4(x, 16, 20, 22, 25)) & 0x04;
|
||||
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 >> pickbits2_2(x, 1, 4)) & 1;
|
||||
bitindex |= ((ht2_function4b << 1) >> pickbits1_1_2(x, 7, 11, 13)) & 0x02;
|
||||
bitindex |= ((ht2_function4b << 2) >> pickbits1x4(x, 16, 20, 22, 25)) & 0x04;
|
||||
bitindex |= ((ht2_function4b << 3) >> pickbits2_1_1(x, 27, 30, 32)) & 0x08;
|
||||
bitindex |= ((ht2_function4a << 4) >> pickbits1_2_1(x, 33, 42, 45)) & 0x10;
|
||||
|
||||
#if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1
|
||||
printf ("hitag2_crypt bitindex = %02x\n", bitindex);
|
||||
#endif
|
||||
#if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1
|
||||
printf("hitag2_crypt bitindex = %02x\n", bitindex);
|
||||
#endif
|
||||
|
||||
return (ht2_function5c >> bitindex) & 1;
|
||||
return (ht2_function5c >> bitindex) & 1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -77,39 +74,39 @@ uint32_t hitag2_crypt (uint64_t x) {
|
|||
* uint32_t steps - number of bits requested, (capped at 32)
|
||||
*/
|
||||
uint32_t hitag2_nstep(Hitag_State *pstate, uint32_t steps) {
|
||||
uint64_t cur_state = pstate->shiftreg;
|
||||
uint32_t result = 0;
|
||||
uint64_t lfsr = pstate->lfsr;
|
||||
uint64_t cur_state = pstate->shiftreg;
|
||||
uint32_t result = 0;
|
||||
uint64_t lfsr = pstate->lfsr;
|
||||
|
||||
if (steps == 0) return 0;
|
||||
if (steps == 0) return 0;
|
||||
|
||||
do {
|
||||
// update shift registers
|
||||
if (lfsr & 1) {
|
||||
cur_state = (cur_state >> 1) | 0x800000000000;
|
||||
lfsr = (lfsr >> 1) ^ 0xB38083220073;
|
||||
do {
|
||||
// update shift registers
|
||||
if (lfsr & 1) {
|
||||
cur_state = (cur_state >> 1) | 0x800000000000;
|
||||
lfsr = (lfsr >> 1) ^ 0xB38083220073;
|
||||
|
||||
// accumulate next bit of crypto
|
||||
result = (result << 1) | hitag2_crypt(cur_state);
|
||||
} else {
|
||||
cur_state >>= 1;
|
||||
lfsr >>= 1;
|
||||
// accumulate next bit of crypto
|
||||
result = (result << 1) | hitag2_crypt(cur_state);
|
||||
} else {
|
||||
cur_state >>= 1;
|
||||
lfsr >>= 1;
|
||||
|
||||
result = (result << 1) | hitag2_crypt(cur_state);
|
||||
}
|
||||
} while (--steps);
|
||||
result = (result << 1) | hitag2_crypt(cur_state);
|
||||
}
|
||||
} while (--steps);
|
||||
|
||||
#if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1
|
||||
#ifdef _ISOC99_SOURCE
|
||||
printf ("hitag2_nstep cur_state = %012I64x, result %02x\n", cur_state, result);
|
||||
#else
|
||||
printf ("hitag2_nstep cur_state = %012" STR(OFF_FORMAT_X) ", result %02x\n", cur_state, result);
|
||||
#endif
|
||||
#endif // DEBUG_HITAG2
|
||||
#if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1
|
||||
#ifdef _ISOC99_SOURCE
|
||||
printf("hitag2_nstep cur_state = %012I64x, result %02x\n", cur_state, result);
|
||||
#else
|
||||
printf("hitag2_nstep cur_state = %012" STR(OFF_FORMAT_X) ", result %02x\n", cur_state, result);
|
||||
#endif
|
||||
#endif // DEBUG_HITAG2
|
||||
|
||||
pstate->shiftreg = cur_state;
|
||||
pstate->lfsr = lfsr;
|
||||
return result;
|
||||
pstate->shiftreg = cur_state;
|
||||
pstate->lfsr = lfsr;
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -119,140 +116,136 @@ uint32_t hitag2_nstep(Hitag_State *pstate, uint32_t steps) {
|
|||
* uint32_t serialnum - 32 bit tag serial number
|
||||
* 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)
|
||||
{
|
||||
// init state, from serial number and lowest 16 bits of shared key
|
||||
uint64_t cur_state = ((sharedkey & 0xFFFF) << 32) | serialnum;
|
||||
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
|
||||
uint64_t cur_state = ((sharedkey & 0xFFFF) << 32) | serialnum;
|
||||
|
||||
// mix the initialisation vector and highest 32 bits of the shared key
|
||||
initvector ^= (uint32_t) (sharedkey >> 16);
|
||||
// mix the initialisation vector and highest 32 bits of the shared key
|
||||
initvector ^= (uint32_t)(sharedkey >> 16);
|
||||
|
||||
// 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
|
||||
cur_state |= (uint64_t) initvector << 48;
|
||||
initvector >>= 16;
|
||||
// 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
|
||||
cur_state |= (uint64_t) initvector << 48;
|
||||
initvector >>= 16;
|
||||
|
||||
// unrolled loop is faster on PIC32 (MIPS), do 32 times
|
||||
// shift register, then calc new bit
|
||||
cur_state >>= 1;
|
||||
// unrolled loop is faster on PIC32 (MIPS), do 32 times
|
||||
// shift register, then calc new bit
|
||||
cur_state >>= 1;
|
||||
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 16; i++) cur_state = (cur_state >> 1) ^ (uint64_t) hitag2_crypt(cur_state) << 46;
|
||||
for (i = 0; i < 16; i++) cur_state = (cur_state >> 1) ^ (uint64_t) hitag2_crypt(cur_state) << 46;
|
||||
|
||||
// highest 16 bits of IV XOR Shared Key
|
||||
cur_state |= (uint64_t) initvector << 47;
|
||||
// highest 16 bits of IV XOR Shared Key
|
||||
cur_state |= (uint64_t) initvector << 47;
|
||||
|
||||
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;
|
||||
#if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1
|
||||
#ifdef _ISOC99_SOURCE
|
||||
printf ("hitag2_init shiftreg = %012I64x\n", pstate->shiftreg);
|
||||
#else
|
||||
printf ("hitag2_init shiftreg = %012" STR(OFF_FORMAT_X) "\n", pstate->shiftreg);
|
||||
#endif
|
||||
#endif // DEBUG_HITAG2
|
||||
pstate->shiftreg = cur_state;
|
||||
#if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1
|
||||
#ifdef _ISOC99_SOURCE
|
||||
printf("hitag2_init shiftreg = %012I64x\n", pstate->shiftreg);
|
||||
#else
|
||||
printf("hitag2_init shiftreg = %012" STR(OFF_FORMAT_X) "\n", pstate->shiftreg);
|
||||
#endif
|
||||
#endif // DEBUG_HITAG2
|
||||
|
||||
/* naive version for reference, LFSR has 16 taps
|
||||
pstate->lfsr = state ^ (state >> 2) ^ (state >> 3) ^ (state >> 6)
|
||||
^ (state >> 7) ^ (state >> 8) ^ (state >> 16) ^ (state >> 22)
|
||||
^ (state >> 23) ^ (state >> 26) ^ (state >> 30) ^ (state >> 41)
|
||||
^ (state >> 42) ^ (state >> 43) ^ (state >> 46) ^ (state >> 47);
|
||||
*/
|
||||
/* naive version for reference, LFSR has 16 taps
|
||||
pstate->lfsr = state ^ (state >> 2) ^ (state >> 3) ^ (state >> 6)
|
||||
^ (state >> 7) ^ (state >> 8) ^ (state >> 16) ^ (state >> 22)
|
||||
^ (state >> 23) ^ (state >> 26) ^ (state >> 30) ^ (state >> 41)
|
||||
^ (state >> 42) ^ (state >> 43) ^ (state >> 46) ^ (state >> 47);
|
||||
*/
|
||||
|
||||
// optimise with one 64-bit intermediate
|
||||
uint64_t temp = cur_state ^ (cur_state >> 1);
|
||||
// optimise with one 64-bit intermediate
|
||||
uint64_t temp = cur_state ^ (cur_state >> 1);
|
||||
|
||||
pstate->lfsr = cur_state ^ (cur_state >> 6) ^ (cur_state >> 16) ^
|
||||
pstate->lfsr = cur_state ^ (cur_state >> 6) ^ (cur_state >> 16) ^
|
||||
(cur_state >> 26) ^ (cur_state >> 30) ^ (cur_state >> 41) ^
|
||||
(temp >> 2) ^ (temp >> 7) ^ (temp >> 22) ^ (temp >> 42) ^ (temp >> 46);
|
||||
|
||||
#if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1
|
||||
#ifdef _ISOC99_SOURCE
|
||||
printf ("hitag2_init lfsr = %012I64x\n", pstate->lfsr);
|
||||
#else
|
||||
printf ("hitag2_init lfsr = %012" STR(OFF_FORMAT_X) "\n", pstate->lfsr);
|
||||
#endif
|
||||
#endif // DEBUG_HITAG2
|
||||
#if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1
|
||||
#ifdef _ISOC99_SOURCE
|
||||
printf("hitag2_init lfsr = %012I64x\n", pstate->lfsr);
|
||||
#else
|
||||
printf("hitag2_init lfsr = %012" STR(OFF_FORMAT_X) "\n", pstate->lfsr);
|
||||
#endif
|
||||
#endif // DEBUG_HITAG2
|
||||
}
|
||||
|
||||
// try state
|
||||
|
||||
// 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)
|
||||
{
|
||||
#if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1
|
||||
printf ("s : %lu, uid: %u, aR2: %u, nR1: %u, nR2: %u\n", s, uid, aR2, nR1, nR2);
|
||||
fflush (stdout);
|
||||
#endif
|
||||
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
|
||||
printf("s : %lu, uid: %u, aR2: %u, nR1: %u, nR2: %u\n", s, uid, aR2, nR1, nR2);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
Hitag_State hstate;
|
||||
uint64_t keyrev, nR1xk;
|
||||
uint32_t b = 0;
|
||||
Hitag_State hstate;
|
||||
uint64_t keyrev, nR1xk;
|
||||
uint32_t b = 0;
|
||||
|
||||
hstate.shiftreg = s;
|
||||
hstate.shiftreg = s;
|
||||
|
||||
//rollback(&hstate, 2);
|
||||
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));
|
||||
//rollback(&hstate, 2);
|
||||
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
|
||||
printf ("shiftreg : %lu\n", hstate.shiftreg);
|
||||
fflush (stdout);
|
||||
#endif
|
||||
#if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1
|
||||
printf("shiftreg : %lu\n", hstate.shiftreg);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
// recover key
|
||||
keyrev = hstate.shiftreg & 0xffff;
|
||||
nR1xk = (hstate.shiftreg >> 16) & 0xffffffff;
|
||||
// recover key
|
||||
keyrev = hstate.shiftreg & 0xffff;
|
||||
nR1xk = (hstate.shiftreg >> 16) & 0xffffffff;
|
||||
|
||||
#if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1
|
||||
printf ("keyrev: %lu, nR1xk: %lu\n", keyrev, nR1xk);
|
||||
fflush (stdout);
|
||||
#endif
|
||||
#if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1
|
||||
printf("keyrev: %lu, nR1xk: %lu\n", keyrev, nR1xk);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
hstate.shiftreg = ((hstate.shiftreg) << 1) | ((uid >> (31 - i)) & 0x1);
|
||||
b = (b << 1) | (unsigned int) fnf(hstate.shiftreg);
|
||||
}
|
||||
for (int i = 0; i < 32; i++) {
|
||||
hstate.shiftreg = ((hstate.shiftreg) << 1) | ((uid >> (31 - i)) & 0x1);
|
||||
b = (b << 1) | (unsigned int) fnf(hstate.shiftreg);
|
||||
}
|
||||
|
||||
#if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1
|
||||
printf ("shiftreg: %lu\n", hstate.shiftreg);
|
||||
fflush (stdout);
|
||||
#endif
|
||||
#if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1
|
||||
printf("shiftreg: %lu\n", hstate.shiftreg);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
keyrev |= (nR1xk ^ nR1 ^ b) << 16;
|
||||
keyrev |= (nR1xk ^ nR1 ^ b) << 16;
|
||||
|
||||
#if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1
|
||||
printf ("keyrev: %lu\n", keyrev);
|
||||
fflush (stdout);
|
||||
#endif
|
||||
#if defined(DEBUG_HITAG2) && DEBUG_HITAG2 == 1
|
||||
printf("keyrev: %lu\n", keyrev);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
// test key
|
||||
hitag2_init (&hstate, keyrev, uid, nR2);
|
||||
if ((aR2 ^ hitag2_nstep (&hstate, 32)) == 0xffffffff)
|
||||
{
|
||||
*key = rev64 (keyrev);
|
||||
// test key
|
||||
hitag2_init(&hstate, keyrev, uid, nR2);
|
||||
if ((aR2 ^ hitag2_nstep(&hstate, 32)) == 0xffffffff) {
|
||||
*key = rev64(keyrev);
|
||||
|
||||
#if DEBUGME >= 2
|
||||
#if ENABLE_EMOJ == 1
|
||||
printf ("\nKey found ╭☞ ");
|
||||
#else
|
||||
printf ("\nKey found: ");
|
||||
#endif
|
||||
for (int i = 0; i < 6; i++) {
|
||||
printf ("%02X", (uint8_t)(*key & 0xff));
|
||||
*key = *key >> 8;
|
||||
}
|
||||
printf ("\n");
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
#if DEBUGME >= 2
|
||||
#if ENABLE_EMOJ == 1
|
||||
printf("\nKey found ╭☞ ");
|
||||
#else
|
||||
printf("\nKey found: ");
|
||||
#endif
|
||||
for (int i = 0; i < 6; i++) {
|
||||
printf("%02X", (uint8_t)(*key & 0xff));
|
||||
*key = *key >> 8;
|
||||
}
|
||||
printf("\n");
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
//#endif // FORCE_HITAG2_FULL = 0
|
||||
|
|
|
@ -27,17 +27,16 @@
|
|||
#define rev32(X) (rev16(X) + (rev16(X >> 16) << 16))
|
||||
#define rev64(X) (rev32(X) + (rev32(X >> 32) << 32))
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint64_t shiftreg; // naive shift register, required for nonlinear fn input
|
||||
uint64_t lfsr; // fast lfsr, used to make software faster
|
||||
typedef struct {
|
||||
uint64_t shiftreg; // naive shift register, required for nonlinear fn input
|
||||
uint64_t lfsr; // fast lfsr, used to make software faster
|
||||
} Hitag_State;
|
||||
|
||||
// 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
|
||||
int fnR (uint64_t x);
|
||||
int fnR(uint64_t x);
|
||||
|
||||
// the three filter sub-functions that feed fnf
|
||||
int fa(unsigned int i);
|
||||
|
@ -45,7 +44,7 @@ int fa(unsigned int i);
|
|||
int fb(unsigned int i);
|
||||
|
||||
// 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
|
||||
#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 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.
|
||||
|
@ -76,9 +75,9 @@ uint32_t hitag2_nstep(Hitag_State *pstate, uint32_t steps);
|
|||
* uint32_t serialnum - 32 bit tag serial number
|
||||
* 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
|
||||
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
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -24,140 +24,128 @@ License: GNU General Public License v3 or any later version (see LICENSE.txt)
|
|||
|
||||
#include "opencl.h"
|
||||
|
||||
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
|
||||
if (allow_type != CL_DEVICE_TYPE_ALL)
|
||||
{
|
||||
if (cur_type != allow_type) return false;
|
||||
}
|
||||
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
|
||||
if (allow_type != CL_DEVICE_TYPE_ALL) {
|
||||
if (cur_type != allow_type) return false;
|
||||
}
|
||||
|
||||
if (sel[0] == 0xff) return true; // all
|
||||
else
|
||||
{
|
||||
for (unsigned int i = 0; i < cnt; i++)
|
||||
{
|
||||
if (sel[i] == (id+1)) return true;
|
||||
}
|
||||
}
|
||||
if (sel[0] == 0xff) return true; // all
|
||||
else {
|
||||
for (unsigned int i = 0; i < cnt; i++) {
|
||||
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 err = 0;
|
||||
int runKernel(opencl_ctx_t *ctx, uint32_t cand_base, uint64_t *matches, uint32_t *matches_found, size_t id) {
|
||||
int err = 0;
|
||||
|
||||
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 global_ws[3] = { ctx->global_ws[id], GLOBAL_WS_1, GLOBAL_WS_2 };
|
||||
size_t local_ws[3] = { ctx->local_ws[id], 1, 1 };
|
||||
|
||||
if (ctx->profiling)
|
||||
{
|
||||
printf ("[%zu] global_ws %zu, ctx->local_ws: %zu\n", id, global_ws[0], local_ws[0]);
|
||||
fflush (stdout);
|
||||
}
|
||||
if (ctx->profiling) {
|
||||
printf("[%zu] global_ws %zu, ctx->local_ws: %zu\n", id, global_ws[0], local_ws[0]);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
*matches_found = 0;
|
||||
*matches_found = 0;
|
||||
|
||||
// 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);
|
||||
if (err != CL_SUCCESS) {
|
||||
printf ("[%zu] Error: clEnqueueWriteBuffer (matches_found) failed (%d)\n", id, err);
|
||||
return -1;
|
||||
}
|
||||
// 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);
|
||||
if (err != CL_SUCCESS) {
|
||||
printf("[%zu] Error: clEnqueueWriteBuffer (matches_found) failed (%d)\n", id, err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Set the arguments to our compute kernel
|
||||
err = clSetKernelArg (ctx->kernels[id], 0, sizeof(uint32_t), &cand_base);
|
||||
err |= clSetKernelArg (ctx->kernels[id], 4, sizeof(cl_mem), &ctx->matches_found[id]);
|
||||
// Set the arguments to our compute kernel
|
||||
err = clSetKernelArg(ctx->kernels[id], 0, sizeof(uint32_t), &cand_base);
|
||||
err |= clSetKernelArg(ctx->kernels[id], 4, sizeof(cl_mem), &ctx->matches_found[id]);
|
||||
|
||||
if (err != CL_SUCCESS) {
|
||||
printf ("[%zu] Error: clSetKernelArg (cand_base|ctx->matches_found) failed (%d)\n", id, err);
|
||||
return -1;
|
||||
}
|
||||
if (err != CL_SUCCESS) {
|
||||
printf("[%zu] Error: clSetKernelArg (cand_base|ctx->matches_found) failed (%d)\n", id, err);
|
||||
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);
|
||||
if (err != CL_SUCCESS) {
|
||||
printf ("[%zu] Error: clEnqueueNDRangeKernel() failed (%d)\n", id, err);
|
||||
return -1;
|
||||
}
|
||||
err = clEnqueueNDRangeKernel(ctx->commands[id], ctx->kernels[id], 2, NULL, global_ws, local_ws, 0, NULL, &event);
|
||||
if (err != CL_SUCCESS) {
|
||||
printf("[%zu] Error: clEnqueueNDRangeKernel() failed (%d)\n", id, err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// todo, check if is possible remove
|
||||
err = clFlush (ctx->commands[id]);
|
||||
if (err != CL_SUCCESS) {
|
||||
printf ("[%zu] Error: clFlush() failed (%d)\n", id, err);
|
||||
return -1;
|
||||
}
|
||||
// todo, check if is possible remove
|
||||
err = clFlush(ctx->commands[id]);
|
||||
if (err != CL_SUCCESS) {
|
||||
printf("[%zu] Error: clFlush() failed (%d)\n", id, err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ctx->profiling)
|
||||
{
|
||||
err = clWaitForEvents (1, &event);
|
||||
if (err != CL_SUCCESS) {
|
||||
printf ("[%zu] Error: clWaitForEvents() failed (%d)\n", id, err);
|
||||
return -1;
|
||||
}
|
||||
if (ctx->profiling) {
|
||||
err = clWaitForEvents(1, &event);
|
||||
if (err != CL_SUCCESS) {
|
||||
printf("[%zu] Error: clWaitForEvents() failed (%d)\n", id, err);
|
||||
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_END, sizeof (cl_ulong), &gpu_t_end, NULL);
|
||||
if (err != CL_SUCCESS) {
|
||||
printf ("[%zu] Error: clGetEventOPENCL_PROFILINGInfo() failed (%d)\n", id, err);
|
||||
return -1;
|
||||
}
|
||||
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);
|
||||
if (err != CL_SUCCESS) {
|
||||
printf("[%zu] Error: clGetEventOPENCL_PROFILINGInfo() failed (%d)\n", id, err);
|
||||
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);
|
||||
fflush (stdout);
|
||||
}
|
||||
printf("[%zu] kernel exec time (ms): %.2f]\n", id, time_ms);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
err = clReleaseEvent (event);
|
||||
if (err != CL_SUCCESS) {
|
||||
printf ("[%zu] Error: clReleaseEvent() failed (%d)\n", id, err);
|
||||
return -1;
|
||||
}
|
||||
err = clReleaseEvent(event);
|
||||
if (err != CL_SUCCESS) {
|
||||
printf("[%zu] Error: clReleaseEvent() failed (%d)\n", id, err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Wait for the command commands to get serviced before reading back results
|
||||
// todo, check if is possible remove, because of blocking clEnqueueReadBuffer (CL_TRUE)
|
||||
err = clFinish (ctx->commands[id]);
|
||||
if (err != CL_SUCCESS) {
|
||||
printf ("[%zu] Error: clFinish() failed (%d)\n", id, err);
|
||||
return -1;
|
||||
}
|
||||
// Wait for the command commands to get serviced before reading back results
|
||||
// todo, check if is possible remove, because of blocking clEnqueueReadBuffer (CL_TRUE)
|
||||
err = clFinish(ctx->commands[id]);
|
||||
if (err != CL_SUCCESS) {
|
||||
printf("[%zu] Error: clFinish() failed (%d)\n", id, err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// 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);
|
||||
if (err != CL_SUCCESS) {
|
||||
printf ("[%zu] Error: clEnqueueReadBuffer(matches_found) failed (%d)\n", id, err);
|
||||
return -1;
|
||||
}
|
||||
// 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);
|
||||
if (err != CL_SUCCESS) {
|
||||
printf("[%zu] Error: clEnqueueReadBuffer(matches_found) failed (%d)\n", id, err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (matches_found[0] > 0)
|
||||
{
|
||||
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] > (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]);
|
||||
}
|
||||
}
|
||||
if (matches_found[0] > 0) {
|
||||
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] > (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);
|
||||
if (err != CL_SUCCESS) {
|
||||
printf ("[%zu] Error: clEnqueueReadBuffer(matches) failed (%d)\n", id, err);
|
||||
return -1;
|
||||
}
|
||||
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) {
|
||||
printf("[%zu] Error: clEnqueueReadBuffer(matches) failed (%d)\n", id, err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// key found
|
||||
return 1;
|
||||
}
|
||||
// key found
|
||||
return 1;
|
||||
}
|
||||
|
||||
// nada
|
||||
return 0;
|
||||
// nada
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -43,87 +43,84 @@ License: GNU General Public License v3 or any later version (see LICENSE.txt)
|
|||
#define MAX_OPENCL_DEVICES 16
|
||||
|
||||
// defines structures
|
||||
typedef struct compute_device_ctx
|
||||
{
|
||||
char name[0xff];
|
||||
char vendor[0x40];
|
||||
char version[0x40];
|
||||
char driver_version[0x40];
|
||||
typedef struct compute_device_ctx {
|
||||
char name[0xff];
|
||||
char vendor[0x40];
|
||||
char version[0x40];
|
||||
char driver_version[0x40];
|
||||
|
||||
bool is_gpu, is_apple_gpu, is_nv;
|
||||
bool have_lop3, have_local_memory;
|
||||
bool warning, unsupported;
|
||||
bool is_gpu, is_apple_gpu, is_nv;
|
||||
bool have_lop3, have_local_memory;
|
||||
bool warning, unsupported;
|
||||
|
||||
bool selected;
|
||||
bool enabled;
|
||||
bool selected;
|
||||
bool enabled;
|
||||
|
||||
unsigned char pad1[4];
|
||||
unsigned int sm_maj;
|
||||
unsigned int sm_min;
|
||||
unsigned int compute_units;
|
||||
unsigned char pad1[4];
|
||||
unsigned int sm_maj;
|
||||
unsigned int sm_min;
|
||||
unsigned int compute_units;
|
||||
|
||||
cl_device_id device_id;
|
||||
cl_platform_id platform_id;
|
||||
cl_device_id device_id;
|
||||
cl_platform_id platform_id;
|
||||
|
||||
} compute_device_ctx_t;
|
||||
|
||||
typedef struct compute_platform_ctx
|
||||
{
|
||||
unsigned int device_cnt;
|
||||
unsigned int compute_units_max;
|
||||
typedef struct compute_platform_ctx {
|
||||
unsigned int device_cnt;
|
||||
unsigned int compute_units_max;
|
||||
|
||||
bool is_nv, is_apple, is_intel;
|
||||
bool warning;
|
||||
bool selected;
|
||||
bool is_nv, is_apple, is_intel;
|
||||
bool warning;
|
||||
bool selected;
|
||||
|
||||
unsigned char pad1[3];
|
||||
compute_device_ctx_t device[0x10];
|
||||
unsigned char pad1[3];
|
||||
compute_device_ctx_t device[0x10];
|
||||
|
||||
char name[0xff];
|
||||
char vendor[0x40];
|
||||
char version[0x40];
|
||||
char name[0xff];
|
||||
char vendor[0x40];
|
||||
char version[0x40];
|
||||
|
||||
unsigned char pad2[1];
|
||||
cl_platform_id platform_id;
|
||||
cl_context context;
|
||||
cl_program program;
|
||||
unsigned char pad2[1];
|
||||
cl_platform_id platform_id;
|
||||
cl_context context;
|
||||
cl_program program;
|
||||
|
||||
} compute_platform_ctx_t;
|
||||
|
||||
typedef struct opencl_ctx
|
||||
{
|
||||
char *kernelSource[1];
|
||||
size_t kernelSource_len;
|
||||
typedef struct opencl_ctx {
|
||||
char *kernelSource[1];
|
||||
size_t kernelSource_len;
|
||||
|
||||
size_t *global_ws;
|
||||
size_t *local_ws;
|
||||
int *profiles;
|
||||
size_t *global_ws;
|
||||
size_t *local_ws;
|
||||
int *profiles;
|
||||
|
||||
cl_device_id *device_ids; // compute device id's array
|
||||
cl_context *contexts; // compute contexts
|
||||
cl_command_queue *commands; // compute command queue (for each device)
|
||||
cl_program *programs; // compute program's
|
||||
cl_kernel *kernels; // compute kernel's
|
||||
cl_device_id *device_ids; // compute device id's array
|
||||
cl_context *contexts; // compute contexts
|
||||
cl_command_queue *commands; // compute command queue (for each device)
|
||||
cl_program *programs; // compute program's
|
||||
cl_kernel *kernels; // compute kernel's
|
||||
|
||||
// cl_mem cand_base; // device memory used for the candidate base
|
||||
cl_mem *keystreams; // device memory used for the keystream array
|
||||
cl_mem *candidates; // device memory used for the candidates array
|
||||
cl_mem *matches; // device memory used for the matches array
|
||||
cl_mem *matches_found; // device memory used for the matches_found array
|
||||
cl_mem *checks; // device memory used for uid, aR2, nR1, nR2
|
||||
cl_mem *keystreams; // device memory used for the keystream array
|
||||
cl_mem *candidates; // device memory used for the candidates array
|
||||
cl_mem *matches; // device memory used for the matches array
|
||||
cl_mem *matches_found; // device memory used for the matches_found array
|
||||
cl_mem *checks; // device memory used for uid, aR2, nR1, nR2
|
||||
|
||||
wu_queue_ctx_t queue_ctx;
|
||||
bool profiling;
|
||||
unsigned char pad2[1];
|
||||
short thread_sched_type;
|
||||
bool force_hitag2_opencl;
|
||||
wu_queue_ctx_t queue_ctx;
|
||||
bool profiling;
|
||||
unsigned char pad2[1];
|
||||
short thread_sched_type;
|
||||
bool force_hitag2_opencl;
|
||||
|
||||
unsigned char pad3[3];
|
||||
unsigned char pad3[3];
|
||||
|
||||
} 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
|
||||
|
|
|
@ -25,527 +25,493 @@ License: GNU General Public License v3 or any later version (see LICENSE.txt)
|
|||
#include "queue.h"
|
||||
|
||||
#if TEST_UNIT == 1
|
||||
int wu_queue_print (wu_queue_ctx_t *ctx)
|
||||
{
|
||||
wu_queue_item_t *ptr = 0; //NULL;
|
||||
size_t sum = 0;
|
||||
int ret = -1;
|
||||
int wu_queue_print(wu_queue_ctx_t *ctx) {
|
||||
wu_queue_item_t *ptr = 0; //NULL;
|
||||
size_t sum = 0;
|
||||
int ret = -1;
|
||||
|
||||
if (!ctx) return -1;
|
||||
if (!ctx->init) return ERROR_CTX_IS_NOT_INIT;
|
||||
if (!ctx) return -1;
|
||||
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)
|
||||
{
|
||||
pthread_mutex_unlock (&ctx->queue_mutex);
|
||||
return ret;
|
||||
}
|
||||
if ((ret = wu_queue_done(ctx)) != 0) {
|
||||
pthread_mutex_unlock(&ctx->queue_mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
switch (ctx->queue_type)
|
||||
{
|
||||
case QUEUE_TYPE_FORWARD:
|
||||
ptr = ctx->queue_head;
|
||||
printf ("> show queue contents in FORWARD mode, from head\n");
|
||||
break;
|
||||
case QUEUE_TYPE_REVERSE:
|
||||
ptr = ctx->queue_tail;
|
||||
printf ("> show queue contents in REVERSE mode, from tail\n");
|
||||
break;
|
||||
case QUEUE_TYPE_RANDOM:
|
||||
ptr = ctx->queue_head;
|
||||
printf ("> show queue contents in RANDOM mode, from head\n");
|
||||
default:
|
||||
pthread_mutex_unlock (&ctx->queue_mutex);
|
||||
return ERROR_QUEUE_TYPE_INVALID;
|
||||
}
|
||||
switch (ctx->queue_type) {
|
||||
case QUEUE_TYPE_FORWARD:
|
||||
ptr = ctx->queue_head;
|
||||
printf("> show queue contents in FORWARD mode, from head\n");
|
||||
break;
|
||||
case QUEUE_TYPE_REVERSE:
|
||||
ptr = ctx->queue_tail;
|
||||
printf("> show queue contents in REVERSE mode, from tail\n");
|
||||
break;
|
||||
case QUEUE_TYPE_RANDOM:
|
||||
ptr = ctx->queue_head;
|
||||
printf("> show queue contents in RANDOM mode, from head\n");
|
||||
default:
|
||||
pthread_mutex_unlock(&ctx->queue_mutex);
|
||||
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
|
||||
{
|
||||
sum += ptr->data.id;
|
||||
do {
|
||||
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 (!ptr->next) break;
|
||||
ptr = ptr->next;
|
||||
}
|
||||
else if (ctx->queue_type == QUEUE_TYPE_REVERSE)
|
||||
{
|
||||
if (!ptr->prev) break;
|
||||
ptr = ptr->prev;
|
||||
}
|
||||
if (ctx->queue_type == QUEUE_TYPE_FORWARD || ctx->queue_type == QUEUE_TYPE_RANDOM) {
|
||||
if (!ptr->next) break;
|
||||
ptr = ptr->next;
|
||||
} else if (ctx->queue_type == QUEUE_TYPE_REVERSE) {
|
||||
if (!ptr->prev) break;
|
||||
ptr = ptr->prev;
|
||||
}
|
||||
|
||||
} while (ptr);
|
||||
} while (ptr);
|
||||
|
||||
if (!ptr)
|
||||
{
|
||||
printf ("! Fail: ptr must be not null here\n");
|
||||
pthread_mutex_unlock (&ctx->queue_mutex);
|
||||
return -1;
|
||||
}
|
||||
if (!ptr) {
|
||||
printf("! Fail: ptr must be not null here\n");
|
||||
pthread_mutex_unlock(&ctx->queue_mutex);
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (ctx->queue_type)
|
||||
{
|
||||
case QUEUE_TYPE_RANDOM:
|
||||
printf ("> show queue contents in RANDOM mode, from end to head\n");
|
||||
break;
|
||||
case QUEUE_TYPE_FORWARD:
|
||||
printf ("> show queue contents in FORWARD mode, from end to head\n");
|
||||
break;
|
||||
case QUEUE_TYPE_REVERSE:
|
||||
printf ("> show queue contents in REVERSE mode, from start to tail\n");
|
||||
break;
|
||||
}
|
||||
switch (ctx->queue_type) {
|
||||
case QUEUE_TYPE_RANDOM:
|
||||
printf("> show queue contents in RANDOM mode, from end to head\n");
|
||||
break;
|
||||
case QUEUE_TYPE_FORWARD:
|
||||
printf("> show queue contents in FORWARD mode, from end to head\n");
|
||||
break;
|
||||
case QUEUE_TYPE_REVERSE:
|
||||
printf("> show queue contents in REVERSE mode, from start to tail\n");
|
||||
break;
|
||||
}
|
||||
|
||||
cnt = 0;
|
||||
cnt = 0;
|
||||
|
||||
do
|
||||
{
|
||||
sum -= ptr->data.id;
|
||||
if (cnt++ < 4) printf ("# ID %zu, OFF %zu, MAX %zu\n", ptr->data.id, ptr->data.off, ptr->data.max);
|
||||
do {
|
||||
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 (ctx->queue_type == QUEUE_TYPE_FORWARD || ctx->queue_type == QUEUE_TYPE_RANDOM)
|
||||
{
|
||||
if (!ptr->prev) break;
|
||||
ptr = ptr->prev;
|
||||
}
|
||||
else if (ctx->queue_type == QUEUE_TYPE_REVERSE)
|
||||
{
|
||||
if (!ptr->next) break;
|
||||
ptr = ptr->next;
|
||||
}
|
||||
if (ctx->queue_type == QUEUE_TYPE_FORWARD || ctx->queue_type == QUEUE_TYPE_RANDOM) {
|
||||
if (!ptr->prev) break;
|
||||
ptr = ptr->prev;
|
||||
} else if (ctx->queue_type == QUEUE_TYPE_REVERSE) {
|
||||
if (!ptr->next) break;
|
||||
ptr = ptr->next;
|
||||
}
|
||||
|
||||
} while (ptr);
|
||||
} while (ptr);
|
||||
|
||||
if (sum != 0)
|
||||
{
|
||||
printf ("! Fail: sum is not zero\n");
|
||||
pthread_mutex_unlock (&ctx->queue_mutex);
|
||||
return -1;
|
||||
}
|
||||
if (sum != 0) {
|
||||
printf("! Fail: sum is not zero\n");
|
||||
pthread_mutex_unlock(&ctx->queue_mutex);
|
||||
return -1;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock (&ctx->queue_mutex);
|
||||
return 0;
|
||||
pthread_mutex_unlock(&ctx->queue_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
const char *wu_queue_strerror (int error)
|
||||
{
|
||||
switch (error)
|
||||
{
|
||||
case QUEUE_EMPTY: return (const char *) "QUERY_EMPTY";
|
||||
case NO_ERROR: return (const char *) "NO_ERROR";
|
||||
case ERROR_GENERIC: return (const char *) "ERROR_GENERIC";
|
||||
case ERROR_QUEUE_TYPE_INVALID: return (const char *) "ERROR_QUEUE_TYPE_INVALID";
|
||||
case ERROR_CTX_NULL: return (const char *) "ERROR_CTX_NULL";
|
||||
case ERROR_CTX_IS_INIT: return (const char *) "ERROR_CTX_IS_INIT";
|
||||
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:
|
||||
default:
|
||||
return (const char *) "ERROR_UNDEFINED";
|
||||
}
|
||||
const char *wu_queue_strerror(int error) {
|
||||
switch (error) {
|
||||
case QUEUE_EMPTY:
|
||||
return (const char *) "QUERY_EMPTY";
|
||||
case NO_ERROR:
|
||||
return (const char *) "NO_ERROR";
|
||||
case ERROR_GENERIC:
|
||||
return (const char *) "ERROR_GENERIC";
|
||||
case ERROR_QUEUE_TYPE_INVALID:
|
||||
return (const char *) "ERROR_QUEUE_TYPE_INVALID";
|
||||
case ERROR_CTX_NULL:
|
||||
return (const char *) "ERROR_CTX_NULL";
|
||||
case ERROR_CTX_IS_INIT:
|
||||
return (const char *) "ERROR_CTX_IS_INIT";
|
||||
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:
|
||||
default:
|
||||
return (const char *) "ERROR_UNDEFINED";
|
||||
}
|
||||
}
|
||||
|
||||
const char *wu_queue_strdesc (wu_queue_type_t type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case QUEUE_TYPE_FORWARD: return (const char *) "FORWARD";
|
||||
case QUEUE_TYPE_REVERSE: return (const char *) "REVERSE";
|
||||
case QUEUE_TYPE_RANDOM: return (const char *) "RANDOM";
|
||||
}
|
||||
const char *wu_queue_strdesc(wu_queue_type_t type) {
|
||||
switch (type) {
|
||||
case QUEUE_TYPE_FORWARD:
|
||||
return (const char *) "FORWARD";
|
||||
case QUEUE_TYPE_REVERSE:
|
||||
return (const char *) "REVERSE";
|
||||
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)
|
||||
{
|
||||
#if TEST_UNIT == 1
|
||||
fprintf (stdout, "[%s] enter\n", __func__);
|
||||
fflush (stdout);
|
||||
#endif
|
||||
int wu_queue_init(wu_queue_ctx_t *ctx, wu_queue_type_t queue_type) {
|
||||
#if TEST_UNIT == 1
|
||||
fprintf(stdout, "[%s] enter\n", __func__);
|
||||
fflush(stdout);
|
||||
#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
|
||||
if (ctx->init) return ERROR_CTX_IS_INIT;
|
||||
// Conditional jump or move depends on uninitialised value(s). It's good as it
|
||||
if (ctx->init) return ERROR_CTX_IS_INIT;
|
||||
|
||||
if (queue_type == QUEUE_TYPE_RANDOM) srand ((unsigned int) time(0));
|
||||
else if (queue_type != QUEUE_TYPE_FORWARD && queue_type != QUEUE_TYPE_REVERSE)
|
||||
{
|
||||
#if TEST_UNIT == 1
|
||||
fprintf (stderr, "! Error, invalid 'queue_type'.\n");
|
||||
#endif
|
||||
return ERROR_QUEUE_TYPE_INVALID;
|
||||
}
|
||||
if (queue_type == QUEUE_TYPE_RANDOM) srand((unsigned int) time(0));
|
||||
else if (queue_type != QUEUE_TYPE_FORWARD && queue_type != QUEUE_TYPE_REVERSE) {
|
||||
#if TEST_UNIT == 1
|
||||
fprintf(stderr, "! Error, invalid 'queue_type'.\n");
|
||||
#endif
|
||||
return ERROR_QUEUE_TYPE_INVALID;
|
||||
}
|
||||
|
||||
memset (ctx, 0, sizeof (wu_queue_ctx_t));
|
||||
ctx->queue_type = queue_type;
|
||||
ctx->queue_head = 0; //NULL;
|
||||
ctx->queue_tail = 0; //NULL;
|
||||
memset(ctx, 0, sizeof(wu_queue_ctx_t));
|
||||
ctx->queue_type = queue_type;
|
||||
ctx->queue_head = 0; //NULL;
|
||||
ctx->queue_tail = 0; //NULL;
|
||||
|
||||
int ret = 0;
|
||||
int ret = 0;
|
||||
|
||||
if ((ret = pthread_mutexattr_init (&ctx->queue_mutex_attr)) != 0)
|
||||
{
|
||||
#if TEST_UNIT == 1
|
||||
fprintf (stderr, "! Error, pthread_mutexattr_init() failed (%d): %s\n", ret, strerror (ret));
|
||||
#endif
|
||||
memset (ctx, 0, sizeof (wu_queue_ctx_t));
|
||||
return ERROR_MUTEXATTR_INIT;
|
||||
}
|
||||
if ((ret = pthread_mutexattr_init(&ctx->queue_mutex_attr)) != 0) {
|
||||
#if TEST_UNIT == 1
|
||||
fprintf(stderr, "! Error, pthread_mutexattr_init() failed (%d): %s\n", ret, strerror(ret));
|
||||
#endif
|
||||
memset(ctx, 0, sizeof(wu_queue_ctx_t));
|
||||
return ERROR_MUTEXATTR_INIT;
|
||||
}
|
||||
|
||||
if ((ret = pthread_mutexattr_settype (&ctx->queue_mutex_attr, PTHREAD_MUTEX_ERRORCHECK)) != 0)
|
||||
{
|
||||
#if TEST_UNIT == 1
|
||||
fprintf (stderr, "! Error, pthread_mutexattr_settype(PTHREAD_MUTEX_ERRORCHECK) failed (%d): %s\n", ret, strerror (ret));
|
||||
#endif
|
||||
pthread_mutexattr_destroy (&ctx->queue_mutex_attr);
|
||||
memset (ctx, 0, sizeof (wu_queue_ctx_t));
|
||||
return ERROR_MUTEXATTR_SETTYPE;
|
||||
}
|
||||
if ((ret = pthread_mutexattr_settype(&ctx->queue_mutex_attr, PTHREAD_MUTEX_ERRORCHECK)) != 0) {
|
||||
#if TEST_UNIT == 1
|
||||
fprintf(stderr, "! Error, pthread_mutexattr_settype(PTHREAD_MUTEX_ERRORCHECK) failed (%d): %s\n", ret, strerror(ret));
|
||||
#endif
|
||||
pthread_mutexattr_destroy(&ctx->queue_mutex_attr);
|
||||
memset(ctx, 0, sizeof(wu_queue_ctx_t));
|
||||
return ERROR_MUTEXATTR_SETTYPE;
|
||||
}
|
||||
|
||||
if ((ret = pthread_mutex_init (&ctx->queue_mutex, &ctx->queue_mutex_attr)) != 0)
|
||||
{
|
||||
#if TEST_UNIT == 1
|
||||
fprintf (stderr, "! Error, pthread_mutex_init() failed (%d): %s\n", ret, strerror (ret));
|
||||
#endif
|
||||
pthread_mutexattr_destroy (&ctx->queue_mutex_attr);
|
||||
memset (ctx, 0, sizeof (wu_queue_ctx_t));
|
||||
return ERROR_MUTEX_INIT;
|
||||
}
|
||||
if ((ret = pthread_mutex_init(&ctx->queue_mutex, &ctx->queue_mutex_attr)) != 0) {
|
||||
#if TEST_UNIT == 1
|
||||
fprintf(stderr, "! Error, pthread_mutex_init() failed (%d): %s\n", ret, strerror(ret));
|
||||
#endif
|
||||
pthread_mutexattr_destroy(&ctx->queue_mutex_attr);
|
||||
memset(ctx, 0, sizeof(wu_queue_ctx_t));
|
||||
return ERROR_MUTEX_INIT;
|
||||
}
|
||||
|
||||
ctx->init = 1;
|
||||
return NO_ERROR;
|
||||
ctx->init = 1;
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int wu_queue_done (wu_queue_ctx_t *ctx)
|
||||
{
|
||||
if (!ctx) return ERROR_CTX_NULL;
|
||||
if (!ctx->init) return ERROR_CTX_IS_NOT_INIT;
|
||||
int wu_queue_done(wu_queue_ctx_t *ctx) {
|
||||
if (!ctx) return ERROR_CTX_NULL;
|
||||
if (!ctx->init) return ERROR_CTX_IS_NOT_INIT;
|
||||
|
||||
switch (ctx->queue_type)
|
||||
{
|
||||
case QUEUE_TYPE_RANDOM: return (ctx->queue_head == NULL);
|
||||
case QUEUE_TYPE_FORWARD: return (ctx->queue_head == NULL);
|
||||
case QUEUE_TYPE_REVERSE: return (ctx->queue_tail == NULL);
|
||||
}
|
||||
switch (ctx->queue_type) {
|
||||
case QUEUE_TYPE_RANDOM:
|
||||
return (ctx->queue_head == NULL);
|
||||
case QUEUE_TYPE_FORWARD:
|
||||
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)
|
||||
{
|
||||
if (!ctx) return ERROR_CTX_NULL;
|
||||
if (!ctx->init) return ERROR_CTX_IS_NOT_INIT;
|
||||
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->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;
|
||||
|
||||
short first = 0;
|
||||
short first = 0;
|
||||
|
||||
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 TEST_UNIT == 1
|
||||
fprintf (stderr, "! Error: malloc() failed (%d): %s\n", errno, strerror (errno));
|
||||
#endif
|
||||
pthread_mutex_unlock (&ctx->queue_mutex);
|
||||
return ERROR_ALLOC;
|
||||
}
|
||||
if (!(ptr = (wu_queue_item_t *) malloc(sizeof(wu_queue_item_t)))) {
|
||||
#if TEST_UNIT == 1
|
||||
fprintf(stderr, "! Error: malloc() failed (%d): %s\n", errno, strerror(errno));
|
||||
#endif
|
||||
pthread_mutex_unlock(&ctx->queue_mutex);
|
||||
return ERROR_ALLOC;
|
||||
}
|
||||
|
||||
ptr->data.id = id;
|
||||
ptr->data.off = off;
|
||||
ptr->data.max = max;
|
||||
ptr->next = 0; //NULL;
|
||||
ptr->prev = 0; //NULL;
|
||||
ptr->data.id = id;
|
||||
ptr->data.off = off;
|
||||
ptr->data.max = max;
|
||||
ptr->next = 0; //NULL;
|
||||
ptr->prev = 0; //NULL;
|
||||
|
||||
if (first) {
|
||||
ctx->queue_head = ptr;
|
||||
ctx->queue_tail = ptr;
|
||||
ctx->queue_size++;
|
||||
pthread_mutex_unlock (&ctx->queue_mutex);
|
||||
return NO_ERROR;
|
||||
}
|
||||
if (first) {
|
||||
ctx->queue_head = ptr;
|
||||
ctx->queue_tail = ptr;
|
||||
ctx->queue_size++;
|
||||
pthread_mutex_unlock(&ctx->queue_mutex);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
// set tail
|
||||
ptr->prev = ctx->queue_tail;
|
||||
ctx->queue_tail = ptr;
|
||||
// set tail
|
||||
ptr->prev = ctx->queue_tail;
|
||||
ctx->queue_tail = ptr;
|
||||
|
||||
// set head
|
||||
wu_queue_item_t *last = ctx->queue_head;
|
||||
while (last->next != 0) last = last->next;
|
||||
last->next = ptr;
|
||||
// set head
|
||||
wu_queue_item_t *last = ctx->queue_head;
|
||||
while (last->next != 0) last = last->next;
|
||||
last->next = ptr;
|
||||
|
||||
ctx->queue_size++;
|
||||
pthread_mutex_unlock (&ctx->queue_mutex);
|
||||
return NO_ERROR;
|
||||
ctx->queue_size++;
|
||||
pthread_mutex_unlock(&ctx->queue_mutex);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int wu_queue_pop (wu_queue_ctx_t *ctx, wu_queue_data_t *wu, short remove)
|
||||
{
|
||||
if (!ctx) return ERROR_CTX_NULL;
|
||||
if (!ctx->init) return ERROR_CTX_IS_NOT_INIT;
|
||||
int wu_queue_pop(wu_queue_ctx_t *ctx, wu_queue_data_t *wu, short remove) {
|
||||
if (!ctx) return ERROR_CTX_NULL;
|
||||
if (!ctx->init) return ERROR_CTX_IS_NOT_INIT;
|
||||
|
||||
int ret = -1;
|
||||
int rnd = 0;
|
||||
wu_queue_item_t *ptr = 0, *ptrPrev = 0;
|
||||
int ret = -1;
|
||||
int rnd = 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 TEST_UNIT == 1
|
||||
fprintf (stderr, "ret from wu_queue_done() (%d): %s\n", ret, wu_queue_strerror (ret));
|
||||
#endif
|
||||
pthread_mutex_unlock (&ctx->queue_mutex);
|
||||
return ret;
|
||||
}
|
||||
if ((ret = wu_queue_done(ctx)) != 0) {
|
||||
#if TEST_UNIT == 1
|
||||
fprintf(stderr, "ret from wu_queue_done() (%d): %s\n", ret, wu_queue_strerror(ret));
|
||||
#endif
|
||||
pthread_mutex_unlock(&ctx->queue_mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
switch (ctx->queue_type)
|
||||
{
|
||||
case QUEUE_TYPE_FORWARD:
|
||||
ptr = ctx->queue_head;
|
||||
break;
|
||||
case QUEUE_TYPE_REVERSE:
|
||||
ptr = ctx->queue_tail;
|
||||
break;
|
||||
case QUEUE_TYPE_RANDOM:
|
||||
ptr = ctx->queue_head;
|
||||
rnd = rand() % (int) ctx->queue_size;
|
||||
for (int r = 0; r < rnd; r++)
|
||||
{
|
||||
ptrPrev = ptr;
|
||||
ptr = ptr->next;
|
||||
}
|
||||
break;
|
||||
}
|
||||
switch (ctx->queue_type) {
|
||||
case QUEUE_TYPE_FORWARD:
|
||||
ptr = ctx->queue_head;
|
||||
break;
|
||||
case QUEUE_TYPE_REVERSE:
|
||||
ptr = ctx->queue_tail;
|
||||
break;
|
||||
case QUEUE_TYPE_RANDOM:
|
||||
ptr = ctx->queue_head;
|
||||
rnd = rand() % (int) ctx->queue_size;
|
||||
for (int r = 0; r < rnd; r++) {
|
||||
ptrPrev = ptr;
|
||||
ptr = ptr->next;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ptr)
|
||||
{
|
||||
pthread_mutex_unlock (&ctx->queue_mutex);
|
||||
return ERROR_GENERIC;
|
||||
}
|
||||
if (!ptr) {
|
||||
pthread_mutex_unlock(&ctx->queue_mutex);
|
||||
return ERROR_GENERIC;
|
||||
}
|
||||
|
||||
if (!remove)
|
||||
{
|
||||
wu->id = ptr->data.id;
|
||||
wu->off = ptr->data.off;
|
||||
wu->max = ptr->data.max;
|
||||
}
|
||||
if (!remove) {
|
||||
wu->id = ptr->data.id;
|
||||
wu->off = ptr->data.off;
|
||||
wu->max = ptr->data.max;
|
||||
}
|
||||
|
||||
switch (ctx->queue_type)
|
||||
{
|
||||
case QUEUE_TYPE_FORWARD:
|
||||
ctx->queue_head = (ctx->queue_head)->next;
|
||||
break;
|
||||
case QUEUE_TYPE_REVERSE:
|
||||
ctx->queue_tail = (ctx->queue_tail)->prev;
|
||||
break;
|
||||
case QUEUE_TYPE_RANDOM: // from the head
|
||||
#if TEST_UNIT == 1
|
||||
fprintf (stdout, "pop id %ld\n", wu->id);
|
||||
fflush (stdout);
|
||||
#endif
|
||||
if (ptrPrev == NULL)
|
||||
{
|
||||
ctx->queue_head = (ctx->queue_head)->next;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptrPrev->next = ptr->next;
|
||||
}
|
||||
break;
|
||||
}
|
||||
switch (ctx->queue_type) {
|
||||
case QUEUE_TYPE_FORWARD:
|
||||
ctx->queue_head = (ctx->queue_head)->next;
|
||||
break;
|
||||
case QUEUE_TYPE_REVERSE:
|
||||
ctx->queue_tail = (ctx->queue_tail)->prev;
|
||||
break;
|
||||
case QUEUE_TYPE_RANDOM: // from the head
|
||||
#if TEST_UNIT == 1
|
||||
fprintf(stdout, "pop id %ld\n", wu->id);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
if (ptrPrev == NULL) {
|
||||
ctx->queue_head = (ctx->queue_head)->next;
|
||||
} else {
|
||||
ptrPrev->next = ptr->next;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
memset (ptr, 0, sizeof (wu_queue_item_t));
|
||||
free (ptr);
|
||||
ptr = 0; //NULL;
|
||||
memset(ptr, 0, sizeof(wu_queue_item_t));
|
||||
free(ptr);
|
||||
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);
|
||||
return NO_ERROR;
|
||||
pthread_mutex_unlock(&ctx->queue_mutex);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int wu_queue_destroy (wu_queue_ctx_t *ctx)
|
||||
{
|
||||
#if TEST_UNIT == 1
|
||||
fprintf (stdout, "[%s] enter\n", __func__);
|
||||
fflush (stdout);
|
||||
#endif
|
||||
int wu_queue_destroy(wu_queue_ctx_t *ctx) {
|
||||
#if TEST_UNIT == 1
|
||||
fprintf(stdout, "[%s] enter\n", __func__);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
if (!ctx) return ERROR_CTX_NULL;
|
||||
if (!ctx->init) return ERROR_CTX_IS_NOT_INIT;
|
||||
if (!ctx) return ERROR_CTX_NULL;
|
||||
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
|
||||
while ((ret = wu_queue_pop (ctx, 0, 1)) == 0) {};
|
||||
// unload the queue
|
||||
while ((ret = wu_queue_pop(ctx, 0, 1)) == 0) {};
|
||||
|
||||
if (ret != QUEUE_EMPTY)
|
||||
{
|
||||
#if TEST_UNIT
|
||||
fprintf (stderr, "! Error, wu_queue_pop() failed (%d): %s\n", ret, wu_queue_strerror (ret));
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
if (ret != QUEUE_EMPTY) {
|
||||
#if TEST_UNIT
|
||||
fprintf(stderr, "! Error, wu_queue_pop() failed (%d): %s\n", ret, wu_queue_strerror(ret));
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if TEST_UNIT == 1
|
||||
printf ("ret from wu_queue_pop() (%d): %s\n", ret, wu_queue_strerror (ret));
|
||||
#endif
|
||||
#if TEST_UNIT == 1
|
||||
printf("ret from wu_queue_pop() (%d): %s\n", ret, wu_queue_strerror(ret));
|
||||
#endif
|
||||
|
||||
#if TEST_UNIT == 1
|
||||
if (ctx->queue_head != 0) fprintf (stderr, "queue_head not null\n");
|
||||
if (ctx->queue_tail != 0) fprintf (stderr, "queue_tail not null\n");
|
||||
#endif
|
||||
#if TEST_UNIT == 1
|
||||
if (ctx->queue_head != 0) fprintf(stderr, "queue_head not null\n");
|
||||
if (ctx->queue_tail != 0) fprintf(stderr, "queue_tail not null\n");
|
||||
#endif
|
||||
|
||||
ctx->queue_head = 0; //NULL;
|
||||
ctx->queue_tail = 0; //NULL;
|
||||
ctx->init = 0;
|
||||
ctx->queue_head = 0; //NULL;
|
||||
ctx->queue_tail = 0; //NULL;
|
||||
ctx->init = 0;
|
||||
|
||||
pthread_mutex_unlock (&ctx->queue_mutex);
|
||||
pthread_mutex_unlock(&ctx->queue_mutex);
|
||||
|
||||
pthread_mutex_destroy (&ctx->queue_mutex);
|
||||
pthread_mutexattr_destroy (&ctx->queue_mutex_attr);
|
||||
pthread_mutex_destroy(&ctx->queue_mutex);
|
||||
pthread_mutexattr_destroy(&ctx->queue_mutex_attr);
|
||||
|
||||
memset (ctx, 0, sizeof (wu_queue_ctx_t));
|
||||
//ctx = 0; //NULL;
|
||||
memset(ctx, 0, sizeof(wu_queue_ctx_t));
|
||||
//ctx = 0; //NULL;
|
||||
|
||||
return (ret == 1) ? NO_ERROR : ERROR_GENERIC;
|
||||
return (ret == 1) ? NO_ERROR : ERROR_GENERIC;
|
||||
}
|
||||
|
||||
#if TEST_UNIT == 1
|
||||
int main (void)
|
||||
{
|
||||
unsigned int profiles[11][2] =
|
||||
{
|
||||
{ 16384, 5 }, // 0, best for Intel GPU's with 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
|
||||
{ 2048, 8 }, // 3 (old 1) usefull for any kind of CPU's
|
||||
{ 1024, 9 },
|
||||
{ 512, 10 },
|
||||
{ 256, 11 },
|
||||
{ 128, 12 }, // 7, (old 5) the last good value with NVIDIA GPU's
|
||||
{ 64, 13 },
|
||||
{ 32, 14 },
|
||||
{ 16, 15 },
|
||||
};
|
||||
int main(void) {
|
||||
unsigned int profiles[11][2] = {
|
||||
{ 16384, 5 }, // 0, best for Intel GPU's with 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
|
||||
{ 2048, 8 }, // 3 (old 1) usefull for any kind of CPU's
|
||||
{ 1024, 9 },
|
||||
{ 512, 10 },
|
||||
{ 256, 11 },
|
||||
{ 128, 12 }, // 7, (old 5) the last good value with NVIDIA GPU's
|
||||
{ 64, 13 },
|
||||
{ 32, 14 },
|
||||
{ 16, 15 },
|
||||
};
|
||||
|
||||
size_t err = 0, err_max = 1;
|
||||
size_t id = 0;
|
||||
size_t max = profiles[0][0];
|
||||
size_t chunk = profiles[0][1];
|
||||
size_t sum = 0;
|
||||
int i = 0;
|
||||
size_t err = 0, err_max = 1;
|
||||
size_t id = 0;
|
||||
size_t max = profiles[0][0];
|
||||
size_t chunk = profiles[0][1];
|
||||
size_t sum = 0;
|
||||
int i = 0;
|
||||
|
||||
wu_queue_ctx_t ctx;
|
||||
memset (&ctx, 0, sizeof (wu_queue_ctx_t));
|
||||
wu_queue_ctx_t ctx;
|
||||
memset(&ctx, 0, sizeof(wu_queue_ctx_t));
|
||||
|
||||
printf("Selected the following config: max %zu, chunk %zu\n", max, chunk);
|
||||
fflush (stdout);
|
||||
printf("Selected the following config: max %zu, chunk %zu\n", max, chunk);
|
||||
fflush(stdout);
|
||||
|
||||
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 ret = 0;
|
||||
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 ret = 0;
|
||||
|
||||
for (i = 0; i < types_max; i++)
|
||||
{
|
||||
printf ("[%d] trying wu_queue_init() in %s mode\n", i, wu_queue_strdesc (types[i]));
|
||||
for (i = 0; i < types_max; 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)
|
||||
{
|
||||
fprintf (stderr, "[%d] Error: wu_queue_init(%s) failed (%d): %s\n", i, wu_queue_strdesc (types[i]), ret, wu_queue_strerror (ret));
|
||||
err++;
|
||||
continue;
|
||||
}
|
||||
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));
|
||||
err++;
|
||||
continue;
|
||||
}
|
||||
|
||||
printf ("[%d] trying wu_queue_push()\n", i);
|
||||
printf("[%d] trying wu_queue_push()\n", i);
|
||||
|
||||
for (id = 0; id < max; id++)
|
||||
{
|
||||
sum += id;
|
||||
ret = wu_queue_push (&ctx, id, id << chunk, max);
|
||||
if (ret != 0)
|
||||
{
|
||||
fprintf (stderr, "[%d] Error: wu_queue_push(%zu) failed (%d): %s\n", i, id, ret, wu_queue_strerror (ret));
|
||||
err++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
for (id = 0; id < max; id++) {
|
||||
sum += id;
|
||||
ret = wu_queue_push(&ctx, id, id << chunk, max);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "[%d] Error: wu_queue_push(%zu) failed (%d): %s\n", i, id, ret, wu_queue_strerror(ret));
|
||||
err++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
printf("[%d] push sum: %zu\n", i, sum);
|
||||
printf("[%d] push sum: %zu\n", i, sum);
|
||||
|
||||
if (wu_queue_print (&ctx) == -1)
|
||||
{
|
||||
fprintf (stderr, "[%d] wu_queue_print() error\n", i);
|
||||
err++;
|
||||
continue;
|
||||
}
|
||||
if (wu_queue_print(&ctx) == -1) {
|
||||
fprintf(stderr, "[%d] wu_queue_print() error\n", i);
|
||||
err++;
|
||||
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)
|
||||
{
|
||||
fprintf (stderr, "[%d] Error: wu_queue_pop() failed (%d): %s\n", i, ret, wu_queue_strerror (ret));
|
||||
err++;
|
||||
continue;
|
||||
}
|
||||
if (ret != QUEUE_EMPTY) {
|
||||
fprintf(stderr, "[%d] Error: wu_queue_pop() failed (%d): %s\n", i, ret, wu_queue_strerror(ret));
|
||||
err++;
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("[%d] pop sum: %zu\n", i, sum);
|
||||
printf("[%d] pop sum: %zu\n", i, sum);
|
||||
|
||||
if (sum != 0)
|
||||
{
|
||||
fprintf (stderr, "[%d] Fail: sum is not zero (%zu)\n", i, sum);
|
||||
err++;
|
||||
continue;
|
||||
}
|
||||
if (sum != 0) {
|
||||
fprintf(stderr, "[%d] Fail: sum is not zero (%zu)\n", i, sum);
|
||||
err++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (wu_queue_print (&ctx) == -1)
|
||||
{
|
||||
fprintf (stderr, "[%d] wu_queue_print() error\n", i);
|
||||
err++;
|
||||
continue;
|
||||
}
|
||||
if (wu_queue_print(&ctx) == -1) {
|
||||
fprintf(stderr, "[%d] wu_queue_print() error\n", i);
|
||||
err++;
|
||||
continue;
|
||||
}
|
||||
|
||||
printf ("[%d] trying wu_queue_destroy()\n", i);
|
||||
if ((ret = wu_queue_destroy (&ctx)) != 0)
|
||||
{
|
||||
fprintf (stderr, "! Error: wu_queue_destroy() failed (%d): %s\n", ret, wu_queue_strerror (ret));
|
||||
err++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
printf("[%d] trying wu_queue_destroy()\n", i);
|
||||
if ((ret = wu_queue_destroy(&ctx)) != 0) {
|
||||
fprintf(stderr, "! Error: wu_queue_destroy() failed (%d): %s\n", ret, wu_queue_strerror(ret));
|
||||
err++;
|
||||
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)
|
||||
{
|
||||
printf ("Self-Test pass\n");
|
||||
return 0;
|
||||
}
|
||||
if (err == err_max) {
|
||||
printf("Self-Test pass\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf ("Self-Test fail\n");
|
||||
return -1;
|
||||
printf("Self-Test fail\n");
|
||||
return -1;
|
||||
}
|
||||
#endif // TEST_UNIT
|
||||
|
|
|
@ -42,81 +42,76 @@ License: GNU General Public License v3 or any later version (see LICENSE.txt)
|
|||
#include <pthread.h>
|
||||
|
||||
// enum errors
|
||||
typedef enum wu_queue_error
|
||||
{
|
||||
QUEUE_EMPTY = 1,
|
||||
NO_ERROR = 0,
|
||||
ERROR_GENERIC = -1,
|
||||
ERROR_QUEUE_TYPE_INVALID = -2,
|
||||
ERROR_CTX_NULL = -3,
|
||||
ERROR_CTX_IS_INIT = -4,
|
||||
ERROR_CTX_IS_NOT_INIT = -5,
|
||||
ERROR_MUTEXATTR_INIT = -6,
|
||||
ERROR_MUTEXATTR_SETTYPE = -7,
|
||||
ERROR_MUTEX_INIT = -8,
|
||||
ERROR_ALLOC = -9,
|
||||
ERROR_UNDEFINED = -10
|
||||
typedef enum wu_queue_error {
|
||||
QUEUE_EMPTY = 1,
|
||||
NO_ERROR = 0,
|
||||
ERROR_GENERIC = -1,
|
||||
ERROR_QUEUE_TYPE_INVALID = -2,
|
||||
ERROR_CTX_NULL = -3,
|
||||
ERROR_CTX_IS_INIT = -4,
|
||||
ERROR_CTX_IS_NOT_INIT = -5,
|
||||
ERROR_MUTEXATTR_INIT = -6,
|
||||
ERROR_MUTEXATTR_SETTYPE = -7,
|
||||
ERROR_MUTEX_INIT = -8,
|
||||
ERROR_ALLOC = -9,
|
||||
ERROR_UNDEFINED = -10
|
||||
|
||||
} wu_queue_error_t;
|
||||
|
||||
// enum queue types
|
||||
typedef enum wu_queue_type
|
||||
{
|
||||
QUEUE_TYPE_FORWARD = 0,
|
||||
QUEUE_TYPE_REVERSE,
|
||||
QUEUE_TYPE_RANDOM
|
||||
typedef enum wu_queue_type {
|
||||
QUEUE_TYPE_FORWARD = 0,
|
||||
QUEUE_TYPE_REVERSE,
|
||||
QUEUE_TYPE_RANDOM
|
||||
|
||||
} wu_queue_type_t;
|
||||
|
||||
// hold wu data
|
||||
typedef struct wu_queue_data
|
||||
{
|
||||
size_t id;
|
||||
size_t off;
|
||||
size_t max;
|
||||
size_t rem;
|
||||
typedef struct wu_queue_data {
|
||||
size_t id;
|
||||
size_t off;
|
||||
size_t max;
|
||||
size_t rem;
|
||||
|
||||
} wu_queue_data_t;
|
||||
|
||||
// lists
|
||||
typedef struct wu_queue_item wu_queue_item_t;
|
||||
struct wu_queue_item
|
||||
{
|
||||
wu_queue_data_t data;
|
||||
wu_queue_item_t *next;
|
||||
wu_queue_item_t *prev;
|
||||
struct wu_queue_item {
|
||||
wu_queue_data_t data;
|
||||
wu_queue_item_t *next;
|
||||
wu_queue_item_t *prev;
|
||||
};
|
||||
|
||||
// main ctx
|
||||
typedef struct wu_queue_ctx
|
||||
{
|
||||
unsigned int init;
|
||||
typedef struct wu_queue_ctx {
|
||||
unsigned int init;
|
||||
|
||||
wu_queue_type_t queue_type;
|
||||
wu_queue_item_t *queue_head;
|
||||
wu_queue_item_t *queue_tail;
|
||||
wu_queue_type_t queue_type;
|
||||
wu_queue_item_t *queue_head;
|
||||
wu_queue_item_t *queue_tail;
|
||||
|
||||
size_t queue_size;
|
||||
size_t queue_size;
|
||||
|
||||
// mutex
|
||||
pthread_mutexattr_t queue_mutex_attr;
|
||||
// mutex
|
||||
pthread_mutexattr_t queue_mutex_attr;
|
||||
// unsigned char pad1[4];
|
||||
pthread_mutex_t queue_mutex;
|
||||
pthread_mutex_t queue_mutex;
|
||||
|
||||
} wu_queue_ctx_t;
|
||||
|
||||
// exports
|
||||
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_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_destroy (wu_queue_ctx_t *ctx);
|
||||
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_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_destroy(wu_queue_ctx_t *ctx);
|
||||
|
||||
const char *wu_queue_strdesc (wu_queue_type_t type);
|
||||
const char *wu_queue_strerror (int error);
|
||||
const char *wu_queue_strdesc(wu_queue_type_t type);
|
||||
const char *wu_queue_strerror(int error);
|
||||
|
||||
#if TEST_UNIT == 1
|
||||
int wu_queue_print (wu_queue_ctx_t *ctx);
|
||||
int wu_queue_print(wu_queue_ctx_t *ctx);
|
||||
#endif
|
||||
|
||||
#endif // QUEUE_H
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -34,110 +34,105 @@ License: GNU General Public License v3 or any later version (see LICENSE.txt)
|
|||
#include "opencl.h"
|
||||
#include "hitag2.h"
|
||||
|
||||
typedef enum thread_status
|
||||
{
|
||||
TH_START = 0,
|
||||
TH_WAIT,
|
||||
TH_PROCESSING,
|
||||
TH_STOP,
|
||||
TH_ERROR,
|
||||
TH_FOUND_KEY,
|
||||
TH_END
|
||||
typedef enum thread_status {
|
||||
TH_START = 0,
|
||||
TH_WAIT,
|
||||
TH_PROCESSING,
|
||||
TH_STOP,
|
||||
TH_ERROR,
|
||||
TH_FOUND_KEY,
|
||||
TH_END
|
||||
|
||||
} thread_status_t;
|
||||
|
||||
typedef enum thread_type
|
||||
{
|
||||
THREAD_TYPE_SEQ = 0,
|
||||
THREAD_TYPE_ASYNC
|
||||
typedef enum thread_type {
|
||||
THREAD_TYPE_SEQ = 0,
|
||||
THREAD_TYPE_ASYNC
|
||||
|
||||
} thread_type_t;
|
||||
|
||||
typedef enum thread_error
|
||||
{
|
||||
THREAD_NOERROR = 0,
|
||||
THREAD_ERROR_CTX_IS_NULL = -1,
|
||||
THREAD_ERROR_CTX_IS_INIT = -2,
|
||||
THREAD_ERROR_TYPE_INVALID = -3,
|
||||
THREAD_ERROR_COUNT_INVALID = -4,
|
||||
THREAD_ERROR_ATTR_SETDETACH = -5,
|
||||
THREAD_ERROR_ATTR = -6,
|
||||
THREAD_ERROR_MUTEXATTR = -7,
|
||||
THREAD_ERROR_CREATE = -8,
|
||||
THREAD_ERROR_MUTEX = -9,
|
||||
THREAD_ERROR_COND = -10,
|
||||
THREAD_ERROR_MUTEX_USLEEP = -11,
|
||||
THREAD_ERROR_COND_USLEEP = -12,
|
||||
THREAD_ERROR_GENERIC = -13,
|
||||
THREAD_ERROR_ALLOC = -14
|
||||
typedef enum thread_error {
|
||||
THREAD_NOERROR = 0,
|
||||
THREAD_ERROR_CTX_IS_NULL = -1,
|
||||
THREAD_ERROR_CTX_IS_INIT = -2,
|
||||
THREAD_ERROR_TYPE_INVALID = -3,
|
||||
THREAD_ERROR_COUNT_INVALID = -4,
|
||||
THREAD_ERROR_ATTR_SETDETACH = -5,
|
||||
THREAD_ERROR_ATTR = -6,
|
||||
THREAD_ERROR_MUTEXATTR = -7,
|
||||
THREAD_ERROR_CREATE = -8,
|
||||
THREAD_ERROR_MUTEX = -9,
|
||||
THREAD_ERROR_COND = -10,
|
||||
THREAD_ERROR_MUTEX_USLEEP = -11,
|
||||
THREAD_ERROR_COND_USLEEP = -12,
|
||||
THREAD_ERROR_GENERIC = -13,
|
||||
THREAD_ERROR_ALLOC = -14
|
||||
|
||||
} thread_error_t;
|
||||
|
||||
typedef struct threads_ctx
|
||||
{
|
||||
short init;
|
||||
short type;
|
||||
typedef struct threads_ctx {
|
||||
short init;
|
||||
short type;
|
||||
|
||||
unsigned char pad1[4];
|
||||
size_t thread_count;
|
||||
unsigned char pad1[4];
|
||||
size_t thread_count;
|
||||
|
||||
pthread_t *thread_handles;
|
||||
pthread_t *thread_handles;
|
||||
|
||||
pthread_mutex_t *thread_mutexs;
|
||||
pthread_cond_t *thread_conds;
|
||||
pthread_mutex_t *thread_mutexs;
|
||||
pthread_cond_t *thread_conds;
|
||||
|
||||
short enable_condusleep;
|
||||
short enable_condusleep;
|
||||
|
||||
// get rid of sleep/usleep call to synchronize threads
|
||||
unsigned char pad2[6];
|
||||
pthread_mutex_t thread_mutex_usleep;
|
||||
pthread_cond_t thread_cond_usleep;
|
||||
// get rid of sleep/usleep call to synchronize threads
|
||||
unsigned char pad2[6];
|
||||
pthread_mutex_t thread_mutex_usleep;
|
||||
pthread_cond_t thread_cond_usleep;
|
||||
|
||||
pthread_attr_t attr;
|
||||
pthread_mutexattr_t mutex_attr;
|
||||
pthread_attr_t attr;
|
||||
pthread_mutexattr_t mutex_attr;
|
||||
|
||||
} thread_ctx_t;
|
||||
|
||||
// used by threads engine
|
||||
typedef struct thread_arg
|
||||
{
|
||||
thread_status_t status;
|
||||
unsigned char pad1[4];
|
||||
size_t max_threads;
|
||||
typedef struct thread_arg {
|
||||
thread_status_t status;
|
||||
unsigned char pad1[4];
|
||||
size_t max_threads;
|
||||
|
||||
uint64_t s;
|
||||
uint32_t uid, nR1, aR1, nR2, aR2;
|
||||
bool r;
|
||||
bool err;
|
||||
bool quit;
|
||||
bool async;
|
||||
uint64_t s;
|
||||
uint32_t uid, nR1, aR1, nR2, aR2;
|
||||
bool r;
|
||||
bool err;
|
||||
bool quit;
|
||||
bool async;
|
||||
|
||||
uint64_t off;
|
||||
uint64_t *matches;
|
||||
uint32_t *matches_found;
|
||||
size_t slice;
|
||||
size_t max_step;
|
||||
size_t device_id;
|
||||
uint64_t off;
|
||||
uint64_t *matches;
|
||||
uint32_t *matches_found;
|
||||
size_t slice;
|
||||
size_t max_step;
|
||||
size_t device_id;
|
||||
|
||||
uint64_t key;
|
||||
uint64_t key;
|
||||
|
||||
opencl_ctx_t *ocl_ctx;
|
||||
thread_ctx_t *thread_ctx;
|
||||
opencl_ctx_t *ocl_ctx;
|
||||
thread_ctx_t *thread_ctx;
|
||||
|
||||
} thread_args_t;
|
||||
|
||||
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_stop (thread_ctx_t *ctx);
|
||||
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_stop(thread_ctx_t *ctx);
|
||||
|
||||
void tprintf (const char * restrict format, ...);
|
||||
const char *thread_strerror (int error);
|
||||
const char *thread_status_strdesc (thread_status_t s);
|
||||
bool thread_setEnd (thread_ctx_t *ctx, thread_args_t *t_arg);
|
||||
void tprintf(const char *restrict format, ...);
|
||||
const char *thread_strerror(int error);
|
||||
const char *thread_status_strdesc(thread_status_t s);
|
||||
bool thread_setEnd(thread_ctx_t *ctx, thread_args_t *t_arg);
|
||||
|
||||
void *computing_process (void *arg);
|
||||
void *computing_process_async (void *arg);
|
||||
void *computing_process(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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue