-
Notifications
You must be signed in to change notification settings - Fork 14
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
Convert a subset of GPU dialect ops to the OpenCL GPU runtime calls #333
Open
AndreyPavlenko
wants to merge
5
commits into
intel:main
Choose a base branch
from
AndreyPavlenko:gc-ocl-pass
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AndreyPavlenko
force-pushed
the
gc-ocl-pass
branch
2 times, most recently
from
September 10, 2024 12:33
d855aee
to
95d6a07
Compare
AndreyPavlenko
force-pushed
the
gc-ocl-pass
branch
7 times, most recently
from
September 12, 2024 13:20
03d6a65
to
51cf443
Compare
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.
Could you please add lits? Would help reviewing.
AndreyPavlenko
added a commit
to AndreyPavlenko/graph-compiler
that referenced
this pull request
Sep 14, 2024
…nCL runtime calls
AndreyPavlenko
added a commit
to AndreyPavlenko/graph-compiler
that referenced
this pull request
Sep 15, 2024
…nCL runtime calls
AndreyPavlenko
force-pushed
the
gc-ocl-pass
branch
from
September 15, 2024 01:40
1815d78
to
9a3240e
Compare
dchigarev
reviewed
Sep 16, 2024
AndreyPavlenko
added a commit
to AndreyPavlenko/graph-compiler
that referenced
this pull request
Sep 16, 2024
…nCL runtime calls
AndreyPavlenko
added a commit
to AndreyPavlenko/graph-compiler
that referenced
this pull request
Sep 18, 2024
…nCL runtime calls
Added a new path, that converts the following GPU dialect ops to the corresponding callsof the GPU OpenCL runtime functions (to be implemented later): - gpu.alloc, gpu.dealloc, gpu.memcpy and gpu.launch The first argument of each runtime's function is a pointer to the context structure. This is not a cl_context, this is an execution context, i.e. a single execution of the module's main function. It contains the queue, wait list (in case of out-of-order mode) and someother data, required for the module ops execution. It's expected, that the pointer to the context is passed to the module's main function as the last argument of type memref with zero dims. For each gpu.launch operation, 2 additional functions are created: - getXXXKernel(): returns the kernel pointer, stored in a global variable. If it's NULL, calls createXXXKernel(). - createXXXKernel(): Calls the runtime's function, that creates a kernel. SPIRV, kernel name, and sizes are passed to the function. The returned pointer is saved in the global var using `llvm.cmpxchg`, to make sure it doesn't overwrite a kernel, created by another thread. Finally, a destructor function is created, that calls the corresponding runtime's kernel destroy function and passes the pointers, stored in the global vars. This function must be called by themodule owner, when destroying the module. The kernel is not a cl_kernel, but a runtime's internal structure, that contains a compiledcl_program, preconfigured cl_kernel and other data, required for the kernel execution. The runtime's launch function clones the preconfigured kernel, sets the arguments and enqueues a command to execute the kernel.
AndreyPavlenko
force-pushed
the
gc-ocl-pass
branch
from
September 19, 2024 21:00
3ce394f
to
d9651f1
Compare
AndreyPavlenko
force-pushed
the
gc-ocl-pass
branch
from
September 19, 2024 21:12
d9651f1
to
34415b1
Compare
AndreyPavlenko
added a commit
to AndreyPavlenko/graph-compiler
that referenced
this pull request
Sep 19, 2024
…nCL runtime calls
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added a new path, that converts the following GPU dialect ops to the corresponding callsof the OpenCL GPU runtime functions (to be implemented later):
The first argument of each runtime's function is a pointer to the context structure. This is not a cl_context, this is an execution context, i.e. a single execution of the module's main function. It contains the queue, wait list (in case of out-of-order mode) and someother data, required for the module ops execution. It's expected, that the pointer to the context is passed to the module's main function as the last argument of type memref with zero dims.
For each gpu.launch operation, 2 additional functions are created:
llvm.cmpxchg
, to make sure it doesn't overwrite a kernel, created by another thread.Finally, a destructor function is created, that calls the corresponding runtime's kernel destroy function and passes the pointers, stored in the global vars. This function must be called by themodule owner, when destroying the module.
The kernel is not a cl_kernel, but a runtime's internal structure, that contains a compiledcl_program, preconfigured cl_kernel and other data, required for the kernel execution. The runtime's launch function clones the preconfigured kernel, sets the arguments and enqueues a command to execute the kernel.
Example of code produced by this path: