Add platform vendor_id detection

pull/321/head
Jens Steube 8 years ago
parent 082b1504b1
commit 7cbce12ea7

@ -196,10 +196,6 @@ static inline u32 rotl32_S (const u32 a, const u32 n)
static inline u64 rotr64_S (const u64 a, const u32 n)
{
#if (DEVICE_TYPE == DEVICE_TYPE_GPU)
#ifdef cl_amd_media_ops
const u32 a0 = h32_from_64_S (a);
const u32 a1 = l32_from_64_S (a);
@ -208,18 +204,6 @@ static inline u64 rotr64_S (const u64 a, const u32 n)
const u64 r = hl32_to_64_S (t0, t1);
#else
const u64 r = rotate (a, (u64) 64 - n);
#endif
#else
const u64 r = rotate (a, (u64) 64 - n);
#endif
return r;
}
@ -260,10 +244,6 @@ static inline u32x rotl32 (const u32x a, const u32 n)
static inline u64x rotr64 (const u64x a, const u32 n)
{
#if (DEVICE_TYPE == DEVICE_TYPE_GPU)
#ifdef cl_amd_media_ops
const u32x a0 = h32_from_64 (a);
const u32x a1 = l32_from_64 (a);
@ -272,18 +252,6 @@ static inline u64x rotr64 (const u64x a, const u32 n)
const u64x r = hl32_to_64 (t0, t1);
#else
const u64x r = rotate (a, (u64) 64 - n);
#endif
#else
const u64x r = rotate (a, (u64) 64 - n);
#endif
return r;
}
@ -294,34 +262,12 @@ static inline u64x rotl64 (const u64x a, const u32 n)
static inline u32 __bfe (const u32 a, const u32 b, const u32 c)
{
#ifdef cl_amd_media_ops2
return amd_bfe (a, b, c);
#else
#define BIT(x) (1 << (x))
#define BIT_MASK(x) (BIT (x) - 1)
#define BFE(x,y,z) (((x) >> (y)) & BIT_MASK (z))
return BFE (a, b, c);
#endif
}
static inline u32 amd_bytealign_S (const u32 a, const u32 b, const u32 c)
{
#ifdef cl_amd_media_ops
return amd_bytealign (a, b, c);
#else
const u64 tmp = ((((u64) a) << 32) | ((u64) b)) >> ((c & 3) * 8);
return (u32) (tmp);
#endif
}
#endif

@ -15,9 +15,9 @@
* vendor specific
*/
#if VENDOR_ID == 4098
#if VENDOR_ID == (1 << 0)
#define IS_AMD
#elif VENDOR_ID == 4318
#elif VENDOR_ID == (1 << 6)
#define IS_NV
#else
#define IS_GENERIC

