P4 to Git Change 2024454 by axie@axie-hip-rocm on 2019/11/04 14:38:31
SWDEV-198863 - Options for hip-clang-vdi path to provide the chicken bits, or functional equivalents to HCC_DB (phase 1)
1. The log macros is turned off for release build. So log functions has zero impact to release build.
2. The log macros have level, mask, condition control. So we can have more control to avoid log flooding.
I also adjusted some existing log to use new log functions.
1. To excercise and test the new log functions.
2. To improve performance slightly.
3. The change is mainly for HIP-ROCM, we can move more in next phases for PAL or ORCA.
4. I make these log feature unavailable for release build. We can revert to old log functions for release build in a case by case method.
Tests:
1. http://ocltc.amd.com:8111/viewModification.html?modId=128289&personal=true&tab=vcsModificationBuilds
http://ocltc.amd.com:8111/viewModification.html?modId=128358&personal=true&tab=vcsModificationBuilds
2. release build, run hip program, there is no log
3. fastdebug build, run hip program,
export LOG_LEVEL=3
export GPU_LOG_MASK=4294967295
There was a lot of logs.
4. fastdebug build, run hip program,
export LOG_LEVEL=2
export GPU_LOG_MASK=4294967295
There was no logs.
5. fastdebug build, run hip program,
export LOG_LEVEL=3
export GPU_LOG_MASK=4294967294
There was much less logs.
6. fastdebug build, run hip program,
export LOG_LEVEL=3
export GPU_LOG_MASK=47102
There was even much less logs. The logs was expected according to the mask.
7. Tested step 2 to 6 similarily in Windows and Linux
ReviewBoard: http://ocltc.amd.com/reviews/r/18215
Affected files ...
... //depot/stg/opencl/drivers/opencl/api/hip/hip_internal.hpp#46 edit
... //depot/stg/opencl/drivers/opencl/api/hip/hip_memory.cpp#82 edit
... //depot/stg/opencl/drivers/opencl/api/hip/hip_stream.cpp#26 edit
... //depot/stg/opencl/drivers/opencl/api/hip/hiprtc_internal.hpp#2 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_svm.cpp#29 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/comgrctx.cpp#6 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/devkernel.cpp#29 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/devprogram.cpp#68 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#137 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocvirtual.cpp#91 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/command.cpp#100 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/commandqueue.cpp#32 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/runtime.cpp#40 edit
... //depot/stg/opencl/drivers/opencl/runtime/utils/debug.hpp#10 edit
... //depot/stg/opencl/drivers/opencl/runtime/utils/flags.hpp#323 edit
[ROCm/clr commit: 3f6e18bf6b]
Bu işleme şunda yer alıyor:
@@ -13,7 +13,7 @@ bool Comgr::is_ready_ = false;
|
||||
|
||||
bool Comgr::LoadLib() {
|
||||
#if defined(COMGR_DYN_DLL)
|
||||
LogInfo("Loading COMGR library.");
|
||||
ClPrint(amd::LOG_INFO, amd::LOG_CODE, "Loading COMGR library.");
|
||||
static const char* ComgrLibName =
|
||||
LP64_SWITCH(WINDOWS_SWITCH("amd_comgr32.dll", "libamd_comgr32.so"),
|
||||
WINDOWS_SWITCH("amd_comgr.dll", "libamd_comgr.so"));
|
||||
|
||||
@@ -1731,7 +1731,7 @@ void Kernel::InitPrintf(const std::vector<std::string>& printfInfoStrings) {
|
||||
} while (end != std::string::npos);
|
||||
|
||||
if (tokens.size() < 2) {
|
||||
LogPrintfWarning("Invalid PrintInfo string: \"%s\"", str.c_str());
|
||||
ClPrint(amd::LOG_WARNING, amd::LOG_KERN, "Invalid PrintInfo string: \"%s\"", str.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1747,7 +1747,7 @@ void Kernel::InitPrintf(const std::vector<std::string>& printfInfoStrings) {
|
||||
|
||||
// ensure that we have the correct number of tokens
|
||||
if (tokens.size() < end + 1 /*last token is the fmtString*/) {
|
||||
LogPrintfWarning("Invalid PrintInfo string: \"%s\"", str.c_str());
|
||||
ClPrint(amd::LOG_WARNING, amd::LOG_KERN, "Invalid PrintInfo string: \"%s\"", str.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1398,7 +1398,7 @@ static void dumpCodeObject(const std::string& image) {
|
||||
char fname[30];
|
||||
static std::atomic<int> index;
|
||||
sprintf(fname, "_code_object%04d.o", index++);
|
||||
LogPrintfInfo("Code object saved in %s\n", fname);
|
||||
ClPrint(amd::LOG_INFO, amd::LOG_CODE, "Code object saved in %s\n", fname);
|
||||
std::ofstream ofs;
|
||||
ofs.open(fname, std::ios::binary);
|
||||
ofs << image;
|
||||
@@ -2905,7 +2905,7 @@ bool Program::createKernelMetadataMap() {
|
||||
|
||||
status = amd::Comgr::metadata_lookup(metadata_, "Kernels", &kernelsMD);
|
||||
if (status == AMD_COMGR_STATUS_SUCCESS) {
|
||||
LogInfo("Using Code Object V2.");
|
||||
ClPrint(amd::LOG_INFO, amd::LOG_CODE, "Using Code Object V2.");
|
||||
hasKernelMD = true;
|
||||
codeObjectVer_ = 2;
|
||||
}
|
||||
@@ -2913,7 +2913,7 @@ bool Program::createKernelMetadataMap() {
|
||||
status = amd::Comgr::metadata_lookup(metadata_, "amdhsa.kernels", &kernelsMD);
|
||||
|
||||
if (status == AMD_COMGR_STATUS_SUCCESS) {
|
||||
LogInfo("Using Code Object V3.");
|
||||
ClPrint(amd::LOG_INFO, amd::LOG_CODE, "Using Code Object V3.");
|
||||
hasKernelMD = true;
|
||||
codeObjectVer_ = 3;
|
||||
}
|
||||
|
||||
@@ -396,7 +396,7 @@ void Device::XferBuffers::release(VirtualGPU& gpu, Memory& buffer) {
|
||||
}
|
||||
|
||||
bool Device::init() {
|
||||
LogInfo("Initializing HSA stack.");
|
||||
ClPrint(amd::LOG_INFO, amd::LOG_INIT, "Initializing HSA stack.");
|
||||
|
||||
// Initialize the compiler
|
||||
if (!initCompiler(offlineDevice_)) {
|
||||
@@ -469,7 +469,7 @@ bool Device::init() {
|
||||
}
|
||||
// If the AmdDeviceInfo for the HsaDevice Id could not be found return false
|
||||
if (id == HSA_INVALID_DEVICE_ID) {
|
||||
LogPrintfWarning("Could not find a DeviceInfo entry for %d", deviceId);
|
||||
ClPrint(amd::LOG_WARNING, amd::LOG_INIT, "Could not find a DeviceInfo entry for %d", deviceId);
|
||||
continue;
|
||||
}
|
||||
roc_device->deviceInfo_ = DeviceInfo[id];
|
||||
@@ -1835,8 +1835,8 @@ bool Device::SetClockMode(const cl_set_device_clock_mode_input_amd setClockModeI
|
||||
|
||||
hsa_queue_t *Device::acquireQueue(uint32_t queue_size_hint) {
|
||||
assert(queuePool_.size() <= GPU_MAX_HW_QUEUES);
|
||||
LogPrintfInfo("number of allocated hardware queues: %d, maximum: %d",
|
||||
queuePool_.size(), GPU_MAX_HW_QUEUES);
|
||||
ClPrint(amd::LOG_INFO, amd::LOG_QUEUE, "number of allocated hardware queues: %d, maximum: %d",
|
||||
queuePool_.size(), GPU_MAX_HW_QUEUES);
|
||||
|
||||
// If we have reached the max number of queues, reuse an existing queue,
|
||||
// choosing the one with the least number of users.
|
||||
@@ -1846,7 +1846,7 @@ hsa_queue_t *Device::acquireQueue(uint32_t queue_size_hint) {
|
||||
[] (PoolRef A, PoolRef B) {
|
||||
return A.second.refCount < B.second.refCount;
|
||||
});
|
||||
LogPrintfInfo("selected queue with least refCount: %p (%d)",
|
||||
ClPrint(amd::LOG_INFO, amd::LOG_QUEUE, "selected queue with least refCount: %p (%d)",
|
||||
lowest->first, lowest->second.refCount);
|
||||
lowest->second.refCount++;
|
||||
return lowest->first;
|
||||
@@ -1870,7 +1870,7 @@ hsa_queue_t *Device::acquireQueue(uint32_t queue_size_hint) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
LogPrintfInfo("created hardware queue %p with size %d",
|
||||
ClPrint(amd::LOG_INFO, amd::LOG_QUEUE, "created hardware queue %p with size %d",
|
||||
queue, queue_size);
|
||||
hsa_amd_profiling_set_profiler_enabled(queue, 1);
|
||||
auto result = queuePool_.emplace(std::make_pair(queue, QueueInfo()));
|
||||
@@ -1890,7 +1890,7 @@ void Device::releaseQueue(hsa_queue_t* queue) {
|
||||
if (qInfo.refCount != 0) {
|
||||
return;
|
||||
}
|
||||
LogPrintfInfo("deleting hardware queue %p with refCount 0", queue);
|
||||
ClPrint(amd::LOG_INFO, amd::LOG_QUEUE, "deleting hardware queue %p with refCount 0", queue);
|
||||
|
||||
hsa_queue_destroy(queue);
|
||||
queuePool_.erase(qIter);
|
||||
|
||||
@@ -300,7 +300,7 @@ bool VirtualGPU::processMemObjects(const amd::Kernel& kernel, const_address para
|
||||
gpuMem->syncCacheFromHost(*this);
|
||||
}
|
||||
const void* globalAddress = *reinterpret_cast<const void* const*>(params + desc.offset_);
|
||||
LogPrintfInfo("!\targ%d: %s %s = ptr:%p obj:[%p-%p] threadId : %zx\n", index,
|
||||
ClPrint(amd::LOG_INFO, amd::LOG_KERN, "!\targ%d: %s %s = ptr:%p obj:[%p-%p] threadId : %zx\n", index,
|
||||
desc.typeName_.c_str(), desc.name_.c_str(),
|
||||
globalAddress, gpuMem->getDeviceMemory(),
|
||||
reinterpret_cast<address>(gpuMem->getDeviceMemory()) + mem->getSize(),
|
||||
@@ -2034,7 +2034,7 @@ bool VirtualGPU::submitKernelInternal(const amd::NDRangeContainer& sizes, const
|
||||
return false;
|
||||
}
|
||||
|
||||
LogPrintfInfo("[%zx]!\tShaderName : %s\n", std::this_thread::get_id(), gpuKernel.name().c_str());
|
||||
ClPrint(amd::LOG_INFO, amd::LOG_KERN, "[%zx]!\tShaderName : %s\n", std::this_thread::get_id(), gpuKernel.name().c_str());
|
||||
|
||||
// Check if runtime has to setup hidden arguments
|
||||
for (uint32_t i = signature.numParameters(); i < signature.numParametersAll(); ++i) {
|
||||
|
||||
Yeni konuda referans
Bir kullanıcı engelle