diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.inl b/level_zero/core/source/cmdlist/cmdlist_hw.inl index e6931aa61e..c662f22b2c 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw.inl @@ -281,7 +281,7 @@ ze_result_t CommandListCoreFamily::appendImageCopyFromMemory(ze_i break; } - builtinKernel->setArgBufferWithAlloc(0u, reinterpret_cast(&allocationStruct.alignedAllocationPtr), + builtinKernel->setArgBufferWithAlloc(0u, allocationStruct.alignedAllocationPtr, allocationStruct.alloc); builtinKernel->setArgRedescribedImage(1u, hDstImage); builtinKernel->setArgumentValue(2u, sizeof(size_t), &allocationStruct.offset); @@ -378,7 +378,7 @@ ze_result_t CommandListCoreFamily::appendImageCopyToMemory(void * } builtinKernel->setArgRedescribedImage(0u, hSrcImage); - builtinKernel->setArgBufferWithAlloc(1u, reinterpret_cast(&allocationStruct.alignedAllocationPtr), + builtinKernel->setArgBufferWithAlloc(1u, allocationStruct.alignedAllocationPtr, allocationStruct.alloc); uint32_t origin[] = { @@ -566,9 +566,8 @@ ze_result_t CommandListCoreFamily::appendMemoryCopyKernelWithGA(v return ZE_RESULT_ERROR_UNKNOWN; } - builtinFunction->setArgBufferWithAlloc(0u, dstPtr, dstPtrAlloc); - - builtinFunction->setArgBufferWithAlloc(1u, srcPtr, srcPtrAlloc); + builtinFunction->setArgBufferWithAlloc(0u, *reinterpret_cast(dstPtr), dstPtrAlloc); + builtinFunction->setArgBufferWithAlloc(1u, *reinterpret_cast(srcPtr), srcPtrAlloc); uint32_t elems = size / elementSize; builtinFunction->setArgumentValue(2, sizeof(elems), &elems); @@ -639,8 +638,8 @@ ze_result_t CommandListCoreFamily::appendPageFaultCopy(NEO::Graph auto dstValPtr = static_cast(dstptr->getGpuAddress()); auto srcValPtr = static_cast(srcptr->getGpuAddress()); - builtinFunction->setArgBufferWithAlloc(0, reinterpret_cast(&dstValPtr), dstptr); - builtinFunction->setArgBufferWithAlloc(1, reinterpret_cast(&srcValPtr), srcptr); + builtinFunction->setArgBufferWithAlloc(0, dstValPtr, dstptr); + builtinFunction->setArgBufferWithAlloc(1, srcValPtr, srcptr); builtinFunction->setArgumentValue(2, sizeof(size), &size); uint32_t groups = (static_cast(size) + ((groupSizeX)-1)) / (groupSizeX); @@ -854,8 +853,8 @@ ze_result_t CommandListCoreFamily::appendMemoryCopyKernel3d(NEO:: auto dstValPtr = static_cast(dstGA->getGpuAddress()); auto srcValPtr = static_cast(srcGA->getGpuAddress()); - builtinFunction->setArgBufferWithAlloc(0, reinterpret_cast(&srcValPtr), srcGA); - builtinFunction->setArgBufferWithAlloc(1, reinterpret_cast(&dstValPtr), dstGA); + builtinFunction->setArgBufferWithAlloc(0, srcValPtr, srcGA); + builtinFunction->setArgBufferWithAlloc(1, dstValPtr, dstGA); builtinFunction->setArgumentValue(2, sizeof(srcOrigin), &srcOrigin); builtinFunction->setArgumentValue(3, sizeof(dstOrigin), &dstOrigin); builtinFunction->setArgumentValue(4, sizeof(srcPitches), &srcPitches); @@ -909,8 +908,8 @@ ze_result_t CommandListCoreFamily::appendMemoryCopyKernel2d(NEO:: auto dstValPtr = static_cast(dstGA->getGpuAddress()); auto srcValPtr = static_cast(srcGA->getGpuAddress()); - builtinFunction->setArgBufferWithAlloc(0, reinterpret_cast(&srcValPtr), srcGA); - builtinFunction->setArgBufferWithAlloc(1, reinterpret_cast(&dstValPtr), dstGA); + builtinFunction->setArgBufferWithAlloc(0, srcValPtr, srcGA); + builtinFunction->setArgBufferWithAlloc(1, dstValPtr, dstGA); builtinFunction->setArgumentValue(2, sizeof(srcOrigin), &srcOrigin); builtinFunction->setArgumentValue(3, sizeof(dstOrigin), &dstOrigin); builtinFunction->setArgumentValue(4, sizeof(srcPitch), &srcPitch); diff --git a/level_zero/core/source/kernel/kernel.h b/level_zero/core/source/kernel/kernel.h index 174b54e5cf..95f52dd3d7 100644 --- a/level_zero/core/source/kernel/kernel.h +++ b/level_zero/core/source/kernel/kernel.h @@ -96,7 +96,7 @@ struct Kernel : _ze_kernel_handle_t, virtual NEO::DispatchKernelEncoderI { virtual ze_result_t setArgumentValue(uint32_t argIndex, size_t argSize, const void *pArgValue) = 0; virtual void setGroupCount(uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ) = 0; - virtual ze_result_t setArgBufferWithAlloc(uint32_t argIndex, const void *argVal, NEO::GraphicsAllocation *allocation) = 0; + virtual ze_result_t setArgBufferWithAlloc(uint32_t argIndex, uintptr_t argVal, NEO::GraphicsAllocation *allocation) = 0; virtual ze_result_t setArgRedescribedImage(uint32_t argIndex, ze_image_handle_t argVal) = 0; virtual ze_result_t setGroupSize(uint32_t groupSizeX, uint32_t groupSizeY, uint32_t groupSizeZ) = 0; diff --git a/level_zero/core/source/kernel/kernel_imp.cpp b/level_zero/core/source/kernel/kernel_imp.cpp index 73d9cc09cf..95e46fbcf2 100644 --- a/level_zero/core/source/kernel/kernel_imp.cpp +++ b/level_zero/core/source/kernel/kernel_imp.cpp @@ -413,9 +413,9 @@ ze_result_t KernelImp::setArgRedescribedImage(uint32_t argIndex, ze_image_handle return ZE_RESULT_SUCCESS; } -ze_result_t KernelImp::setArgBufferWithAlloc(uint32_t argIndex, const void *argVal, NEO::GraphicsAllocation *allocation) { +ze_result_t KernelImp::setArgBufferWithAlloc(uint32_t argIndex, uintptr_t argVal, NEO::GraphicsAllocation *allocation) { const auto &arg = kernelImmData->getDescriptor().payloadMappings.explicitArgs[argIndex].as(); - const auto val = *reinterpret_cast(argVal); + const auto val = argVal; NEO::patchPointer(ArrayRef(crossThreadData.get(), crossThreadDataSize), arg, val); if (NEO::isValidOffset(arg.bindful)) { @@ -460,8 +460,8 @@ ze_result_t KernelImp::setArgBuffer(uint32_t argIndex, size_t argSize, const voi auto requestedAddress = *reinterpret_cast(argVal); auto svmAllocsManager = module->getDevice()->getDriverHandle()->getSvmAllocsManager(); NEO::GraphicsAllocation *alloc = svmAllocsManager->getSVMAllocs()->get(requestedAddress)->gpuAllocation; - - return setArgBufferWithAlloc(argIndex, argVal, alloc); + auto gpuAddress = reinterpret_cast(requestedAddress); + return setArgBufferWithAlloc(argIndex, gpuAddress, alloc); } ze_result_t KernelImp::setArgImage(uint32_t argIndex, size_t argSize, const void *argVal) { diff --git a/level_zero/core/source/kernel/kernel_imp.h b/level_zero/core/source/kernel/kernel_imp.h index 48684e3006..f764f3628a 100644 --- a/level_zero/core/source/kernel/kernel_imp.h +++ b/level_zero/core/source/kernel/kernel_imp.h @@ -64,7 +64,7 @@ struct KernelImp : Kernel { ze_result_t setArgRedescribedImage(uint32_t argIndex, ze_image_handle_t argVal) override; - ze_result_t setArgBufferWithAlloc(uint32_t argIndex, const void *argVal, NEO::GraphicsAllocation *allocation) override; + ze_result_t setArgBufferWithAlloc(uint32_t argIndex, uintptr_t argVal, NEO::GraphicsAllocation *allocation) override; ze_result_t setArgImage(uint32_t argIndex, size_t argSize, const void *argVal); diff --git a/level_zero/core/test/black_box_tests/CMakeLists.txt b/level_zero/core/test/black_box_tests/CMakeLists.txt new file mode 100644 index 0000000000..935eed7410 --- /dev/null +++ b/level_zero/core/test/black_box_tests/CMakeLists.txt @@ -0,0 +1,23 @@ +# +# Copyright (C) 2020 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" AND WIN32) + set(L0_BLACK_BOX_TEST_PROJECT_FOLDER "ze_intel_gpu/black_box_tests") + set(TEST_NAME zello_world) + + add_executable(${TEST_NAME} zello_world.cpp) + + set_target_properties(${TEST_NAME} + PROPERTIES + VS_DEBUGGER_COMMAND "$(TargetPath)" + VS_DEBUGGER_COMMAND_ARGUMENTS "" + VS_DEBUGGER_WORKING_DIRECTORY "$(OutputPath)" + ) + + add_dependencies(${TEST_NAME} ${TARGET_NAME_L0}) + target_link_libraries(${TEST_NAME} PUBLIC ${TARGET_NAME_L0}) + set_target_properties(${TEST_NAME} PROPERTIES FOLDER ${L0_BLACK_BOX_TEST_PROJECT_FOLDER}) +endif() \ No newline at end of file