@ -132,16 +132,23 @@ static inline int CPU_ISSET (int num, cpu_set_t *cs) { return (cs->count & (1 <
#define CL_PLATFORMS_MAX 16
#define CL_VENDOR_NV "NVIDIA Corporation"
#define CL_VENDOR_AMD "Advanced Micro Devices, Inc."
#define CL_VENDOR_APPLE "Apple"
#define CL_VENDOR_INTEL_BEIGNET "Intel"
#define CL_VENDOR_INTEL_SDK "Intel(R) OpenCL"
#define CL_VENDOR_MESA "Mesa"
#define CL_VENDOR_NV "NVIDIA Corporation"
#define CL_VENDOR_POCL "The pocl project"
#define VENDOR_ID_AMD 4098
#define VENDOR_ID_NV 4318
#define VENDOR_ID_APPLE_INTEL 4294967295
#define VENDOR_ID_APPLE_IRIS 16925952
#define VENDOR_ID_GENERIC 9999
#define VENDOR_ID_AMD (1 << 0)
#define VENDOR_ID_APPLE (1 << 1)
#define VENDOR_ID_INTEL_BEIGNET (1 << 2)
#define VENDOR_ID_INTEL_SDK (1 << 3)
#define VENDOR_ID INTEL (1 << 4)
#define VENDOR_ID_MESA (1 << 5)
#define VENDOR_ID_NV (1 << 6)
#define VENDOR_ID_POCL (1 << 7)
#define VENDOR_ID_GENERIC (1 << 31)
#define BLOCK_SIZE 64
@ -644,8 +651,8 @@ extern hc_thread_mutex_t mux_display;
#define DISPLAY_LEN_MAX_11100 10 + 32 + 1 + 8 + 1 + 32
#define DISPLAY_LEN_MIN_11200 9 + 40 + 1 + 40
#define DISPLAY_LEN_MAX_11200 9 + 40 + 1 + 40
#define DISPLAY_LEN_MIN_11300 1 + 7 + 1 + 2 + 1 + 96 + 1 + 2 + 1 + 16 + 1 + 1 + 1 + 2 + 1 + 96 + 1 + 2 + 1 + 66
#define DISPLAY_LEN_MAX_11300 1 + 7 + 1 + 2 + 1 + 96 + 1 + 2 + 1 + 16 + 1 + 6 + 1 + 2 + 1 + 96 + 1 + 2 + 1 + 66
#define DISPLAY_LEN_MIN_11300 1 + 7 + 1 + 2 + 1 + 96 + 1 + 2 + 1 + 16 + 1 + 1 + 1 + 2 + 1 + 96 + 1 + 1 + 1 + 2
#define DISPLAY_LEN_MAX_11300 1 + 7 + 1 + 2 + 1 + 96 + 1 + 2 + 1 + 16 + 1 + 6 + 1 + 2 + 1 + 96 + 1 + 3 + 1 + 512
#define DISPLAY_LEN_MIN_11400 6 + 0 + 1 + 0 + 1 + 0 + 1 + 0 + 1 + 0 + 1 + 0 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 1 + 0 + 1 + 0 + 1 + 3 + 1 + 32
#define DISPLAY_LEN_MAX_11400 6 + 512 + 1 + 512 + 1 + 116 + 1 + 116 + 1 + 246 + 1 + 245 + 1 + 246 + 1 + 245 + 1 + 50 + 1 + 50 + 1 + 50 + 1 + 50 + 1 + 3 + 1 + 32
#define DISPLAY_LEN_MIN_11500 8 + 1 + 8

@ -12676,6 +12676,49 @@ int main (int argc, char **argv)
hc_clGetDeviceIDs (data.ocl, platform, CL_DEVICE_TYPE_ALL, DEVICES_MAX, platform_devices, &platform_devices_cnt);
char platform_vendor[INFOSZ] = { 0 };
hc_clGetPlatformInfo (data.ocl, platform, CL_PLATFORM_VENDOR, sizeof (platform_vendor), platform_vendor, NULL);
// find our own platform vendor because pocl and mesa are pushing original vendor_id through opencl
// this causes trouble with vendor id based macros
// we'll assign generic to those without special optimization available
cl_uint vendor_id = 0;
if (strcmp (platform_vendor, CL_VENDOR_AMD) == 0)
{
vendor_id = VENDOR_ID_AMD;
}
else if (strcmp (platform_vendor, CL_VENDOR_APPLE) == 0)
{
vendor_id = VENDOR_ID_GENERIC;
}
else if (strcmp (platform_vendor, CL_VENDOR_INTEL_BEIGNET) == 0)
{
vendor_id = VENDOR_ID_GENERIC;
}
else if (strcmp (platform_vendor, CL_VENDOR_INTEL_SDK) == 0)
{
vendor_id = VENDOR_ID_GENERIC;
}
else if (strcmp (platform_vendor, CL_VENDOR_MESA) == 0)
{
vendor_id = VENDOR_ID_GENERIC;
}
else if (strcmp (platform_vendor, CL_VENDOR_NV) == 0)
{
vendor_id = VENDOR_ID_NV;
}
else if (strcmp (platform_vendor, CL_VENDOR_POCL) == 0)
{
vendor_id = VENDOR_ID_GENERIC;
}
else
{
vendor_id = VENDOR_ID_GENERIC;
}
for (uint platform_devices_id = 0; platform_devices_id < platform_devices_cnt; platform_devices_id++)
{
size_t param_value_size = 0;
@ -12684,6 +12727,8 @@ int main (int argc, char **argv)
hc_device_param_t *device_param = &data.devices_param[device_id];
device_param->vendor_id = vendor_id;
device_param->device = platform_devices[platform_devices_id];
device_param->device_id = device_id;
@ -12700,14 +12745,6 @@ int main (int argc, char **argv)
device_param->device_type = device_type;
// vendor_id
cl_uint vendor_id = 0;
hc_clGetDeviceInfo (data.ocl, device_param->device, CL_DEVICE_VENDOR_ID, sizeof (vendor_id), &vendor_id, NULL);
device_param->vendor_id = vendor_id;
// device_name
hc_clGetDeviceInfo (data.ocl, device_param->device, CL_DEVICE_NAME, 0, NULL, &param_value_size);
@ -12744,16 +12781,6 @@ int main (int argc, char **argv)
myfree (device_opencl_version);
if (strstr (device_version, "pocl"))
{
// pocl returns the real vendor_id in CL_DEVICE_VENDOR_ID which causes many problems because of hms and missing amd_bfe () etc
// we need to overwrite vendor_id to avoid this. maybe open pocl issue?
cl_uint vendor_id = VENDOR_ID_GENERIC;
device_param->vendor_id = vendor_id;
}
// vector_width
cl_uint vector_width;
@ -12863,12 +12890,6 @@ int main (int argc, char **argv)
if (device_type & CL_DEVICE_TYPE_GPU)
{
if (vendor_id == VENDOR_ID_AMD)
{
if (strstr (device_version, "MESA"))
{
// MESA stuff
}
else
{
cl_uint device_processor_cores = 0;
@ -12878,7 +12899,6 @@ int main (int argc, char **argv)
device_param->device_processor_cores = device_processor_cores;
}
}
else if (vendor_id == VENDOR_ID_NV)
{
cl_uint kernel_exec_timeout = 0;
@ -12943,37 +12963,9 @@ int main (int argc, char **argv)
if (device_param->skipped == 0)
{
if (strstr (device_version, "pocl"))
{
if (force == 0)
{
log_info ("");
log_info ("ATTENTION! All pocl drivers are known to be broken due to broken LLVM <= 3.7");
log_info ("You are STRONGLY encouraged not to use it");
log_info ("You can use --force to override this but do not post error reports if you do so");
log_info ("");
return (-1);
}
}
if (device_type & CL_DEVICE_TYPE_GPU)
{
if (vendor_id == VENDOR_ID_NV)
{
if (device_param->kernel_exec_timeout != 0)
{
if (data.quiet == 0) log_info ("Device #%u: WARNING! Kernel exec timeout is not disabled, it might cause you errors of code 702", device_id + 1);
if (data.quiet == 0) log_info (" See the wiki on how to disable it: https://hashcat.net/wiki/doku.php?id=timeout_patch");
}
}
else if (vendor_id == VENDOR_ID_AMD)
{
if (strstr (device_version, "MESA"))
{
// MESA stuff
}
else
if (vendor_id == VENDOR_ID_AMD)
{
int catalyst_check = (force == 1) ? 0 : 1;
@ -13021,6 +13013,26 @@ int main (int argc, char **argv)
return (-1);
}
}
else if (vendor_id == VENDOR_ID_NV)
{
if (device_param->kernel_exec_timeout != 0)
{
if (data.quiet == 0) log_info ("Device #%u: WARNING! Kernel exec timeout is not disabled, it might cause you errors of code 702", device_id + 1);
if (data.quiet == 0) log_info (" See the wiki on how to disable it: https://hashcat.net/wiki/doku.php?id=timeout_patch");
}
}
else if (vendor_id == VENDOR_ID_POCL)
{
if (force == 0)
{
log_info ("");
log_info ("ATTENTION! All pocl drivers are known to be broken due to broken LLVM <= 3.7");
log_info ("You are STRONGLY encouraged not to use it");
log_info ("You can use --force to override this but do not post error reports if you do so");
log_info ("");
return (-1);
}
}
}

Loading…
Cancel
Save