Adjust clang format to the new versions, revert broken macro layout (#714)
This commit is contained in:
1 parent
ed877433f3
commit
2ff2316227
189 files changed
+1906
-2418
No files matched your search
@@ -376,8 +376,8 @@ hsa_ven_amd_loader_1_00_pfn_t Device::amd_loader_ext_table = {nullptr};
|
||||
|
||||
hsa_status_t Device::loaderQueryHostAddress(const void* device, const void** host) {
|
||||
return amd_loader_ext_table.hsa_ven_amd_loader_query_host_address
|
||||
? amd_loader_ext_table.hsa_ven_amd_loader_query_host_address(device, host)
|
||||
: HSA_STATUS_ERROR;
|
||||
? amd_loader_ext_table.hsa_ven_amd_loader_query_host_address(device, host)
|
||||
: HSA_STATUS_ERROR;
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
@@ -413,9 +413,9 @@ bool Device::init() {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string ordinals = amd::IS_HIP
|
||||
? ((HIP_VISIBLE_DEVICES[0] != '\0') ? HIP_VISIBLE_DEVICES : CUDA_VISIBLE_DEVICES)
|
||||
: GPU_DEVICE_ORDINAL;
|
||||
std::string ordinals =
|
||||
amd::IS_HIP ? ((HIP_VISIBLE_DEVICES[0] != '\0') ? HIP_VISIBLE_DEVICES : CUDA_VISIBLE_DEVICES)
|
||||
: GPU_DEVICE_ORDINAL;
|
||||
if (ordinals[0] != '\0') {
|
||||
size_t pos = 0;
|
||||
std::vector<hsa_agent_t> valid_agents;
|
||||
@@ -573,9 +573,9 @@ bool Device::create() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (HSA_STATUS_SUCCESS !=
|
||||
hsa_agent_get_info(bkendDevice_, (hsa_agent_info_t)HSA_AMD_AGENT_INFO_CHIP_ID,
|
||||
&pciDeviceId_)) {
|
||||
if (HSA_STATUS_SUCCESS != hsa_agent_get_info(bkendDevice_,
|
||||
(hsa_agent_info_t)HSA_AMD_AGENT_INFO_CHIP_ID,
|
||||
&pciDeviceId_)) {
|
||||
LogPrintfError("Unable to get PCI ID of HSA device %s", agent_name);
|
||||
return false;
|
||||
}
|
||||
@@ -584,35 +584,34 @@ bool Device::create() {
|
||||
uint count;
|
||||
hsa_isa_t first_isa;
|
||||
} agent_isas = {0, {0}};
|
||||
if (HSA_STATUS_SUCCESS !=
|
||||
hsa_agent_iterate_isas(
|
||||
bkendDevice_,
|
||||
[](hsa_isa_t isa, void* data) {
|
||||
agent_isas_t* agent_isas = static_cast<agent_isas_t*>(data);
|
||||
if (agent_isas->count++ == 0) {
|
||||
agent_isas->first_isa = isa;
|
||||
}
|
||||
return HSA_STATUS_SUCCESS;
|
||||
},
|
||||
&agent_isas)) {
|
||||
if (HSA_STATUS_SUCCESS != hsa_agent_iterate_isas(
|
||||
bkendDevice_,
|
||||
[](hsa_isa_t isa, void* data) {
|
||||
agent_isas_t* agent_isas = static_cast<agent_isas_t*>(data);
|
||||
if (agent_isas->count++ == 0) {
|
||||
agent_isas->first_isa = isa;
|
||||
}
|
||||
return HSA_STATUS_SUCCESS;
|
||||
},
|
||||
&agent_isas)) {
|
||||
LogPrintfError("Unable to iterate supported ISAs for HSA device %s (PCI ID %x)", agent_name,
|
||||
pciDeviceId_);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t isa_name_length = 0;
|
||||
if (HSA_STATUS_SUCCESS !=
|
||||
hsa_isa_get_info_alt(agent_isas.first_isa, (hsa_isa_info_t)HSA_ISA_INFO_NAME_LENGTH,
|
||||
&isa_name_length)) {
|
||||
if (HSA_STATUS_SUCCESS != hsa_isa_get_info_alt(agent_isas.first_isa,
|
||||
(hsa_isa_info_t)HSA_ISA_INFO_NAME_LENGTH,
|
||||
&isa_name_length)) {
|
||||
LogPrintfError("Unable to get ISA name length for HSA device %s (PCI ID %x)", agent_name,
|
||||
pciDeviceId_);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<char> isa_name(isa_name_length + 1, '\0');
|
||||
if (HSA_STATUS_SUCCESS !=
|
||||
hsa_isa_get_info_alt(agent_isas.first_isa, (hsa_isa_info_t)HSA_ISA_INFO_NAME,
|
||||
isa_name.data())) {
|
||||
if (HSA_STATUS_SUCCESS != hsa_isa_get_info_alt(agent_isas.first_isa,
|
||||
(hsa_isa_info_t)HSA_ISA_INFO_NAME,
|
||||
isa_name.data())) {
|
||||
LogPrintfError("Unable to get ISA name for HSA device %s (PCI ID %x)", agent_name,
|
||||
pciDeviceId_);
|
||||
return false;
|
||||
@@ -663,10 +662,9 @@ bool Device::create() {
|
||||
assert(!settings_);
|
||||
roc::Settings* hsaSettings = new roc::Settings();
|
||||
settings_ = hsaSettings;
|
||||
if (!hsaSettings ||
|
||||
!hsaSettings->create((agent_profile_ == HSA_PROFILE_FULL), *isa,
|
||||
isa->xnack() == amd::Isa::Feature::Enabled, coop_groups, isXgmi_,
|
||||
hasValidHDPFlush)) {
|
||||
if (!hsaSettings || !hsaSettings->create((agent_profile_ == HSA_PROFILE_FULL), *isa,
|
||||
isa->xnack() == amd::Isa::Feature::Enabled, coop_groups,
|
||||
isXgmi_, hasValidHDPFlush)) {
|
||||
LogPrintfError("Unable to create settings for HSA device %s (PCI ID %x)", agent_name,
|
||||
pciDeviceId_);
|
||||
return false;
|
||||
@@ -969,11 +967,11 @@ bool Device::createSampler(const amd::Sampler& owner, device::Sampler** sampler)
|
||||
void Sampler::fillSampleDescriptor(hsa_ext_sampler_descriptor_v2_t& samplerDescriptor,
|
||||
const amd::Sampler& sampler) const {
|
||||
samplerDescriptor.filter_mode = sampler.filterMode() == CL_FILTER_NEAREST
|
||||
? HSA_EXT_SAMPLER_FILTER_MODE_NEAREST
|
||||
: HSA_EXT_SAMPLER_FILTER_MODE_LINEAR;
|
||||
? HSA_EXT_SAMPLER_FILTER_MODE_NEAREST
|
||||
: HSA_EXT_SAMPLER_FILTER_MODE_LINEAR;
|
||||
samplerDescriptor.coordinate_mode = sampler.normalizedCoords()
|
||||
? HSA_EXT_SAMPLER_COORDINATE_MODE_NORMALIZED
|
||||
: HSA_EXT_SAMPLER_COORDINATE_MODE_UNNORMALIZED;
|
||||
? HSA_EXT_SAMPLER_COORDINATE_MODE_NORMALIZED
|
||||
: HSA_EXT_SAMPLER_COORDINATE_MODE_UNNORMALIZED;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
switch (sampler.addressingMode(i)) {
|
||||
case CL_ADDRESS_CLAMP_TO_EDGE:
|
||||
@@ -1036,9 +1034,9 @@ bool Device::populateOCLDeviceConstants() {
|
||||
|
||||
::strncpy(info_.name_, isa().targetId(), sizeof(info_.name_) - 1);
|
||||
char device_name[64] = {0};
|
||||
if (HSA_STATUS_SUCCESS ==
|
||||
hsa_agent_get_info(bkendDevice_, (hsa_agent_info_t)HSA_AMD_AGENT_INFO_PRODUCT_NAME,
|
||||
device_name)) {
|
||||
if (HSA_STATUS_SUCCESS == hsa_agent_get_info(bkendDevice_,
|
||||
(hsa_agent_info_t)HSA_AMD_AGENT_INFO_PRODUCT_NAME,
|
||||
device_name)) {
|
||||
::strncpy(info_.boardName_, device_name, sizeof(info_.boardName_) - 1);
|
||||
}
|
||||
|
||||
@@ -1075,9 +1073,9 @@ bool Device::populateOCLDeviceConstants() {
|
||||
info_.maxPhysicalComputeUnits_ = settings().enableWgpMode_ ? info_.maxPhysicalComputeUnits_ / 2
|
||||
: info_.maxPhysicalComputeUnits_;
|
||||
|
||||
if (HSA_STATUS_SUCCESS !=
|
||||
hsa_agent_get_info(bkendDevice_, (hsa_agent_info_t)HSA_AMD_AGENT_INFO_CACHELINE_SIZE,
|
||||
&info_.globalMemCacheLineSize_)) {
|
||||
if (HSA_STATUS_SUCCESS != hsa_agent_get_info(bkendDevice_,
|
||||
(hsa_agent_info_t)HSA_AMD_AGENT_INFO_CACHELINE_SIZE,
|
||||
&info_.globalMemCacheLineSize_)) {
|
||||
return false;
|
||||
}
|
||||
info_.globalMemCacheLineSize_ =
|
||||
@@ -1152,9 +1150,8 @@ bool Device::populateOCLDeviceConstants() {
|
||||
checkAtomicSupport();
|
||||
|
||||
assert(cpu_agent_info_->fine_grain_pool.handle != 0);
|
||||
if (HSA_STATUS_SUCCESS !=
|
||||
hsa_amd_agent_iterate_memory_pools(bkendDevice_, Device::iterateGpuMemoryPoolCallback,
|
||||
this)) {
|
||||
if (HSA_STATUS_SUCCESS != hsa_amd_agent_iterate_memory_pools(
|
||||
bkendDevice_, Device::iterateGpuMemoryPoolCallback, this)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1188,9 +1185,9 @@ bool Device::populateOCLDeviceConstants() {
|
||||
}
|
||||
|
||||
size_t group_segment_size = 0;
|
||||
if (HSA_STATUS_SUCCESS !=
|
||||
hsa_amd_memory_pool_get_info(group_segment_, HSA_AMD_MEMORY_POOL_INFO_SIZE,
|
||||
&group_segment_size)) {
|
||||
if (HSA_STATUS_SUCCESS != hsa_amd_memory_pool_get_info(group_segment_,
|
||||
HSA_AMD_MEMORY_POOL_INFO_SIZE,
|
||||
&group_segment_size)) {
|
||||
return false;
|
||||
}
|
||||
assert(group_segment_size > 0);
|
||||
@@ -1229,16 +1226,16 @@ bool Device::populateOCLDeviceConstants() {
|
||||
|
||||
if (settings().enableLocalMemory_ && gpuvm_segment_.handle != 0) {
|
||||
size_t global_segment_size = 0;
|
||||
if (HSA_STATUS_SUCCESS !=
|
||||
hsa_amd_memory_pool_get_info(gpuvm_segment_, HSA_AMD_MEMORY_POOL_INFO_SIZE,
|
||||
&global_segment_size)) {
|
||||
if (HSA_STATUS_SUCCESS != hsa_amd_memory_pool_get_info(gpuvm_segment_,
|
||||
HSA_AMD_MEMORY_POOL_INFO_SIZE,
|
||||
&global_segment_size)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
assert(global_segment_size > 0);
|
||||
info_.globalMemSize_ = (static_cast<uint64_t>(std::min(GPU_MAX_HEAP_SIZE, 100u)) *
|
||||
static_cast<uint64_t>(global_segment_size)) /
|
||||
100u;
|
||||
100u;
|
||||
|
||||
// For APU with vram size <= 512MiB, use a smaller single alloc percentage
|
||||
if (info_.globalMemSize_ <= 536870912) {
|
||||
@@ -1266,7 +1263,7 @@ bool Device::populateOCLDeviceConstants() {
|
||||
info_.globalMemSize_ = std::max(info_.globalMemSize_, uint64_t(1 * Gi));
|
||||
info_.globalMemSize_ = (static_cast<uint64_t>(std::min(GPU_MAX_HEAP_SIZE, 100u)) *
|
||||
static_cast<uint64_t>(info_.globalMemSize_)) /
|
||||
100u;
|
||||
100u;
|
||||
|
||||
info_.maxMemAllocSize_ =
|
||||
uint64_t(info_.globalMemSize_ * std::min(GPU_SINGLE_ALLOC_PERCENT, 100u) / 100u);
|
||||
@@ -1325,8 +1322,8 @@ bool Device::populateOCLDeviceConstants() {
|
||||
info_.hostUnifiedMemory_ = 1;
|
||||
info_.iommuv2_ = true;
|
||||
}
|
||||
info_.memBaseAddrAlign_ = 8 *
|
||||
(flagIsDefault(MEMOBJ_BASE_ADDR_ALIGN) ? sizeof(int64_t[16]) * 2 : MEMOBJ_BASE_ADDR_ALIGN);
|
||||
info_.memBaseAddrAlign_ = 8 * (flagIsDefault(MEMOBJ_BASE_ADDR_ALIGN) ? sizeof(int64_t[16]) * 2
|
||||
: MEMOBJ_BASE_ADDR_ALIGN);
|
||||
info_.minDataTypeAlignSize_ = sizeof(int64_t[16]);
|
||||
|
||||
info_.maxConstantArgs_ = 8;
|
||||
@@ -1629,14 +1626,14 @@ bool Device::populateOCLDeviceConstants() {
|
||||
if (getIsaMeta(std::move(isa().isaName()), isaMeta)) {
|
||||
std::string addressableNumVGPRs, totalNumVGPRs, vGPRAllocGranule;
|
||||
info_.availableVGPRs_ = getValueFromIsaMeta(isaMeta, "AddressableNumVGPRs", addressableNumVGPRs)
|
||||
? atoi(addressableNumVGPRs.c_str())
|
||||
: 0;
|
||||
? atoi(addressableNumVGPRs.c_str())
|
||||
: 0;
|
||||
info_.vgprsPerSimd_ = getValueFromIsaMeta(isaMeta, "TotalNumVGPRs", totalNumVGPRs)
|
||||
? atoi(totalNumVGPRs.c_str())
|
||||
: 0;
|
||||
? atoi(totalNumVGPRs.c_str())
|
||||
: 0;
|
||||
info_.vgprAllocGranularity_ = getValueFromIsaMeta(isaMeta, "VGPRAllocGranule", vGPRAllocGranule)
|
||||
? atoi(vGPRAllocGranule.c_str())
|
||||
: 0;
|
||||
? atoi(vGPRAllocGranule.c_str())
|
||||
: 0;
|
||||
|
||||
info_.availableRegistersPerCU_ = info_.vgprsPerSimd_ * info_.simdPerCU_ * info_.wavefrontWidth_;
|
||||
ClPrint(amd::LOG_INFO, amd::LOG_INIT,
|
||||
@@ -1647,8 +1644,8 @@ bool Device::populateOCLDeviceConstants() {
|
||||
|
||||
std::string sgprValue;
|
||||
info_.availableSGPRs_ = (getValueFromIsaMeta(isaMeta, "AddressableNumSGPRs", sgprValue))
|
||||
? (atoi(sgprValue.c_str()))
|
||||
: 0;
|
||||
? (atoi(sgprValue.c_str()))
|
||||
: 0;
|
||||
if (!releaseIsaMeta(isaMeta)) {
|
||||
LogInfo("Can not release the isa meta node");
|
||||
}
|
||||
@@ -1663,9 +1660,8 @@ bool Device::populateOCLDeviceConstants() {
|
||||
}
|
||||
|
||||
// This capability should be available with xnack enabled
|
||||
if (HSA_STATUS_SUCCESS !=
|
||||
hsa_system_get_info(HSA_AMD_SYSTEM_INFO_SVM_ACCESSIBLE_BY_DEFAULT,
|
||||
&info_.hmmCpuMemoryAccessible_)) {
|
||||
if (HSA_STATUS_SUCCESS != hsa_system_get_info(HSA_AMD_SYSTEM_INFO_SVM_ACCESSIBLE_BY_DEFAULT,
|
||||
&info_.hmmCpuMemoryAccessible_)) {
|
||||
LogError("HSA_AMD_SYSTEM_INFO_SVM_ACCESSIBLE_BY_DEFAULT query failed.");
|
||||
}
|
||||
|
||||
@@ -1805,9 +1801,9 @@ bool Device::bindExternalDevice(uint flags, void* const gfxDevice[], void* gfxCo
|
||||
}
|
||||
|
||||
return info_.deviceTopology_.pcie.bus == info.pci_bus &&
|
||||
info_.deviceTopology_.pcie.device == info.pci_device &&
|
||||
info_.deviceTopology_.pcie.function == info.pci_function &&
|
||||
info_.vendorId_ == info.vendor_id && pciDeviceId_ == info.device_id;
|
||||
info_.deviceTopology_.pcie.device == info.pci_device &&
|
||||
info_.deviceTopology_.pcie.function == info.pci_function &&
|
||||
info_.vendorId_ == info.vendor_id && pciDeviceId_ == info.device_id;
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -2224,10 +2220,10 @@ void Device::releaseMemory(void* ptr, size_t size) const {
|
||||
|
||||
void* Device::deviceLocalAlloc(size_t size, bool atomics, bool pseudo_fine_grain,
|
||||
bool contiguous) const {
|
||||
const hsa_amd_memory_pool_t& pool = (pseudo_fine_grain && gpu_ext_fine_grained_segment_.handle)
|
||||
? gpu_ext_fine_grained_segment_
|
||||
: (atomics && gpu_fine_grained_segment_.handle) ? gpu_fine_grained_segment_
|
||||
: gpuvm_segment_;
|
||||
const hsa_amd_memory_pool_t& pool =
|
||||
(pseudo_fine_grain && gpu_ext_fine_grained_segment_.handle) ? gpu_ext_fine_grained_segment_
|
||||
: (atomics && gpu_fine_grained_segment_.handle) ? gpu_fine_grained_segment_
|
||||
: gpuvm_segment_;
|
||||
|
||||
if (pool.handle == 0 || gpuvm_segment_max_alloc_ == 0) {
|
||||
DevLogPrintfError("Invalid argument, pool_handle: 0x%x , max_alloc: %u \n", pool.handle,
|
||||
@@ -2474,9 +2470,8 @@ bool Device::SetSvmAttributesInt(const void* dev_ptr, size_t count, amd::MemoryA
|
||||
amd::Memory* svm_mem = amd::MemObjMap::FindMemObj(dev_ptr);
|
||||
if ((nullptr == svm_mem) || ((svm_mem->getMemFlags() & CL_MEM_ALLOC_HOST_PTR) == 0) ||
|
||||
// Validate the range of provided memory
|
||||
((svm_mem->getSize() -
|
||||
(reinterpret_cast<const_address>(dev_ptr) -
|
||||
reinterpret_cast<address>(svm_mem->getSvmPtr()))) < count)) {
|
||||
((svm_mem->getSize() - (reinterpret_cast<const_address>(dev_ptr) -
|
||||
reinterpret_cast<address>(svm_mem->getSvmPtr()))) < count)) {
|
||||
LogPrintfError("SetSvmAttributes received unknown memory for update: %p!", dev_ptr);
|
||||
return false;
|
||||
}
|
||||
@@ -2565,9 +2560,8 @@ bool Device::GetSvmAttributes(void** data, size_t* data_sizes, int* attributes,
|
||||
amd::Memory* svm_mem = amd::MemObjMap::FindMemObj(dev_ptr);
|
||||
if ((nullptr == svm_mem) || ((svm_mem->getMemFlags() & CL_MEM_ALLOC_HOST_PTR) == 0) ||
|
||||
// Validate the range of provided memory
|
||||
((svm_mem->getSize() -
|
||||
(reinterpret_cast<const_address>(dev_ptr) -
|
||||
reinterpret_cast<address>(svm_mem->getSvmPtr()))) < count)) {
|
||||
((svm_mem->getSize() - (reinterpret_cast<const_address>(dev_ptr) -
|
||||
reinterpret_cast<address>(svm_mem->getSvmPtr()))) < count)) {
|
||||
LogPrintfError("GetSvmAttributes received unknown memory %p for state!", dev_ptr);
|
||||
return false;
|
||||
}
|
||||
@@ -3493,9 +3487,8 @@ bool Device::IsValidAllocation(const void* dev_ptr, size_t size, hsa_amd_pointer
|
||||
}
|
||||
|
||||
if (ptr_info->type != HSA_EXT_POINTER_TYPE_UNKNOWN) {
|
||||
if ((size != 0) &&
|
||||
((reinterpret_cast<const_address>(dev_ptr) -
|
||||
reinterpret_cast<const_address>(ptr_info->agentBaseAddress)) > size)) {
|
||||
if ((size != 0) && ((reinterpret_cast<const_address>(dev_ptr) -
|
||||
reinterpret_cast<const_address>(ptr_info->agentBaseAddress)) > size)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user