mirror of
https://github.com/hashcat/hashcat.git
synced 2025-01-09 15:20:59 +00:00
OpenCL Devices: Utilize PCI domain to improve alias device detection
This commit is contained in:
parent
5f7b70bc42
commit
0ff2f8c5e1
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
- Compile macOS: Fixed makefile target 'clean' to correctly remove *.dSYM folders
|
- Compile macOS: Fixed makefile target 'clean' to correctly remove *.dSYM folders
|
||||||
- Compile ZLIB: Fixed makefile include paths in case USE_SYSTEM_ZLIB is used
|
- Compile ZLIB: Fixed makefile include paths in case USE_SYSTEM_ZLIB is used
|
||||||
|
- OpenCL Devices: Utilize PCI domain to improve alias device detection
|
||||||
- OpenCL Kernels: Added datatypes to literals of enum costants
|
- OpenCL Kernels: Added datatypes to literals of enum costants
|
||||||
- OpenCL Kernels: Added pure kernels for hash-mode 600 (BLAKE2b-512)
|
- OpenCL Kernels: Added pure kernels for hash-mode 600 (BLAKE2b-512)
|
||||||
- OpenCL Runtime: Add some unstable warnings for some SHA512 based algorithms on AMD GPU on macOS
|
- OpenCL Runtime: Add some unstable warnings for some SHA512 based algorithms on AMD GPU on macOS
|
||||||
|
@ -1056,6 +1056,7 @@ typedef struct hc_device_param
|
|||||||
int device_id_alias_cnt;
|
int device_id_alias_cnt;
|
||||||
int device_id_alias_buf[DEVICES_MAX];
|
int device_id_alias_buf[DEVICES_MAX];
|
||||||
|
|
||||||
|
u8 pcie_domain;
|
||||||
u8 pcie_bus;
|
u8 pcie_bus;
|
||||||
u8 pcie_device;
|
u8 pcie_device;
|
||||||
u8 pcie_function;
|
u8 pcie_function;
|
||||||
@ -1437,6 +1438,7 @@ typedef struct hc_device_param
|
|||||||
|
|
||||||
cl_device_type opencl_device_type;
|
cl_device_type opencl_device_type;
|
||||||
cl_uint opencl_device_vendor_id;
|
cl_uint opencl_device_vendor_id;
|
||||||
|
u32 opencl_platform_id;
|
||||||
cl_uint opencl_platform_vendor_id;
|
cl_uint opencl_platform_vendor_id;
|
||||||
|
|
||||||
cl_device_id opencl_device;
|
cl_device_id opencl_device;
|
||||||
|
@ -39,17 +39,33 @@ static double TARGET_MSEC_PROFILE[4] = { 2, 12, 96, 480 };
|
|||||||
|
|
||||||
static bool is_same_device (const hc_device_param_t *src, const hc_device_param_t *dst)
|
static bool is_same_device (const hc_device_param_t *src, const hc_device_param_t *dst)
|
||||||
{
|
{
|
||||||
|
// First check by PCI address
|
||||||
|
|
||||||
|
if (src->pcie_domain != dst->pcie_domain) return false; // PCI domain not available on OpenCL
|
||||||
if (src->pcie_bus != dst->pcie_bus) return false;
|
if (src->pcie_bus != dst->pcie_bus) return false;
|
||||||
if (src->pcie_device != dst->pcie_device) return false;
|
if (src->pcie_device != dst->pcie_device) return false;
|
||||||
if (src->pcie_function != dst->pcie_function) return false;
|
if (src->pcie_function != dst->pcie_function) return false;
|
||||||
|
|
||||||
|
// macOS still can't distinguish the devices by PCIe bus:
|
||||||
|
|
||||||
|
if (src->device_processors != dst->device_processors) return false;
|
||||||
|
|
||||||
|
// CUDA can't have aliases
|
||||||
|
|
||||||
|
if ((src->is_cuda == true) && (dst->is_cuda == true)) return false;
|
||||||
|
|
||||||
|
// But OpenCL can have aliases
|
||||||
|
|
||||||
|
if ((src->is_opencl == true) && (dst->is_opencl == true))
|
||||||
|
{
|
||||||
// Intel CPU and embedded GPU would survive up to here!
|
// Intel CPU and embedded GPU would survive up to here!
|
||||||
|
|
||||||
if (src->opencl_device_type != dst->opencl_device_type) return false;
|
if (src->opencl_device_type != dst->opencl_device_type) return false;
|
||||||
|
|
||||||
// macOS still can't distinguish the devices by PCIe bus:
|
// There should be no aliases on the same opencl platform
|
||||||
|
|
||||||
if (src->device_processors != dst->device_processors) return false;
|
if (src->opencl_platform_id == dst->opencl_platform_id) return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -5473,13 +5489,17 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
|
|||||||
|
|
||||||
// pcie_bus, pcie_device, pcie_function
|
// pcie_bus, pcie_device, pcie_function
|
||||||
|
|
||||||
|
int pci_domain_id_nv = 0;
|
||||||
int pci_bus_id_nv = 0;
|
int pci_bus_id_nv = 0;
|
||||||
int pci_slot_id_nv = 0;
|
int pci_slot_id_nv = 0;
|
||||||
|
|
||||||
|
if (hc_cuDeviceGetAttribute (hashcat_ctx, &pci_domain_id_nv, CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID, cuda_device) == -1) return -1;
|
||||||
|
|
||||||
if (hc_cuDeviceGetAttribute (hashcat_ctx, &pci_bus_id_nv, CU_DEVICE_ATTRIBUTE_PCI_BUS_ID, cuda_device) == -1) return -1;
|
if (hc_cuDeviceGetAttribute (hashcat_ctx, &pci_bus_id_nv, CU_DEVICE_ATTRIBUTE_PCI_BUS_ID, cuda_device) == -1) return -1;
|
||||||
|
|
||||||
if (hc_cuDeviceGetAttribute (hashcat_ctx, &pci_slot_id_nv, CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID, cuda_device) == -1) return -1;
|
if (hc_cuDeviceGetAttribute (hashcat_ctx, &pci_slot_id_nv, CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID, cuda_device) == -1) return -1;
|
||||||
|
|
||||||
|
device_param->pcie_domain = (u8) (pci_domain_id_nv);
|
||||||
device_param->pcie_bus = (u8) (pci_bus_id_nv);
|
device_param->pcie_bus = (u8) (pci_bus_id_nv);
|
||||||
device_param->pcie_device = (u8) (pci_slot_id_nv >> 3);
|
device_param->pcie_device = (u8) (pci_slot_id_nv >> 3);
|
||||||
device_param->pcie_function = (u8) (pci_slot_id_nv & 7);
|
device_param->pcie_function = (u8) (pci_slot_id_nv & 7);
|
||||||
@ -5717,6 +5737,10 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
|
|||||||
|
|
||||||
device_param->is_opencl = true;
|
device_param->is_opencl = true;
|
||||||
|
|
||||||
|
// store opencl platform i
|
||||||
|
|
||||||
|
device_param->opencl_platform_id = opencl_platforms_idx;
|
||||||
|
|
||||||
// check OpenCL version
|
// check OpenCL version
|
||||||
|
|
||||||
device_param->use_opencl12 = false;
|
device_param->use_opencl12 = false;
|
||||||
@ -6190,6 +6214,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
|
|||||||
|
|
||||||
if (hc_clGetDeviceInfo (hashcat_ctx, device_param->opencl_device, CL_DEVICE_TOPOLOGY_AMD, sizeof (amdtopo), &amdtopo, NULL) == -1) return -1;
|
if (hc_clGetDeviceInfo (hashcat_ctx, device_param->opencl_device, CL_DEVICE_TOPOLOGY_AMD, sizeof (amdtopo), &amdtopo, NULL) == -1) return -1;
|
||||||
|
|
||||||
|
device_param->pcie_domain = 0; // no attribute to query
|
||||||
device_param->pcie_bus = amdtopo.pcie.bus;
|
device_param->pcie_bus = amdtopo.pcie.bus;
|
||||||
device_param->pcie_device = amdtopo.pcie.device;
|
device_param->pcie_device = amdtopo.pcie.device;
|
||||||
device_param->pcie_function = amdtopo.pcie.function;
|
device_param->pcie_function = amdtopo.pcie.function;
|
||||||
@ -6204,6 +6229,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
|
|||||||
|
|
||||||
if (hc_clGetDeviceInfo (hashcat_ctx, device_param->opencl_device, CL_DEVICE_PCI_SLOT_ID_NV, sizeof (pci_slot_id_nv), &pci_slot_id_nv, NULL) == -1) return -1;
|
if (hc_clGetDeviceInfo (hashcat_ctx, device_param->opencl_device, CL_DEVICE_PCI_SLOT_ID_NV, sizeof (pci_slot_id_nv), &pci_slot_id_nv, NULL) == -1) return -1;
|
||||||
|
|
||||||
|
device_param->pcie_domain = 0; // no attribute to query
|
||||||
device_param->pcie_bus = (u8) (pci_bus_id_nv);
|
device_param->pcie_bus = (u8) (pci_bus_id_nv);
|
||||||
device_param->pcie_device = (u8) (pci_slot_id_nv >> 3);
|
device_param->pcie_device = (u8) (pci_slot_id_nv >> 3);
|
||||||
device_param->pcie_function = (u8) (pci_slot_id_nv & 7);
|
device_param->pcie_function = (u8) (pci_slot_id_nv & 7);
|
||||||
|
Loading…
Reference in New Issue
Block a user