kfdtest: Style cleanup
Clean up the KFDTest style via CPPLint. Some warnings remain regarding
volatile variables being cast to void*. This is the command used:
cpplint.py --linelength=120
--filter=-readability/multiline_string,-readability/todo,-build/include,-runtime/references
multiline_string is due to using ISA code
todo is to avoid errors that we don't have TODO(username) instead of TODO
include is about including the folder in the header includes
references is regarding non-const references '&' being const or using
pointers. That can be addressed later
Change-Id: I3c6622da0a13dd33ab29b2bfff48be25e763b750
[ROCm/ROCR-Runtime commit: dffac0a97e]
This commit is contained in:
1 parent
76f3da6bd0
commit
19788ae516
33 files changed
+371
-328
No files matched your search
@@ -40,7 +40,8 @@ void KFDEvictTest::AllocBuffers(HSAuint32 defaultGPUNode, HSAuint32 count, HSAui
|
||||
|
||||
totalMB = N_PROCESSES*count*(vramBufSize>>20);
|
||||
if (m_IsParent) {
|
||||
LOG() << "Allocating " << N_PROCESSES << "*" << count << "*" << (vramBufSize>>20) << "(="<< totalMB << ")MB VRAM in KFD" << std::endl;
|
||||
LOG() << "Allocating " << N_PROCESSES << "*" << count << "*" << (vramBufSize>>20) << "(="
|
||||
<< totalMB << ")MB VRAM in KFD" << std::endl;
|
||||
}
|
||||
|
||||
HSAKMT_STATUS ret;
|
||||
@@ -95,7 +96,8 @@ void KFDEvictTest::AllocAmdgpuBo(int rn, HSAuint64 vramBufSize, amdgpu_bo_handle
|
||||
alloc.flags = AMDGPU_GEM_CREATE_VRAM_CLEARED;
|
||||
|
||||
if (m_IsParent) {
|
||||
LOG() << "Allocating " << N_PROCESSES << "*" << (vramBufSize >> 20) / N_PROCESSES << "(=" << (vramBufSize >> 20) << ")MB VRAM in GFX" << std::endl;
|
||||
LOG() << "Allocating " << N_PROCESSES << "*" << (vramBufSize >> 20) / N_PROCESSES << "(="
|
||||
<< (vramBufSize >> 20) << ")MB VRAM in GFX" << std::endl;
|
||||
}
|
||||
ASSERT_EQ(0, amdgpu_bo_alloc(m_RenderNodes[rn].device_handle, &alloc, &handle));
|
||||
}
|
||||
@@ -104,79 +106,72 @@ void KFDEvictTest::FreeAmdgpuBo(amdgpu_bo_handle handle) {
|
||||
ASSERT_EQ(0, amdgpu_bo_free(handle));
|
||||
}
|
||||
|
||||
static int
|
||||
amdgpu_bo_alloc_and_map(amdgpu_device_handle dev, unsigned size,
|
||||
unsigned alignment, unsigned heap, uint64_t flags,
|
||||
amdgpu_bo_handle *bo, void **cpu, uint64_t *mc_address,
|
||||
amdgpu_va_handle *va_handle)
|
||||
{
|
||||
struct amdgpu_bo_alloc_request request = {};
|
||||
amdgpu_bo_handle buf_handle;
|
||||
amdgpu_va_handle handle;
|
||||
uint64_t vmc_addr;
|
||||
int r;
|
||||
static int amdgpu_bo_alloc_and_map(amdgpu_device_handle dev, unsigned size,
|
||||
unsigned alignment, unsigned heap, uint64_t flags,
|
||||
amdgpu_bo_handle *bo, void **cpu, uint64_t *mc_address,
|
||||
amdgpu_va_handle *va_handle) {
|
||||
struct amdgpu_bo_alloc_request request = {};
|
||||
amdgpu_bo_handle buf_handle;
|
||||
amdgpu_va_handle handle;
|
||||
uint64_t vmc_addr;
|
||||
int r;
|
||||
|
||||
request.alloc_size = size;
|
||||
request.phys_alignment = alignment;
|
||||
request.preferred_heap = heap;
|
||||
request.flags = flags;
|
||||
request.alloc_size = size;
|
||||
request.phys_alignment = alignment;
|
||||
request.preferred_heap = heap;
|
||||
request.flags = flags;
|
||||
|
||||
r = amdgpu_bo_alloc(dev, &request, &buf_handle);
|
||||
if (r)
|
||||
return r;
|
||||
r = amdgpu_bo_alloc(dev, &request, &buf_handle);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
r = amdgpu_va_range_alloc(dev,
|
||||
amdgpu_gpu_va_range_general,
|
||||
size, alignment, 0, &vmc_addr,
|
||||
&handle, 0);
|
||||
if (r)
|
||||
goto error_va_alloc;
|
||||
r = amdgpu_va_range_alloc(dev,
|
||||
amdgpu_gpu_va_range_general,
|
||||
size, alignment, 0, &vmc_addr,
|
||||
&handle, 0);
|
||||
if (r)
|
||||
goto error_va_alloc;
|
||||
|
||||
r = amdgpu_bo_va_op(buf_handle, 0, size, vmc_addr, 0, AMDGPU_VA_OP_MAP);
|
||||
if (r)
|
||||
goto error_va_map;
|
||||
r = amdgpu_bo_va_op(buf_handle, 0, size, vmc_addr, 0, AMDGPU_VA_OP_MAP);
|
||||
if (r)
|
||||
goto error_va_map;
|
||||
|
||||
r = amdgpu_bo_cpu_map(buf_handle, cpu);
|
||||
if (r)
|
||||
goto error_cpu_map;
|
||||
r = amdgpu_bo_cpu_map(buf_handle, cpu);
|
||||
if (r)
|
||||
goto error_cpu_map;
|
||||
|
||||
*bo = buf_handle;
|
||||
*mc_address = vmc_addr;
|
||||
*va_handle = handle;
|
||||
*bo = buf_handle;
|
||||
*mc_address = vmc_addr;
|
||||
*va_handle = handle;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
error_cpu_map:
|
||||
amdgpu_bo_cpu_unmap(buf_handle);
|
||||
amdgpu_bo_cpu_unmap(buf_handle);
|
||||
|
||||
error_va_map:
|
||||
amdgpu_bo_va_op(buf_handle, 0, size, vmc_addr, 0, AMDGPU_VA_OP_UNMAP);
|
||||
amdgpu_bo_va_op(buf_handle, 0, size, vmc_addr, 0, AMDGPU_VA_OP_UNMAP);
|
||||
|
||||
error_va_alloc:
|
||||
amdgpu_bo_free(buf_handle);
|
||||
return r;
|
||||
amdgpu_bo_free(buf_handle);
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline int
|
||||
amdgpu_bo_unmap_and_free(amdgpu_bo_handle bo, amdgpu_va_handle va_handle,
|
||||
uint64_t mc_addr, uint64_t size)
|
||||
{
|
||||
amdgpu_bo_cpu_unmap(bo);
|
||||
amdgpu_bo_va_op(bo, 0, size, mc_addr, 0, AMDGPU_VA_OP_UNMAP);
|
||||
amdgpu_va_range_free(va_handle);
|
||||
amdgpu_bo_free(bo);
|
||||
|
||||
return 0;
|
||||
static inline int amdgpu_bo_unmap_and_free(amdgpu_bo_handle bo, amdgpu_va_handle va_handle,
|
||||
uint64_t mc_addr, uint64_t size) {
|
||||
amdgpu_bo_cpu_unmap(bo);
|
||||
amdgpu_bo_va_op(bo, 0, size, mc_addr, 0, AMDGPU_VA_OP_UNMAP);
|
||||
amdgpu_va_range_free(va_handle);
|
||||
amdgpu_bo_free(bo);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
amdgpu_get_bo_list(amdgpu_device_handle dev, amdgpu_bo_handle bo1,
|
||||
amdgpu_bo_handle bo2, amdgpu_bo_list_handle *list)
|
||||
{
|
||||
amdgpu_bo_handle resources[] = {bo1, bo2};
|
||||
static inline int amdgpu_get_bo_list(amdgpu_device_handle dev, amdgpu_bo_handle bo1,
|
||||
amdgpu_bo_handle bo2, amdgpu_bo_list_handle *list) {
|
||||
amdgpu_bo_handle resources[] = {bo1, bo2};
|
||||
|
||||
return amdgpu_bo_list_create(dev, bo2 ? 2 : 1, resources, NULL, list);
|
||||
return amdgpu_bo_list_create(dev, bo2 ? 2 : 1, resources, NULL, list);
|
||||
}
|
||||
|
||||
void KFDEvictTest::AmdgpuCommandSubmissionComputeNop(int rn) {
|
||||
@@ -204,7 +199,7 @@ void KFDEvictTest::AmdgpuCommandSubmissionComputeNop(int rn) {
|
||||
&boList));
|
||||
|
||||
/* Fill Nop cammands in IB */
|
||||
ptr = (uint32_t *)ibResultCpu;
|
||||
ptr = reinterpret_cast<uint32_t *>(ibResultCpu);
|
||||
for (int i = 0; i < 16; i++)
|
||||
ptr[i] = 0xffff1000;
|
||||
|
||||
|
||||
Reference in new issue
Block a user