test: support additional parameters for copy workload
Related-To: NEO-12811 Signed-off-by: Joshua Santosh Ranjan <joshua.santosh.ranjan@intel.com>
This commit is contained in:
parent
daa53cd8ca
commit
368afc2593
|
@ -181,20 +181,27 @@ class AppendMemoryCopyFromHeapToDeviceAndBackToHost : public Workload {
|
||||||
|
|
||||||
class CopyBufferToBuffer : public Workload {
|
class CopyBufferToBuffer : public Workload {
|
||||||
public:
|
public:
|
||||||
CopyBufferToBuffer(ExecutionContext *execCtxt) : Workload(execCtxt) { initialize(); }
|
CopyBufferToBuffer(ExecutionContext *execCtxt) : Workload(execCtxt) { initialize(nullptr, nullptr, 0); }
|
||||||
|
CopyBufferToBuffer(ExecutionContext *execCtxt, void *srcAddress, void *dstAddress, uint32_t size) : Workload(execCtxt) { initialize(srcAddress, dstAddress, size); }
|
||||||
~CopyBufferToBuffer() override { finalize(); };
|
~CopyBufferToBuffer() override { finalize(); };
|
||||||
bool appendCommands() override;
|
bool appendCommands() override;
|
||||||
bool validate() override;
|
bool validate() override;
|
||||||
|
void setValidationStatus(bool status) {
|
||||||
|
isValidationEnabled = status;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initialize();
|
void initialize(void *src, void *dst, uint32_t size);
|
||||||
void finalize();
|
void finalize();
|
||||||
const uint32_t allocationSize = 4096;
|
uint32_t allocationSize = 4096;
|
||||||
void *sourceBuffer = nullptr;
|
void *sourceBuffer = nullptr;
|
||||||
void *destinationBuffer = nullptr;
|
void *destinationBuffer = nullptr;
|
||||||
ze_module_handle_t module = nullptr;
|
ze_module_handle_t module = nullptr;
|
||||||
ze_kernel_handle_t kernel = nullptr;
|
ze_kernel_handle_t kernel = nullptr;
|
||||||
bool executeFromSpirv = false;
|
bool executeFromSpirv = false;
|
||||||
|
bool isSourceBufferAllocated = false;
|
||||||
|
bool isDestinationBufferAllocated = false;
|
||||||
|
bool isValidationEnabled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SingleMetricCollector : public Collector {
|
class SingleMetricCollector : public Collector {
|
||||||
|
|
|
@ -69,7 +69,11 @@ void AppendMemoryCopyFromHeapToDeviceAndBackToHost::finalize() {
|
||||||
////////////////////////
|
////////////////////////
|
||||||
/////CopyBufferToBuffer
|
/////CopyBufferToBuffer
|
||||||
////////////////////////
|
////////////////////////
|
||||||
void CopyBufferToBuffer::initialize() {
|
void CopyBufferToBuffer::initialize(void *src, void *dst, uint32_t size) {
|
||||||
|
|
||||||
|
sourceBuffer = src;
|
||||||
|
destinationBuffer = dst;
|
||||||
|
allocationSize = size != 0u ? size : allocationSize;
|
||||||
|
|
||||||
ze_device_mem_alloc_desc_t deviceDesc = {ZE_STRUCTURE_TYPE_DEVICE_MEM_ALLOC_DESC};
|
ze_device_mem_alloc_desc_t deviceDesc = {ZE_STRUCTURE_TYPE_DEVICE_MEM_ALLOC_DESC};
|
||||||
deviceDesc.flags = ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_UNCACHED;
|
deviceDesc.flags = ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_UNCACHED;
|
||||||
|
@ -78,16 +82,21 @@ void CopyBufferToBuffer::initialize() {
|
||||||
ze_host_mem_alloc_desc_t hostDesc = {ZE_STRUCTURE_TYPE_HOST_MEM_ALLOC_DESC};
|
ze_host_mem_alloc_desc_t hostDesc = {ZE_STRUCTURE_TYPE_HOST_MEM_ALLOC_DESC};
|
||||||
hostDesc.flags = ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_UNCACHED;
|
hostDesc.flags = ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_UNCACHED;
|
||||||
|
|
||||||
VALIDATECALL(zeMemAllocShared(executionCtxt->getContextHandle(0), &deviceDesc, &hostDesc,
|
if (sourceBuffer == nullptr) {
|
||||||
allocationSize, 1, executionCtxt->getDeviceHandle(0),
|
VALIDATECALL(zeMemAllocShared(executionCtxt->getContextHandle(0), &deviceDesc, &hostDesc,
|
||||||
&sourceBuffer));
|
allocationSize, 1, executionCtxt->getDeviceHandle(0),
|
||||||
VALIDATECALL(zeMemAllocShared(executionCtxt->getContextHandle(0), &deviceDesc, &hostDesc,
|
&sourceBuffer));
|
||||||
allocationSize, 1, executionCtxt->getDeviceHandle(0),
|
isSourceBufferAllocated = true;
|
||||||
&destinationBuffer));
|
memset(sourceBuffer, 55, allocationSize);
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize memory
|
if (destinationBuffer == nullptr) {
|
||||||
memset(sourceBuffer, 55, allocationSize);
|
VALIDATECALL(zeMemAllocShared(executionCtxt->getContextHandle(0), &deviceDesc, &hostDesc,
|
||||||
memset(destinationBuffer, 0, allocationSize);
|
allocationSize, 1, executionCtxt->getDeviceHandle(0),
|
||||||
|
&destinationBuffer));
|
||||||
|
isDestinationBufferAllocated = true;
|
||||||
|
memset(destinationBuffer, 0, allocationSize);
|
||||||
|
}
|
||||||
|
|
||||||
std::ifstream file("copy_buffer_to_buffer.spv", std::ios::binary);
|
std::ifstream file("copy_buffer_to_buffer.spv", std::ios::binary);
|
||||||
|
|
||||||
|
@ -130,7 +139,8 @@ void CopyBufferToBuffer::initialize() {
|
||||||
bool CopyBufferToBuffer::appendCommands() {
|
bool CopyBufferToBuffer::appendCommands() {
|
||||||
|
|
||||||
if (executeFromSpirv) {
|
if (executeFromSpirv) {
|
||||||
uint32_t groupSizeX = 32u;
|
LOG(zmu::LogLevel::DEBUG) << "Using copy_buffer_to_buffer.spv" << std::endl;
|
||||||
|
uint32_t groupSizeX = std::min<uint32_t>(32u, allocationSize);
|
||||||
uint32_t groupSizeY = 1u;
|
uint32_t groupSizeY = 1u;
|
||||||
uint32_t groupSizeZ = 1u;
|
uint32_t groupSizeZ = 1u;
|
||||||
VALIDATECALL(zeKernelSuggestGroupSize(kernel, allocationSize, 1U, 1U, &groupSizeX, &groupSizeY, &groupSizeZ));
|
VALIDATECALL(zeKernelSuggestGroupSize(kernel, allocationSize, 1U, 1U, &groupSizeX, &groupSizeY, &groupSizeZ));
|
||||||
|
@ -160,6 +170,11 @@ bool CopyBufferToBuffer::appendCommands() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CopyBufferToBuffer::validate() {
|
bool CopyBufferToBuffer::validate() {
|
||||||
|
|
||||||
|
if (!isValidationEnabled) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Validate.
|
// Validate.
|
||||||
const bool outputValidationSuccessful = (memcmp(destinationBuffer, sourceBuffer, allocationSize) == 0);
|
const bool outputValidationSuccessful = (memcmp(destinationBuffer, sourceBuffer, allocationSize) == 0);
|
||||||
|
|
||||||
|
@ -185,8 +200,13 @@ bool CopyBufferToBuffer::validate() {
|
||||||
|
|
||||||
void CopyBufferToBuffer::finalize() {
|
void CopyBufferToBuffer::finalize() {
|
||||||
|
|
||||||
VALIDATECALL(zeMemFree(executionCtxt->getContextHandle(0), sourceBuffer));
|
if (isSourceBufferAllocated) {
|
||||||
VALIDATECALL(zeMemFree(executionCtxt->getContextHandle(0), destinationBuffer));
|
VALIDATECALL(zeMemFree(executionCtxt->getContextHandle(0), sourceBuffer));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isDestinationBufferAllocated) {
|
||||||
|
VALIDATECALL(zeMemFree(executionCtxt->getContextHandle(0), destinationBuffer));
|
||||||
|
}
|
||||||
|
|
||||||
if (kernel) {
|
if (kernel) {
|
||||||
zeKernelDestroy(kernel);
|
zeKernelDestroy(kernel);
|
||||||
|
|
Loading…
Reference in New Issue