-
Notifications
You must be signed in to change notification settings - Fork 411
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
Add support for reduce intents and expressions on GPU #24787
Merged
Merged
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
stonea
reviewed
Apr 12, 2024
e-kayrakli
commented
Apr 12, 2024
e-kayrakli
commented
Apr 12, 2024
e-kayrakli
commented
Apr 12, 2024
stonea
approved these changes
Apr 18, 2024
e-kayrakli
force-pushed
the
gpu-reduce-intent
branch
from
April 19, 2024 23:27
6c3274f
to
64df191
Compare
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
e-kayrakli
force-pushed
the
gpu-reduce-intent
branch
from
April 25, 2024 17:12
84fffbb
to
bc76764
Compare
Signed-off-by: Engin Kayraklioglu <e-kayrakli@users.noreply.github.com>
Very exciting! I had no idea this was this close to being accomplished/able! |
4 tasks
e-kayrakli
added a commit
that referenced
this pull request
May 28, 2024
Arkouda+GPU compilation testing suffered as fallout from #24787. The issues were twofold: - Compiler segfault: In Arkouda, some order-independent loops are subject to what we call "late gpuization failure". In such cases, we generate a kernel, but then remove it from the AST. Removing a function from AST doesn't remove it from `gFnSymbols`. Scrubbing `gFnSymbols` et al. happens in between passes and removes such functions. However, `gpuTransforms` are technically part of LICM. After `gpuTransfroms` there are some LICM operations (that also seem unrelated to LICM, unfortunately) that iterate over `gFnSymbols`. One such operation would get the removed function from the AST that would cause segfaults down the road. As a solution, this PR uses `for_alive_in_Vec` in the problematic section of the code to avoid the issue. Note that I couldn't reproduce this issue outside of Arkouda. - Linkage issues: fixing that exposed other linkage issues b/c Arkouda uses reductions on bools. It felt safe to just support those. So, this PR adds the ability to do reduction on bools. [Reviewed by @DanilaFe] #### Test: - [x] arkouda compiles locally (well, there is another issue, but that needs to be fixed on Arkouda side. See Bears-R-Us/arkouda#3236) - [x] nvidia - [x] amd - [x] standard linux64
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.
This PR enables support for
+
,min
andmax
reductions on GPU-eligible loops. Both intent and expression based forms are supported:and
are now supported and executed as kernels on the GPU.
Background
In Chapel,
reduce
expressions lower toforall
s withreduce
intents early in compilation. As a result, during GPU transformations, there's onlyforall
s withreduce
intents. Therefore, the implementation here is all about supportingforall
loops withreduce
intents, where support forreduce
expressions comes for free.Implementation
Overview
We have been using CUB/hipCUB as the backend implementation for device-wide reductions for a couple of releases now. Implementation here relies on the same libraries support for block-wide reductions. For a reduction variable
redVar
, the generated kernel looks like:redVarBuffer
is allocated/maintained by the runtime.chpl_gpu_dev_breduce
will use *CUB to perform the block-wide reduction at the end of the kernel.Details
chpl_gpu_dev_breduce*
. In an earlier implementation, I tried to duplicate calls at the end of the kernel body and in the early return block. But hipCUB couldn't handle the thread divergence. So, I had to steer away from early return. Now,chpl_gpu_dev_breduce
calls are added topostBody_
.class KernelArg
ingpuTransforms
for easier representation of kernel actual/formal pairs.kernel_cfg
type in the runtime. As such, it;chpl_gpu_kernel_launch
, now. IOW, there's nochpl_gpu_kernel_launch_flat
anymore.chpl_gpu_kernel_launch
takes only akernel_cfg
argument. So,kernel_cfg
should contain all the info necessary to launch a kernel.PRIM_GPU_KERNEL_LAUNCH
primitive for all launches. IOW, there's noPRIM_GPU_KERNEL_LAUNCH_FLAT
anymore.PRIM_GPU_KERNEL_LAUNCH
only takes a single argument, that is thekernel_cfg
PRIM_GPU_INIT_KERNEL_CFG_3D
for 3D launches.PRIM_GPU_BLOCK_REDUCE
implements thechpl_gpu_dev_breduce
in the snippet above.PRIM_GPU_ARG
with a new argument kind.PRIM_GPU_ARG
, and then is passed as a function pointer to the runtime.redVarBuffer
in the snippet above.runtime/include/gpu/{nvidia,amd}/chpl-gpu-dev-reduce.h
kernel_cfg
type has been extended to handle number of threads, grid dimensions, kernel names and of course reduction variables.reduce_var
is the type that represent reduction arguments to kernelschpl_gpu_arg_reduce
is where a reduction variable is added to akernel_cfg
, andcfg_finalize_reductions
is what's called after the kernel itself to perform the final reduction(s).--std=c++14
. This was necessary for hipCUB.test/gpu/native/basics/reductionNoGpuize.chpl
is removed as it doesn't make much sense anymore.__primitive
based tests are adjusted for the new kernel launch interface.gpu/native/reduction
Future work
Test