Permalink
Browse files

Add support to run under Mesa clover

- add platform vendor for Mesa
- modify kernel to run under Mesa clover (OpenCL 1.1)
  • Loading branch information...
kitsook committed Feb 12, 2018
1 parent 2ae7260 commit dbcc7552247dc3ea79e9ad6298de45ed68e59df0
Showing with 57 additions and 1 deletion.
  1. +1 −1 xmrstak/backend/amd/amd_gpu/gpu.cpp
  2. +56 −0 xmrstak/backend/amd/amd_gpu/opencl/cryptonight.cl
@@ -559,7 +559,7 @@ int getAMDPlatformIdx()
clGetPlatformInfo(platforms[i], CL_PLATFORM_VENDOR, infoSize, platformNameVec.data(), NULL);
std::string platformName(platformNameVec.data());
if( platformName.find("Advanced Micro Devices") != std::string::npos || platformName.find("Apple") != std::string::npos)
if( platformName.find("Advanced Micro Devices") != std::string::npos || platformName.find("Apple") != std::string::npos || platformName.find("Mesa") != std::string::npos)
{
platformIndex = i;
printer::inst()->print_msg(L0,"Found AMD platform index id = %i, name = %s",i , platformName.c_str());
@@ -14,6 +14,62 @@ R"===(
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* For Mesa clover support */
#ifdef cl_clang_storage_class_specifiers
#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers : enable
/* taken from https://www.khronos.org/registry/OpenCL/extensions/amd/cl_amd_media_ops.txt
* Build-in Function
* uintn amd_bitalign (uintn src0, uintn src1, uintn src2)
* Description
* dst.s0 = (uint) (((((long)src0.s0) << 32) | (long)src1.s0) >> (src2.s0 & 31))
* similar operation applied to other components of the vectors.
*
* The implemented function is modified because the last is in our case always a scalar.
* We can ignore the bitwise AND operation.
*/
inline uint2 amd_bitalign( const uint2 src0, const uint2 src1, const uint src2)
{
uint2 result;
result.s0 = (uint) (((((long)src0.s0) << 32) | (long)src1.s0) >> (src2));
result.s1 = (uint) (((((long)src0.s1) << 32) | (long)src1.s1) >> (src2));
return result;
}
/* taken from: https://www.khronos.org/registry/OpenCL/extensions/amd/cl_amd_media_ops2.txt
* Built-in Function:
* uintn amd_bfe (uintn src0, uintn src1, uintn src2)
* Description
* NOTE: operator >> below represent logical right shift
* offset = src1.s0 & 31;
* width = src2.s0 & 31;
* if width = 0
* dst.s0 = 0;
* else if (offset + width) < 32
* dst.s0 = (src0.s0 << (32 - offset - width)) >> (32 - width);
* else
* dst.s0 = src0.s0 >> offset;
* similar operation applied to other components of the vectors
*/
inline int amd_bfe(const uint src0, const uint offset, const uint width)
{
/* casts are removed because we can implement everything as uint
* int offset = src1;
* int width = src2;
* remove check for edge case, this function is always called with
* `width==8`
* @code
* if ( width == 0 )
* return 0;
* @endcode
*/
if ( (offset + width) < 32u )
return (src0 << (32u - offset - width)) >> (32u - width);
return src0 >> offset;
}
#endif /* end Mesa clover support */
#ifdef cl_amd_media_ops
#pragma OPENCL EXTENSION cl_amd_media_ops : enable
#else

0 comments on commit dbcc755

Please sign in to comment.