SWDEV-470698 - fix formatting, add format check workflow (#657)
This commit is contained in:
committad av
GitHub
förälder
5840940caa
incheckning
f7338717ae
@@ -39,31 +39,41 @@ static_assert(hipCpuDeviceId == amd::CpuDeviceId, "CPU device ID mismatch with R
|
||||
static_assert(hipInvalidDeviceId == amd::InvalidDeviceId,
|
||||
"Invalid device ID mismatch with ROCclr!");
|
||||
|
||||
static_assert(static_cast<uint32_t>(hipMemAdviseSetReadMostly) ==
|
||||
amd::MemoryAdvice::SetReadMostly, "Enum mismatch with ROCclr!");
|
||||
static_assert(static_cast<uint32_t>(hipMemAdviseSetReadMostly) == amd::MemoryAdvice::SetReadMostly,
|
||||
"Enum mismatch with ROCclr!");
|
||||
static_assert(static_cast<uint32_t>(hipMemAdviseUnsetReadMostly) ==
|
||||
amd::MemoryAdvice::UnsetReadMostly, "Enum mismatch with ROCclr!");
|
||||
amd::MemoryAdvice::UnsetReadMostly,
|
||||
"Enum mismatch with ROCclr!");
|
||||
static_assert(static_cast<uint32_t>(hipMemAdviseSetPreferredLocation) ==
|
||||
amd::MemoryAdvice::SetPreferredLocation, "Enum mismatch with ROCclr!");
|
||||
amd::MemoryAdvice::SetPreferredLocation,
|
||||
"Enum mismatch with ROCclr!");
|
||||
static_assert(static_cast<uint32_t>(hipMemAdviseUnsetPreferredLocation) ==
|
||||
amd::MemoryAdvice::UnsetPreferredLocation, "Enum mismatch with ROCclr!");
|
||||
static_assert(static_cast<uint32_t>(hipMemAdviseSetAccessedBy) ==
|
||||
amd::MemoryAdvice::SetAccessedBy, "Enum mismatch with ROCclr!");
|
||||
amd::MemoryAdvice::UnsetPreferredLocation,
|
||||
"Enum mismatch with ROCclr!");
|
||||
static_assert(static_cast<uint32_t>(hipMemAdviseSetAccessedBy) == amd::MemoryAdvice::SetAccessedBy,
|
||||
"Enum mismatch with ROCclr!");
|
||||
static_assert(static_cast<uint32_t>(hipMemAdviseUnsetAccessedBy) ==
|
||||
amd::MemoryAdvice::UnsetAccessedBy, "Enum mismatch with ROCclr!");
|
||||
amd::MemoryAdvice::UnsetAccessedBy,
|
||||
"Enum mismatch with ROCclr!");
|
||||
static_assert(static_cast<uint32_t>(hipMemAdviseSetCoarseGrain) ==
|
||||
amd::MemoryAdvice::SetCoarseGrain, "Enum mismatch with ROCclr!");
|
||||
amd::MemoryAdvice::SetCoarseGrain,
|
||||
"Enum mismatch with ROCclr!");
|
||||
static_assert(static_cast<uint32_t>(hipMemAdviseUnsetCoarseGrain) ==
|
||||
amd::MemoryAdvice::UnsetCoarseGrain, "Enum mismatch with ROCclr!");
|
||||
amd::MemoryAdvice::UnsetCoarseGrain,
|
||||
"Enum mismatch with ROCclr!");
|
||||
|
||||
static_assert(static_cast<uint32_t>(hipMemRangeAttributeReadMostly) ==
|
||||
amd::MemRangeAttribute::ReadMostly, "Enum mismatch with ROCclr!");
|
||||
amd::MemRangeAttribute::ReadMostly,
|
||||
"Enum mismatch with ROCclr!");
|
||||
static_assert(static_cast<uint32_t>(hipMemRangeAttributePreferredLocation) ==
|
||||
amd::MemRangeAttribute::PreferredLocation, "Enum mismatch with ROCclr!");
|
||||
amd::MemRangeAttribute::PreferredLocation,
|
||||
"Enum mismatch with ROCclr!");
|
||||
static_assert(static_cast<uint32_t>(hipMemRangeAttributeAccessedBy) ==
|
||||
amd::MemRangeAttribute::AccessedBy, "Enum mismatch with ROCclr!");
|
||||
amd::MemRangeAttribute::AccessedBy,
|
||||
"Enum mismatch with ROCclr!");
|
||||
static_assert(static_cast<uint32_t>(hipMemRangeAttributeLastPrefetchLocation) ==
|
||||
amd::MemRangeAttribute::LastPrefetchLocation, "Enum mismatch with ROCclr!");
|
||||
amd::MemRangeAttribute::LastPrefetchLocation,
|
||||
"Enum mismatch with ROCclr!");
|
||||
|
||||
// ================================================================================================
|
||||
hipError_t hipMallocManaged(void** dev_ptr, size_t size, unsigned int flags) {
|
||||
@@ -84,8 +94,7 @@ hipError_t hipMallocManaged(void** dev_ptr, size_t size, unsigned int flags) {
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
hipError_t hipMemPrefetchAsync(const void* dev_ptr, size_t count, int device,
|
||||
hipStream_t stream) {
|
||||
hipError_t hipMemPrefetchAsync(const void* dev_ptr, size_t count, int device, hipStream_t stream) {
|
||||
HIP_INIT_API(hipMemPrefetchAsync, dev_ptr, count, device, stream);
|
||||
CHECK_STREAM_CAPTURE_SUPPORTED();
|
||||
hipMemLocation location;
|
||||
@@ -147,8 +156,8 @@ hipError_t hipMemRangeGetAttribute(void* data, size_t data_size, hipMemRangeAttr
|
||||
amd::Device* dev = g_devices[0]->devices()[0];
|
||||
|
||||
// Get the allocation attribute from AMD HMM
|
||||
if (!dev->GetSvmAttributes(&data, &data_size, reinterpret_cast<int*>(&attribute), 1,
|
||||
dev_ptr, count)) {
|
||||
if (!dev->GetSvmAttributes(&data, &data_size, reinterpret_cast<int*>(&attribute), 1, dev_ptr,
|
||||
count)) {
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
@@ -159,8 +168,8 @@ hipError_t hipMemRangeGetAttribute(void* data, size_t data_size, hipMemRangeAttr
|
||||
hipError_t hipMemRangeGetAttributes(void** data, size_t* data_sizes,
|
||||
hipMemRangeAttribute* attributes, size_t num_attributes,
|
||||
const void* dev_ptr, size_t count) {
|
||||
HIP_INIT_API(hipMemRangeGetAttributes, data, data_sizes,
|
||||
attributes, num_attributes, dev_ptr, count);
|
||||
HIP_INIT_API(hipMemRangeGetAttributes, data, data_sizes, attributes, num_attributes, dev_ptr,
|
||||
count);
|
||||
|
||||
if ((data == nullptr) || (data_sizes == nullptr) || (attributes == nullptr) ||
|
||||
(num_attributes == 0) || (dev_ptr == nullptr) || (count == 0)) {
|
||||
@@ -168,7 +177,7 @@ hipError_t hipMemRangeGetAttributes(void** data, size_t* data_sizes,
|
||||
}
|
||||
|
||||
if (*data_sizes > 0) {
|
||||
for (int i = 0 ; i<*data_sizes ; i++) {
|
||||
for (int i = 0; i < *data_sizes; i++) {
|
||||
if (!data[i]) {
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
@@ -188,8 +197,8 @@ hipError_t hipMemRangeGetAttributes(void** data, size_t* data_sizes,
|
||||
// Shouldn't matter for which device the interface is called
|
||||
amd::Device* dev = g_devices[0]->devices()[0];
|
||||
// Get the allocation attributes from AMD HMM
|
||||
if (!dev->GetSvmAttributes(data, data_sizes, reinterpret_cast<int*>(attributes),
|
||||
num_attributes, dev_ptr, count)) {
|
||||
if (!dev->GetSvmAttributes(data, data_sizes, reinterpret_cast<int*>(attributes), num_attributes,
|
||||
dev_ptr, count)) {
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
@@ -197,8 +206,8 @@ hipError_t hipMemRangeGetAttributes(void** data, size_t* data_sizes,
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
hipError_t hipStreamAttachMemAsync(hipStream_t stream, void* dev_ptr,
|
||||
size_t length, unsigned int flags) {
|
||||
hipError_t hipStreamAttachMemAsync(hipStream_t stream, void* dev_ptr, size_t length,
|
||||
unsigned int flags) {
|
||||
HIP_INIT_API(hipStreamAttachMemAsync, stream, dev_ptr, length, flags);
|
||||
// stream can be null, length can be 0.
|
||||
if (dev_ptr == nullptr) {
|
||||
@@ -217,8 +226,9 @@ hipError_t hipStreamAttachMemAsync(hipStream_t stream, void* dev_ptr,
|
||||
// host-accessible region of system-allocated pageable memory.
|
||||
// This type of memory may only be specified if the device associated with the
|
||||
// stream reports a non-zero value for the device attribute hipDevAttrPageableMemoryAccess.
|
||||
hip::Stream* hip_stream = (stream == nullptr || stream == hipStreamLegacy) ?
|
||||
hip::getCurrentDevice()->NullStream() : hip::getStream(stream);
|
||||
hip::Stream* hip_stream = (stream == nullptr || stream == hipStreamLegacy)
|
||||
? hip::getCurrentDevice()->NullStream()
|
||||
: hip::getStream(stream);
|
||||
size_t offset = 0;
|
||||
amd::Memory* memObj = getMemoryObject(dev_ptr, offset);
|
||||
if (memObj == nullptr) {
|
||||
@@ -258,9 +268,9 @@ hipError_t ihipMallocManaged(void** ptr, size_t size, size_t align, bool use_hos
|
||||
// allocation in the device driver
|
||||
if (use_host_ptr) {
|
||||
// If the host pointer is already allocated, map it to svm fine grain buffer
|
||||
*ptr = amd::SvmBuffer::malloc(ctx, CL_MEM_SVM_FINE_GRAIN_BUFFER | CL_MEM_USE_HOST_PTR, size,
|
||||
(align == 0) ? dev.info().memBaseAddrAlign_ : align, nullptr,
|
||||
*ptr);
|
||||
*ptr =
|
||||
amd::SvmBuffer::malloc(ctx, CL_MEM_SVM_FINE_GRAIN_BUFFER | CL_MEM_USE_HOST_PTR, size,
|
||||
(align == 0) ? dev.info().memBaseAddrAlign_ : align, nullptr, *ptr);
|
||||
} else {
|
||||
*ptr = amd::SvmBuffer::malloc(ctx, CL_MEM_SVM_FINE_GRAIN_BUFFER | CL_MEM_ALLOC_HOST_PTR, size,
|
||||
(align == 0) ? dev.info().memBaseAddrAlign_ : align);
|
||||
@@ -268,12 +278,12 @@ hipError_t ihipMallocManaged(void** ptr, size_t size, size_t align, bool use_hos
|
||||
if (*ptr == nullptr) {
|
||||
return hipErrorMemoryAllocation;
|
||||
}
|
||||
size_t offset = 0; //this is ignored
|
||||
size_t offset = 0; // this is ignored
|
||||
amd::Memory* memObj = getMemoryObject(*ptr, offset);
|
||||
if (memObj == nullptr) {
|
||||
return hipErrorMemoryAllocation;
|
||||
}
|
||||
//saves the current device id so that it can be accessed later
|
||||
// saves the current device id so that it can be accessed later
|
||||
memObj->getUserData().deviceId = hip::getCurrentDevice()->deviceId();
|
||||
|
||||
ClPrint(amd::LOG_INFO, amd::LOG_API, "ihipMallocManaged ptr=0x%zx", *ptr);
|
||||
@@ -397,4 +407,4 @@ hipError_t ihipMemAdvise(const void* dev_ptr, size_t count, hipMemoryAdvise advi
|
||||
|
||||
return hipSuccess;
|
||||
}
|
||||
} //namespace hip
|
||||
} // namespace hip
|
||||
|
||||
Referens i nytt ärende
Block a user