Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/intel-llvm-mirror-base-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f2ac846551b0f7fb97974a87c74f7a48bc4f43f8
fa6bc3d3c3f2e91bb066e117a9ca2618e6df0631
12 changes: 6 additions & 6 deletions source/adapters/cuda/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
cpy_desc.dstY = pCopyRegion->dstOffset.y;
cpy_desc.WidthInBytes = PixelSizeBytes * pCopyRegion->copyExtent.width;
cpy_desc.Height = pCopyRegion->copyExtent.height;
cpy_desc.srcPitch = pSrcImageDesc->width * PixelSizeBytes;
cpy_desc.srcPitch = pSrcImageDesc->rowPitch;
if (pDstImageDesc->rowPitch == 0) {
cpy_desc.dstMemoryType = CUmemorytype_enum::CU_MEMORYTYPE_ARRAY;
cpy_desc.dstArray = (CUarray)pDst;
Expand All @@ -725,7 +725,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
cpy_desc.dstZ = pCopyRegion->dstOffset.z;
cpy_desc.srcMemoryType = CUmemorytype_enum::CU_MEMORYTYPE_HOST;
cpy_desc.srcHost = pSrc;
cpy_desc.srcPitch = pSrcImageDesc->width * PixelSizeBytes;
cpy_desc.srcPitch = pSrcImageDesc->rowPitch;
cpy_desc.srcHeight = pSrcImageDesc->height;
cpy_desc.dstMemoryType = CUmemorytype_enum::CU_MEMORYTYPE_ARRAY;
cpy_desc.dstArray = (CUarray)pDst;
Expand All @@ -745,7 +745,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
cpy_desc.dstZ = pCopyRegion->dstOffset.z;
cpy_desc.srcMemoryType = CUmemorytype_enum::CU_MEMORYTYPE_HOST;
cpy_desc.srcHost = pSrc;
cpy_desc.srcPitch = pSrcImageDesc->width * PixelSizeBytes;
cpy_desc.srcPitch = pSrcImageDesc->rowPitch;
cpy_desc.srcHeight = std::max(uint64_t{1}, pSrcImageDesc->height);
cpy_desc.dstMemoryType = CUmemorytype_enum::CU_MEMORYTYPE_ARRAY;
cpy_desc.dstArray = (CUarray)pDst;
Expand Down Expand Up @@ -793,7 +793,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
cpy_desc.dstY = pCopyRegion->dstOffset.y;
cpy_desc.WidthInBytes = PixelSizeBytes * pCopyRegion->copyExtent.width;
cpy_desc.Height = pCopyRegion->copyExtent.height;
cpy_desc.dstPitch = pDstImageDesc->width * PixelSizeBytes;
cpy_desc.dstPitch = pDstImageDesc->rowPitch;
cpy_desc.dstMemoryType = CUmemorytype_enum::CU_MEMORYTYPE_HOST;
cpy_desc.dstHost = pDst;
if (pSrcImageDesc->rowPitch == 0) {
Expand All @@ -818,7 +818,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
cpy_desc.srcArray = as_CUArray(pSrc);
cpy_desc.dstMemoryType = CUmemorytype_enum::CU_MEMORYTYPE_HOST;
cpy_desc.dstHost = pDst;
cpy_desc.dstPitch = pDstImageDesc->width * PixelSizeBytes;
cpy_desc.dstPitch = pDstImageDesc->rowPitch;
cpy_desc.dstHeight = pDstImageDesc->height;
cpy_desc.WidthInBytes = PixelSizeBytes * pCopyRegion->copyExtent.width;
cpy_desc.Height = pCopyRegion->copyExtent.height;
Expand All @@ -838,7 +838,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
cpy_desc.srcArray = as_CUArray(pSrc);
cpy_desc.dstMemoryType = CUmemorytype_enum::CU_MEMORYTYPE_HOST;
cpy_desc.dstHost = pDst;
cpy_desc.dstPitch = pDstImageDesc->width * PixelSizeBytes;
cpy_desc.dstPitch = pDstImageDesc->rowPitch;
cpy_desc.dstHeight = std::max(uint64_t{1}, pDstImageDesc->height);
cpy_desc.WidthInBytes = PixelSizeBytes * pCopyRegion->copyExtent.width;
cpy_desc.Height = std::max(uint64_t{1}, pCopyRegion->copyExtent.height);
Expand Down
12 changes: 6 additions & 6 deletions source/adapters/hip/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
cpy_desc.srcY = pCopyRegion->srcOffset.y;
cpy_desc.dstXInBytes = pCopyRegion->dstOffset.x * PixelSizeBytes;
cpy_desc.dstY = pCopyRegion->dstOffset.y;
cpy_desc.srcPitch = pSrcImageDesc->width * PixelSizeBytes;
cpy_desc.srcPitch = pSrcImageDesc->rowPitch;
if (pDstImageDesc->rowPitch == 0) {
cpy_desc.dstMemoryType = hipMemoryTypeArray;
cpy_desc.dstArray = static_cast<hipArray_t>(pDst);
Expand All @@ -727,7 +727,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
cpy_desc.dstZ = pCopyRegion->dstOffset.z;
cpy_desc.srcMemoryType = hipMemoryTypeHost;
cpy_desc.srcHost = pSrc;
cpy_desc.srcPitch = pSrcImageDesc->width * PixelSizeBytes;
cpy_desc.srcPitch = pSrcImageDesc->rowPitch;
cpy_desc.srcHeight = pSrcImageDesc->height;
cpy_desc.dstMemoryType = hipMemoryTypeArray;
cpy_desc.dstArray = static_cast<hipArray_t>(pDst);
Expand All @@ -749,7 +749,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
cpy_desc.dstZ = pCopyRegion->dstOffset.z;
cpy_desc.srcMemoryType = hipMemoryTypeHost;
cpy_desc.srcHost = pSrc;
cpy_desc.srcPitch = pSrcImageDesc->width * PixelSizeBytes;
cpy_desc.srcPitch = pSrcImageDesc->rowPitch;
cpy_desc.srcHeight = std::max(MinCopyHeight, pSrcImageDesc->height);
cpy_desc.dstMemoryType = hipMemoryTypeArray;
cpy_desc.dstArray = static_cast<hipArray_t>(pDst);
Expand Down Expand Up @@ -824,7 +824,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
}
cpy_desc.dstMemoryType = hipMemoryTypeHost;
cpy_desc.dstHost = pDst;
cpy_desc.dstPitch = pDstImageDesc->width * PixelSizeBytes;
cpy_desc.dstPitch = pDstImageDesc->rowPitch;
cpy_desc.WidthInBytes = PixelSizeBytes * pCopyRegion->copyExtent.width;
cpy_desc.Height = pCopyRegion->copyExtent.height;
UR_CHECK_ERROR(hipMemcpyParam2DAsync(&cpy_desc, Stream));
Expand All @@ -840,7 +840,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
cpy_desc.srcArray = static_cast<hipArray_t>(const_cast<void *>(pSrc));
cpy_desc.dstMemoryType = hipMemoryTypeHost;
cpy_desc.dstHost = pDst;
cpy_desc.dstPitch = pDstImageDesc->width * PixelSizeBytes;
cpy_desc.dstPitch = pDstImageDesc->rowPitch;
cpy_desc.dstHeight = pDstImageDesc->height;
cpy_desc.WidthInBytes = PixelSizeBytes * pCopyRegion->copyExtent.width;
cpy_desc.Height = pCopyRegion->copyExtent.height;
Expand All @@ -863,7 +863,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
cpy_desc.srcArray = static_cast<hipArray_t>(const_cast<void *>(pSrc));
cpy_desc.dstMemoryType = hipMemoryTypeHost;
cpy_desc.dstHost = pDst;
cpy_desc.dstPitch = pDstImageDesc->width * PixelSizeBytes;
cpy_desc.dstPitch = pDstImageDesc->rowPitch;
cpy_desc.dstHeight = std::max(MinCopyHeight, pDstImageDesc->height);
cpy_desc.WidthInBytes = PixelSizeBytes * pCopyRegion->copyExtent.width;
cpy_desc.Height =
Expand Down
6 changes: 2 additions & 4 deletions source/adapters/level_zero/image_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,7 @@ ur_result_t bindlessImagesHandleCopyFlags(

switch (imageCopyFlags) {
case UR_EXP_IMAGE_COPY_FLAG_HOST_TO_DEVICE: {
uint32_t SrcRowPitch =
pSrcImageDesc->width * getPixelSizeBytes(pSrcImageFormat);
uint32_t SrcRowPitch = pSrcImageDesc->rowPitch;
uint32_t SrcSlicePitch = SrcRowPitch * pSrcImageDesc->height;
if (pDstImageDesc->rowPitch == 0) {
// Copy to Non-USM memory
Expand Down Expand Up @@ -824,8 +823,7 @@ ur_result_t bindlessImagesHandleCopyFlags(
return UR_RESULT_SUCCESS;
};
case UR_EXP_IMAGE_COPY_FLAG_DEVICE_TO_HOST: {
uint32_t DstRowPitch =
pDstImageDesc->width * getPixelSizeBytes(pDstImageFormat);
uint32_t DstRowPitch = pDstImageDesc->rowPitch;
uint32_t DstSlicePitch = DstRowPitch * pDstImageDesc->height;
if (pSrcImageDesc->rowPitch == 0) {
// Copy from Non-USM memory to host
Expand Down
13 changes: 4 additions & 9 deletions source/loader/layers/sanitizer/asan/asan_interceptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@
namespace ur_sanitizer_layer {
namespace asan {

AsanInterceptor::AsanInterceptor() {
if (getContext()->Options.MaxQuarantineSizeMB) {
m_Quarantine = std::make_unique<Quarantine>(
getContext()->Options.MaxQuarantineSizeMB * 1024 * 1024);
}
}
AsanInterceptor::AsanInterceptor() {}

AsanInterceptor::~AsanInterceptor() {
// We must release these objects before releasing adapters, since
Expand All @@ -39,7 +34,6 @@ AsanInterceptor::~AsanInterceptor() {
DeviceInfo->Shadow = nullptr;
}

m_Quarantine = nullptr;
m_MemBufferMap.clear();
m_KernelMap.clear();
m_ContextMap.clear();
Expand Down Expand Up @@ -224,7 +218,7 @@ ur_result_t AsanInterceptor::releaseMemory(ur_context_handle_t Context,
}

// If quarantine is disabled, USM is freed immediately
if (!m_Quarantine) {
if (!ContextInfo->m_Quarantine) {
UR_LOG_L(getContext()->logger, DEBUG, "Free: {}",
(void *)AllocInfo->AllocBegin);

Expand All @@ -239,7 +233,8 @@ ur_result_t AsanInterceptor::releaseMemory(ur_context_handle_t Context,
}

// If quarantine is enabled, cache it
auto ReleaseList = m_Quarantine->put(AllocInfo->Device, AllocInfoIt);
auto ReleaseList =
ContextInfo->m_Quarantine->put(AllocInfo->Device, AllocInfoIt);
if (ReleaseList.size()) {
std::scoped_lock<ur_shared_mutex> Guard(m_AllocationMapMutex);
for (auto &It : ReleaseList) {
Expand Down
11 changes: 7 additions & 4 deletions source/loader/layers/sanitizer/asan/asan_interceptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "asan_allocator.hpp"
#include "asan_buffer.hpp"
#include "asan_libdevice.hpp"
#include "asan_quarantine.hpp"
#include "asan_shadow.hpp"
#include "asan_statistics.hpp"
#include "sanitizer_common/sanitizer_common.hpp"
Expand All @@ -33,8 +34,6 @@
namespace ur_sanitizer_layer {
namespace asan {

class Quarantine;

struct AllocInfoList {
std::vector<std::shared_ptr<AllocInfo>> List;
ur_shared_mutex Mutex;
Expand Down Expand Up @@ -148,12 +147,18 @@ struct ContextInfo {
std::unordered_map<ur_device_handle_t, std::optional<ManagedQueue>>
InternalQueueMap;

std::optional<Quarantine> m_Quarantine;

AsanStatsWrapper Stats;

explicit ContextInfo(ur_context_handle_t Context) : Handle(Context) {
[[maybe_unused]] auto Result =
getContext()->urDdiTable.Context.pfnRetain(Context);
assert(Result == UR_RESULT_SUCCESS);
if (getContext()->Options.MaxQuarantineSizeMB) {
m_Quarantine.emplace(getContext()->Options.MaxQuarantineSizeMB * 1024 *
1024);
}
}

~ContextInfo();
Expand Down Expand Up @@ -404,8 +409,6 @@ class AsanInterceptor {
AllocationMap m_AllocationMap;
ur_shared_mutex m_AllocationMapMutex;

std::unique_ptr<Quarantine> m_Quarantine;

std::unordered_set<ur_adapter_handle_t> m_Adapters;
ur_shared_mutex m_AdaptersMutex;

Expand Down