-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[OFFLOAD] Add missing platform properties for libomptarget migration #171009
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
sarnex
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't know anything about liboffload or libomptarget so i can't offer any useful feedback, only generic comments
offload/liboffload/API/Device.td
Outdated
| TaggedEtor<"MAX_MEM_ALLOC_SIZE", "uint64_t", "The maximum size of memory object allocation in bytes">, | ||
| TaggedEtor<"GLOBAL_MEM_SIZE", "uint64_t", "The size of global device memory in bytes">, | ||
| TaggedEtor<"WORK_GROUP_LOCAL_MEM_SIZE", "uint64_t", "The maximum size of local shared memory per work group in bytes">, | ||
| TaggedEtor<"ID", "int32_t", "Device ID">, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we not use UID?
offload/liboffload/API/Device.td
Outdated
| } | ||
|
|
||
| def olSelectInterop : Function { | ||
| let desc = "Return OpenMP interop object that the device supports"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it seems all the descriptions should end with a period
offload/liboffload/API/Queue.td
Outdated
| Param<"ol_queue_handle_t", "Queue", "handle of the queue", PARAM_IN> | ||
| ]; | ||
| let returns = []; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit newline at eof
|
|
||
| Error olDataFence_impl(ol_queue_handle_t Queue) { | ||
| if (Queue->AsyncInfo->Queue) { | ||
| if (auto Err = Queue->Device->Device->dataFence(Queue->AsyncInfo)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't think it's related to this PR but Device->Device->fcn() is kinda weird :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is pretty common in liboffload code: bunch of classes have members called Device although in different classes they mean different things (liboffload Device type vs GenericDeviceTy from libomptarget). BTW, there is similar issue in libomptarget as well where we have different device types that abstract actual device on different API levels.
|
|
||
| Error olSelectInterop_impl(ol_device_handle_t Device, int32_t InteropType, int32_t InteropPreferencesSize, | ||
| void *InteropPreferences, void* InteropSpec) { | ||
| *(interop_spec_t*)InteropSpec = Device->Device->selectInteropPreference( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we static_cast instead of C cast? It's a bit safer.
You can test this locally with the following command:git-clang-format --diff origin/main HEAD --extensions cpp -- offload/liboffload/src/OffloadImpl.cpp --diff_from_common_commit
View the diff from clang-format here.diff --git a/offload/liboffload/src/OffloadImpl.cpp b/offload/liboffload/src/OffloadImpl.cpp
index 27c57232b..cb5ae8e19 100644
--- a/offload/liboffload/src/OffloadImpl.cpp
+++ b/offload/liboffload/src/OffloadImpl.cpp
@@ -1232,7 +1232,7 @@ Error olLaunchHostFunction_impl(ol_queue_handle_t Queue,
Error olDataFence_impl(ol_queue_handle_t Queue) {
if (Queue->AsyncInfo->Queue) {
if (auto Err = Queue->Device->Device->dataFence(Queue->AsyncInfo))
- return Err;
+ return Err;
}
return Error::success();
@@ -1241,13 +1241,14 @@ Error olDataFence_impl(ol_queue_handle_t Queue) {
Error olQueryAsync_impl(ol_queue_handle_t Queue) {
if (Queue->AsyncInfo->Queue) {
if (auto Err = Queue->Device->Device->queryAsync(Queue->AsyncInfo))
- return Err;
+ return Err;
}
return Error::success();
}
-Error olMemDataMappedNotify_impl(ol_device_handle_t Device, void *Ptr, size_t Size) {
+Error olMemDataMappedNotify_impl(ol_device_handle_t Device, void *Ptr,
+ size_t Size) {
return Device->Device->notifyDataMapped(Ptr, Size);
}
@@ -1255,8 +1256,9 @@ Error olMemDataUnMappedNotify_impl(ol_device_handle_t Device, void *Ptr) {
return Device->Device->notifyDataUnmapped(Ptr);
}
-Error olMemDataLock_impl(ol_device_handle_t Device, void *Ptr, size_t Size, void** LockedPtr) {
- Expected<void*> LockedPtrOrErr = Device->Device->dataLock(Ptr, Size);
+Error olMemDataLock_impl(ol_device_handle_t Device, void *Ptr, size_t Size,
+ void **LockedPtr) {
+ Expected<void *> LockedPtrOrErr = Device->Device->dataLock(Ptr, Size);
if (!LockedPtrOrErr)
return LockedPtrOrErr.takeError();
@@ -1269,32 +1271,37 @@ Error olMemDataUnLock_impl(ol_device_handle_t Device, void *Ptr) {
return Device->Device->dataUnlock(Ptr);
}
-Error olCreateInterop_impl(ol_device_handle_t Device, int32_t InteropContext, void* InteropSpec, void **Interop) {
- auto Rc = Device->Device->createInterop(InteropContext, *(interop_spec_t *)InteropSpec);
+Error olCreateInterop_impl(ol_device_handle_t Device, int32_t InteropContext,
+ void *InteropSpec, void **Interop) {
+ auto Rc = Device->Device->createInterop(InteropContext,
+ *(interop_spec_t *)InteropSpec);
if (!Rc)
return Rc.takeError();
*Interop = *Rc;
return Error::success();
}
-Error olReleaseInterop_impl(ol_device_handle_t Device, void* InteropSpec) {
+Error olReleaseInterop_impl(ol_device_handle_t Device, void *InteropSpec) {
auto Rc = Device->Device->releaseInterop((omp_interop_val_t *)InteropSpec);
if (Rc)
return Rc;
return Error::success();
}
-Error olSelectInterop_impl(ol_device_handle_t Device, int32_t InteropType, int32_t InteropPreferencesSize,
- void *InteropPreferences, void* InteropSpec) {
- *(interop_spec_t*)InteropSpec = Device->Device->selectInteropPreference(
- InteropType, InteropPreferencesSize, (interop_spec_t *)InteropPreferences);
+Error olSelectInterop_impl(ol_device_handle_t Device, int32_t InteropType,
+ int32_t InteropPreferencesSize,
+ void *InteropPreferences, void *InteropSpec) {
+ *(interop_spec_t *)InteropSpec = Device->Device->selectInteropPreference(
+ InteropType, InteropPreferencesSize,
+ (interop_spec_t *)InteropPreferences);
return Error::success();
}
Error olFlushQueueInterop_impl(ol_device_handle_t Device, void *Interop) {
- Expected<int32_t> Rc = Device->Device->Plugin.flush_queue((omp_interop_val_t *)Interop);
- if (Rc){
+ Expected<int32_t> Rc =
+ Device->Device->Plugin.flush_queue((omp_interop_val_t *)Interop);
+ if (Rc) {
return Rc.takeError();
}
return Error::success();
@@ -1302,8 +1309,9 @@ Error olFlushQueueInterop_impl(ol_device_handle_t Device, void *Interop) {
Error olSyncBarrierInterop_impl(ol_device_handle_t Device, void *Interop) {
- Expected<int32_t> Rc = Device->Device->Plugin.sync_barrier((omp_interop_val_t *)Interop);
- if (Rc){
+ Expected<int32_t> Rc =
+ Device->Device->Plugin.sync_barrier((omp_interop_val_t *)Interop);
+ if (Rc) {
return Rc.takeError();
}
return Error::success();
@@ -1311,22 +1319,23 @@ Error olSyncBarrierInterop_impl(ol_device_handle_t Device, void *Interop) {
Error olAsyncBarrierInterop_impl(ol_device_handle_t Device, void *Interop) {
- Expected<int32_t> Rc = Device->Device->Plugin.async_barrier((omp_interop_val_t *)Interop);
- if (Rc){
+ Expected<int32_t> Rc =
+ Device->Device->Plugin.async_barrier((omp_interop_val_t *)Interop);
+ if (Rc) {
return Rc.takeError();
}
return Error::success();
}
-Error olInitializeRecordReplay_impl(ol_device_handle_t Device, uint64_t MemorySize,
- void *VAddr, bool IsRecord,
- bool SaveOutput,
- uint64_t *ReqPtrArgOffset){
+Error olInitializeRecordReplay_impl(ol_device_handle_t Device,
+ uint64_t MemorySize, void *VAddr,
+ bool IsRecord, bool SaveOutput,
+ uint64_t *ReqPtrArgOffset) {
uint64_t ReqPtrArgOffsetOut = 0;
- Expected<int> Rc = Device->Device->Plugin.initialize_record_replay(Device->DeviceNum, MemorySize,
- VAddr, IsRecord, SaveOutput,
- ReqPtrArgOffsetOut);
- if (Rc){
+ Expected<int> Rc = Device->Device->Plugin.initialize_record_replay(
+ Device->DeviceNum, MemorySize, VAddr, IsRecord, SaveOutput,
+ ReqPtrArgOffsetOut);
+ if (Rc) {
return Rc.takeError();
}
*ReqPtrArgOffset = ReqPtrArgOffsetOut;
|
|
As a general comment, divide this into multiple PRs (only put together APIs that are related). |
Add missing liboffload platform properties for libomptarget migration
This PR adds liboffload platform properties that needed to make libomptarget to use liboffload