1
mirror of https://github.com/hashcat/hashcat synced 2024-11-24 14:27:14 +01:00
hashcat/OpenCL/inc_vendor.h

158 lines
2.7 KiB
C
Raw Normal View History

2015-12-04 15:47:52 +01:00
/**
* Author......: See docs/credits.txt
2015-12-04 15:47:52 +01:00
* License.....: MIT
*/
#ifndef _INC_VENDOR_H
#define _INC_VENDOR_H
2019-04-25 14:45:17 +02:00
#if defined _CPU_OPENCL_EMU_H
#define IS_NATIVE
#elif defined __CUDACC__
#define IS_CUDA
#else
#define IS_OPENCL
#endif
#if defined IS_NATIVE
2019-05-06 14:34:16 +02:00
#define CONSTANT_VK
#define CONSTANT_AS
#define GLOBAL_AS
2019-05-07 09:01:32 +02:00
#define LOCAL_VK
#define LOCAL_AS
#define KERNEL_FQ
2019-04-25 14:45:17 +02:00
#elif defined IS_CUDA
2019-05-06 14:34:16 +02:00
#define CONSTANT_VK __constant__
2019-04-25 14:45:17 +02:00
#define CONSTANT_AS
#define GLOBAL_AS
2019-05-07 09:01:32 +02:00
#define LOCAL_VK __shared__
2019-04-25 14:45:17 +02:00
#define LOCAL_AS
#define KERNEL_FQ extern "C" __global__
2019-04-25 14:45:17 +02:00
#elif defined IS_OPENCL
2019-05-06 14:34:16 +02:00
#define CONSTANT_VK __constant
#define CONSTANT_AS __constant
#define GLOBAL_AS __global
2019-05-07 09:01:32 +02:00
#define LOCAL_VK __local
#define LOCAL_AS __local
#define KERNEL_FQ __kernel
#endif
#ifndef MAYBE_VOLATILE
#define MAYBE_VOLATILE
#endif
#ifndef MAYBE_UNUSED
#define MAYBE_UNUSED
#endif
/**
* device type
*/
#define DEVICE_TYPE_CPU 2
#define DEVICE_TYPE_GPU 4
#define DEVICE_TYPE_ACCEL 8
#if DEVICE_TYPE == DEVICE_TYPE_CPU
#define IS_CPU
#elif DEVICE_TYPE == DEVICE_TYPE_GPU
#define IS_GPU
#elif DEVICE_TYPE == DEVICE_TYPE_ACCEL
#define IS_ACCEL
#endif
2015-12-04 15:47:52 +01:00
/**
* vendor specific
*/
#if VENDOR_ID == (1 << 0)
2015-12-04 15:47:52 +01:00
#define IS_AMD
2016-05-14 19:45:51 +02:00
#elif VENDOR_ID == (1 << 1)
#define IS_APPLE
#define IS_GENERIC
#elif VENDOR_ID == (1 << 2)
#define IS_INTEL_BEIGNET
#define IS_GENERIC
#elif VENDOR_ID == (1 << 3)
#define IS_INTEL_SDK
#define IS_GENERIC
#elif VENDOR_ID == (1 << 4)
#define IS_MESA
#define IS_GENERIC
#elif VENDOR_ID == (1 << 5)
2015-12-04 15:47:52 +01:00
#define IS_NV
2016-05-14 19:45:51 +02:00
#elif VENDOR_ID == (1 << 6)
#define IS_POCL
#define IS_GENERIC
#else
#define IS_GENERIC
#endif
#if defined IS_AMD && HAS_VPERM == 1
#define IS_ROCM
#endif
#define LOCAL_MEM_TYPE_LOCAL 1
#define LOCAL_MEM_TYPE_GLOBAL 2
#if LOCAL_MEM_TYPE == LOCAL_MEM_TYPE_LOCAL
#define REAL_SHM
#endif
#ifdef REAL_SHM
#define SHM_TYPE LOCAL_AS
#else
#define SHM_TYPE CONSTANT_AS
#endif
/**
* function declarations can have a large influence depending on the opencl runtime
* fast but pure kernels on rocm is a good example
*/
2018-02-08 09:49:59 +01:00
#if defined IS_CPU
#define DECLSPEC inline
2018-02-08 09:49:59 +01:00
#elif defined IS_GPU
#if defined IS_AMD
#define DECLSPEC inline static
#else
#define DECLSPEC
#endif
#else
2018-02-08 09:42:59 +01:00
#define DECLSPEC
#endif
2015-12-04 15:47:52 +01:00
/**
* AMD specific
*/
#ifdef IS_AMD
#if defined(cl_amd_media_ops)
#pragma OPENCL EXTENSION cl_amd_media_ops : enable
#endif
#if defined(cl_amd_media_ops2)
2015-12-04 15:47:52 +01:00
#pragma OPENCL EXTENSION cl_amd_media_ops2 : enable
#endif
#endif
2015-12-04 15:47:52 +01:00
// Whitelist some OpenCL specific functions
// This could create more stable kernels on systems with bad OpenCL drivers
#ifdef IS_CUDA
#define USE_BITSELECT
#define USE_ROTATE
#endif
#ifdef IS_ROCM
#define USE_BITSELECT
#define USE_ROTATE
#endif
#ifdef IS_OPENCL
//#define USE_BITSELECT
//#define USE_ROTATE
//#define USE_SWIZZLE
#endif
#endif