Files
rocm-systems/rocclr/runtime/device/cpu/cpusettings.cpp
T
foreman b6c34a714c P4 to Git Change 1191432 by yaxunl@yaxunl_stg_win50 on 2015/09/16 17:16:06
ECR #354633 - SPIR-V: Rename clCreateProgramWithIL as clCreateProgramWithILKHR and define it as an extension API.
	Add API to OCL 1.2/2.1.
	Add cl_khr_il_program extension.
	Fix SPIR-V conformance and ocltst.

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/amdocl.def.in#15 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/amdocl.map.in#18 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_context.cpp#44 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_icd.cpp#24 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_icd_amd.h#17 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_program.cpp#37 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/headers/opencl1.2/CL/cl_ext.h#9 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl.h#21 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl_ext.h#16 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/headers/opencl2.1/CL/cl.h#3 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/icd/OpenCL.def.in#12 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/icd/icd_dispatch.c#28 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/icd/icd_dispatch.h#23 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/icd/icd_exports.map.in#8 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/cpu/cpusettings.cpp#30 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#252 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/hsa/hsasettings.cpp#37 edit
... //depot/stg/opencl/drivers/opencl/tests/conformance/devel/2.0/test_conformance/spirv/main.cpp#7 edit
... //depot/stg/opencl/drivers/opencl/tests/conformance/devel/2.0/test_conformance/spirv/run_services.cpp#3 edit
... //depot/stg/opencl/drivers/opencl/tests/ocltst/module/spir/SPIRVBasic.cpp#3 edit
2015-09-16 17:29:07 -04:00

107 righe
3.2 KiB
C++

//
// Copyright 2011 Advanced Micro Devices, Inc. All rights reserved.
//
#include "device/cpu/cpusettings.hpp"
#include "os/os.hpp"
namespace cpu {
bool
Settings::create()
{
largeHostMemAlloc_ = true;
// This code is temporary until cl_khr_fp64 is unconditional
if (flagIsDefault(CL_KHR_FP64) || CL_KHR_FP64) {
enableExtension(ClKhrFp64);
}
enableExtension(ClAmdFp64);
enableExtension(ClKhrGlobalInt32BaseAtomics);
enableExtension(ClKhrGlobalInt32ExtendedAtomics);
enableExtension(ClKhrLocalInt32BaseAtomics);
enableExtension(ClKhrLocalInt32ExtendedAtomics);
#ifdef _LP64
enableExtension(ClKhrInt64BaseAtomics);
enableExtension(ClKhrInt64ExtendedAtomics);
#endif // _LP64
enableExtension(ClKhrByteAddressableStore);
enableExtension(ClKhrGlSharing);
enableExtension(ClKhrGlEvent);
enableExtension(ClExtDeviceFission);
enableExtension(ClAmdDeviceAttributeQuery);
enableExtension(ClAmdVec3);
enableExtension(ClAmdMediaOps);
enableExtension(ClAmdMediaOps2);
enableExtension(ClAmdPopcnt);
enableExtension(ClAmdPrintf);
// enableExtension(ClKhrSelectFpRoundingMode);
enableExtension(ClKhr3DImageWrites);
// enableExtension(ClKhrFp16);
#if defined(_WIN32)
enableExtension(ClKhrD3d10Sharing);
#endif // _WIN32
enableExtension(ClKhrSpir);
enableExtension(ClKhrIlProgram);
// Enable some OpenCL 2.0 extensions
if ((OPENCL_MAJOR >= 2) && (CPU_OPENCL_VERSION >= 200)) {
partialDispatch_ = true;
enableExtension(ClKhrSubGroups);
supportDepthsRGB_ = true;
enableExtension(ClKhrDepthImages);
}
// Map CPUID feature bits to our own feature bits
const int sse2_features = CPUFEAT_DX_SSE | CPUFEAT_DX_SSE2;
const int avx_features = CPUFEAT_CX_SSE3 | CPUFEAT_CX_SSSE3 |
CPUFEAT_CX_SSE4_1 | CPUFEAT_CX_SSE4_2 |
CPUFEAT_CX_POPCNT | CPUFEAT_CX_AVX |
CPUFEAT_CX_OSXSAVE;
const int fma3_features = INTEL_CPUFEAT_CX_FMA3;
const int fma4_features = AMD_CPUFEAT_CX_FMA4 | AMD_CPUFEAT_CX_XOP;
int regs[4];
#if defined(ATI_ARCH_X86)
amd::Os::cpuid(regs, 0x0);
bool isAmd = regs[1] == ('A' | ('u' << 8) | ('t' << 16) | ('h' << 24));
bool isIntel = regs[1] == ('G' | ('e' << 8) | ('n' << 16) | ('u' << 24));
amd::Os::cpuid(regs, 0x1);
cpuFeatures_ = (regs[3] & sse2_features) == sse2_features ?
SSE2Instructions : 0;
if ((regs[2] & avx_features) == avx_features) {
// Check for state support
uint64_t xcr0 = amd::Os::xgetbv(0);
// Check for SSE and YMM bits (1 and 2)
if (((uint32_t)xcr0 & 0x6U) == 0x6U) {
cpuFeatures_ |= AVXInstructions;
// Now check for FMA and XOP
if (isIntel) {
cpuFeatures_ |= (regs[2] & fma3_features) == fma3_features ?
FMA3Instructions : 0;
}
if (isAmd) {
amd::Os::cpuid(regs, 0x80000001);
cpuFeatures_ |= (regs[2] & fma4_features) == fma4_features ?
FMA4Instructions : 0;
}
}
}
#endif // ATI_ARCH_X86
return true;
}
} // namespace cpu