-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Offload] Implement the remaining initial Offload API #122106
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
Changes from all commits
1d8a682
742b3e0
44fb1e7
f751a43
e8e7423
731a7d8
4e78abf
833af6e
a8a901f
bae7ccf
2e12e28
aa20e36
5a62263
b7d14be
7616417
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//===-- Event.td - Event definitions for Offload -----------*- tablegen -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file contains Offload API definitions related to the event handle | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
def : Function { | ||
let name = "olDestroyEvent"; | ||
let desc = "Destroy the event and free all underlying resources."; | ||
let details = []; | ||
let params = [ | ||
Param<"ol_event_handle_t", "Event", "handle of the event", PARAM_IN> | ||
]; | ||
let returns = []; | ||
} | ||
|
||
def : Function { | ||
let name = "olWaitEvent"; | ||
let desc = "Wait for the event to be complete."; | ||
let details = []; | ||
let params = [ | ||
Param<"ol_event_handle_t", "Event", "handle of the event", PARAM_IN> | ||
]; | ||
let returns = []; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
//===-- Kernel.td - Kernel definitions for Offload ---------*- tablegen -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file contains Offload API definitions related to the kernel handle | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
def : Function { | ||
let name = "olGetKernel"; | ||
let desc = "Get a kernel from the function identified by `KernelName` in the given program."; | ||
let details = [ | ||
"The kernel handle returned is owned by the device so does not need to be destroyed." | ||
]; | ||
let params = [ | ||
Param<"ol_program_handle_t", "Program", "handle of the program", PARAM_IN>, | ||
Param<"const char*", "KernelName", "name of the kernel entry point in the program", PARAM_IN>, | ||
Param<"ol_kernel_handle_t*", "Kernel", "output pointer for the fetched kernel", PARAM_OUT> | ||
]; | ||
let returns = []; | ||
} | ||
|
||
def : Struct { | ||
let name = "ol_kernel_launch_size_args_t"; | ||
let desc = "Size-related arguments for a kernel launch."; | ||
let members = [ | ||
StructMember<"size_t", "Dimensions", "Number of work dimensions">, | ||
StructMember<"size_t", "NumGroupsX", "Number of work groups on the X dimension">, | ||
StructMember<"size_t", "NumGroupsY", "Number of work groups on the Y dimension">, | ||
StructMember<"size_t", "NumGroupsZ", "Number of work groups on the Z dimension">, | ||
StructMember<"size_t", "GroupSizeX", "Size of a work group on the X dimension.">, | ||
StructMember<"size_t", "GroupSizeY", "Size of a work group on the Y dimension.">, | ||
StructMember<"size_t", "GroupSizeZ", "Size of a work group on the Z dimension.">, | ||
StructMember<"size_t", "DynSharedMemory", "Size of dynamic shared memory in bytes."> | ||
]; | ||
} | ||
|
||
def : Function { | ||
let name = "olLaunchKernel"; | ||
let desc = "Enqueue a kernel launch with the specified size and parameters."; | ||
let details = [ | ||
"If a queue is not specified, kernel execution happens synchronously" | ||
]; | ||
let params = [ | ||
Param<"ol_queue_handle_t", "Queue", "handle of the queue", PARAM_IN_OPTIONAL>, | ||
Param<"ol_device_handle_t", "Device", "handle of the device to execute on", PARAM_IN>, | ||
Param<"ol_kernel_handle_t", "Kernel", "handle of the kernel", PARAM_IN>, | ||
Param<"const void*", "ArgumentsData", "pointer to the kernel argument struct", PARAM_IN>, | ||
Param<"size_t", "ArgumentsSize", "size of the kernel argument struct", PARAM_IN>, | ||
Param<"const ol_kernel_launch_size_args_t*", "LaunchSizeArgs", "pointer to the struct containing launch size parameters", PARAM_IN>, | ||
Param<"ol_event_handle_t*", "EventOut", "optional recorded event for the enqueued operation", PARAM_OUT_OPTIONAL> | ||
]; | ||
let returns = [ | ||
Return<"OL_ERRC_INVALID_ARGUMENT", ["`Queue == NULL && EventOut != NULL`"]>, | ||
Return<"OL_ERRC_INVALID_DEVICE", ["If Queue is non-null but does not belong to Device"]>, | ||
]; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
//===-- Memory.td - Memory definitions for Offload ---------*- tablegen -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file contains Offload API definitions related to memory allocations | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
def : Enum { | ||
let name = "ol_alloc_type_t"; | ||
let desc = "Represents the type of allocation made with olMemAlloc."; | ||
let etors = [ | ||
Etor<"HOST", "Host allocation">, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These names suck, they roughly equate to CUDA's In this context, I believe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't disagree but I'm struggling to come up with better names. Maybe we can discuss this in the next call and come to a decision. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd probably just go with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it should be called pinned. The memory is allocated on the host, accessible by the device and does not migrate to device. ie stays on host. pinned in non offload term could mean pinned on the host and not paged out. |
||
Etor<"DEVICE", "Device allocation">, | ||
Etor<"MANAGED", "Managed allocation"> | ||
]; | ||
} | ||
|
||
def : Function { | ||
let name = "olMemAlloc"; | ||
let desc = "Creates a memory allocation on the specified device."; | ||
let params = [ | ||
Param<"ol_device_handle_t", "Device", "handle of the device to allocate on", PARAM_IN>, | ||
Param<"ol_alloc_type_t", "Type", "type of the allocation", PARAM_IN>, | ||
Param<"size_t", "Size", "size of the allocation in bytes", PARAM_IN>, | ||
Param<"void**", "AllocationOut", "output for the allocated pointer", PARAM_OUT> | ||
]; | ||
let returns = [ | ||
Return<"OL_ERRC_INVALID_SIZE", [ | ||
"`Size == 0`" | ||
]> | ||
]; | ||
} | ||
|
||
def : Function { | ||
let name = "olMemFree"; | ||
let desc = "Frees a memory allocation previously made by olMemAlloc."; | ||
let params = [ | ||
Param<"void*", "Address", "address of the allocation to free", PARAM_IN>, | ||
]; | ||
let returns = []; | ||
} | ||
|
||
def : Function { | ||
let name = "olMemcpy"; | ||
let desc = "Enqueue a memcpy operation."; | ||
let details = [ | ||
"For host pointers, use the host device belonging to the OL_PLATFORM_BACKEND_HOST platform.", | ||
"If a queue is specified, at least one device must be a non-host device", | ||
"If a queue is not specified, the memcpy happens synchronously" | ||
]; | ||
let params = [ | ||
Param<"ol_queue_handle_t", "Queue", "handle of the queue.", PARAM_IN_OPTIONAL>, | ||
Param<"void*", "DstPtr", "pointer to copy to", PARAM_IN>, | ||
Param<"ol_device_handle_t", "DstDevice", "device that DstPtr belongs to", PARAM_IN>, | ||
Param<"void*", "SrcPtr", "pointer to copy from", PARAM_IN>, | ||
Param<"ol_device_handle_t", "SrcDevice", "device that SrcPtr belongs to", PARAM_IN>, | ||
Param<"size_t", "Size", "size in bytes of data to copy", PARAM_IN>, | ||
Param<"ol_event_handle_t*", "EventOut", "optional recorded event for the enqueued operation", PARAM_OUT_OPTIONAL> | ||
]; | ||
let returns = [ | ||
Return<"OL_ERRC_INVALID_ARGUMENT", ["`Queue == NULL && EventOut != NULL`"]> | ||
]; | ||
} |
Uh oh!
There was an error while loading. Please reload this page.