Skip to content
Snippets Groups Projects
Commit 2a0d565b authored by psychocrypt's avatar psychocrypt
Browse files

fix broken AMD OpenCL compile

The AMD compiler for OpenCL shipped with the driver 14XX is broken
and can not compile xmr-stak since the monero v8 changes are introduced.

- workaround a simple compare.
- add new device define `OPENCL_DRIVER_MAJOR`
parent 9fe30b2b
No related branches found
No related tags found
No related merge requests found
......@@ -420,6 +420,11 @@ size_t InitOpenCLGpu(cl_context opencl_ctx, GpuContext* ctx, const char* source_
options += " -DMEMORY=" + std::to_string(hashMemSize);
options += " -DALGO=" + std::to_string(miner_algo[ii]);
options += " -DCN_UNROLL=" + std::to_string(ctx->unroll);
/* AMD driver output is something like: `1445.5 (VM)`
* and is mapped to `14` only. The value is only used for a compiler
* workaround.
*/
options += " -DOPENCL_DRIVER_MAJOR=" + std::to_string(std::stoi(openCLDriverVer.data()) / 100);
/* create a hash for the compile time cache
* used data:
......
......@@ -2,6 +2,10 @@ R"===(
/*
* @author SChernykh
*/
// cryptonight_monero_v8
#if(ALGO==11)
static const __constant uint RCP_C[256] =
{
0xfe01be73u,0xfd07ff01u,0xfa118c5au,0xf924fb13u,0xf630cddbu,0xf558f73cu,0xf25f2934u,0xf1a3f37bu,
......@@ -68,9 +72,19 @@ inline uint2 fast_div_v2(const __local uint *RCP, ulong a, uint b)
const ulong k = mul_hi(as_uint2(a).s0, r) + ((ulong)(r) * as_uint2(a).s1) + a;
ulong q;
((uint*)&q)[0] = as_uint2(k).s1;;
((uint*)&q)[1] = (k < a) ? 1 : 0;
((uint*)&q)[0] = as_uint2(k).s1;
#if defined(cl_amd_device_attribute_query) && (OPENCL_DRIVER_MAJOR == 14)
/* The AMD driver 14.XX is not able to compile `(k < a)`
* https://github.com/fireice-uk/xmr-stak/issues/1922
* This is a workaround for the broken compiler.
*/
const long xx = k - a;
((uint*)&q)[1] = (xx < 0) ? 1U : 0U;
#else
((uint*)&q)[1] = (k < a) ? 1U : 0U;
#endif
const long tmp = a - q * b;
const bool overshoot = (tmp < 0);
const bool undershoot = (tmp >= b);
......@@ -105,4 +119,7 @@ inline uint fast_sqrt_v2(const ulong n1)
return result;
}
#endif
)==="
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment