-
Notifications
You must be signed in to change notification settings - Fork 787
[libspirv] Implement SPIR-V vload builtins via CLC #19174
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
Open
frasercrmck
wants to merge
1
commit into
intel:sycl
Choose a base branch
from
frasercrmck:vload-builtins
base: sycl
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.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifdef __CLC_SCALAR | ||
#define N_IF_VEC | ||
#else | ||
#define N_IF_VEC n | ||
#endif | ||
|
||
#define CLC_VLOAD_NAME() __CLC_XCONCAT(__clc_vload, __CLC_VECSIZE) | ||
#define SPIRV_VLOAD_NAME() \ | ||
__CLC_XCONCAT(__CLC_XCONCAT(__CLC_XCONCAT(__spirv_ocl_vload, N_IF_VEC), _R), \ | ||
__CLC_GENTYPE) | ||
|
||
#define CLC_VLOAD_HALF_NAME(a) \ | ||
__CLC_XCONCAT(__CLC_XCONCAT(__CLC_XCONCAT(__clc_vload, a), _half), \ | ||
__CLC_VECSIZE) | ||
|
||
#define CLC_VLOAD_TY __CLC_XCONCAT(less_aligned_, __CLC_GENTYPE) | ||
|
||
#ifdef __CLC_SCALAR | ||
|
||
#define VLOAD_DEF(ADDRSPACE) \ | ||
_CLC_OVERLOAD _CLC_DEF CLC_VLOAD_TY SPIRV_VLOAD_NAME()( \ | ||
size_t offset, const ADDRSPACE __CLC_SCALAR_GENTYPE *x) { \ | ||
return *((const ADDRSPACE CLC_VLOAD_TY *)(&x[offset])); \ | ||
} | ||
|
||
#define SPIRV_VLOAD_HALF_NAME(a) \ | ||
__CLC_XCONCAT(__CLC_XCONCAT(__spirv_ocl_vload, a), _half) | ||
|
||
#else | ||
|
||
#define VLOAD_DEF(ADDRSPACE) \ | ||
_CLC_OVERLOAD _CLC_DEF CLC_VLOAD_TY SPIRV_VLOAD_NAME()( \ | ||
size_t offset, const ADDRSPACE __CLC_SCALAR_GENTYPE *x) { \ | ||
return CLC_VLOAD_NAME()(offset, x); \ | ||
} | ||
|
||
#define SPIRV_VLOAD_HALF_NAME(a) \ | ||
__CLC_XCONCAT( \ | ||
__CLC_XCONCAT( \ | ||
__CLC_XCONCAT(__CLC_XCONCAT(__spirv_ocl_vload, a), _halfn), _R), \ | ||
__CLC_GENTYPE) | ||
|
||
#endif | ||
|
||
VLOAD_DEF(__private) | ||
VLOAD_DEF(__local) | ||
VLOAD_DEF(__constant) | ||
VLOAD_DEF(__global) | ||
|
||
#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED | ||
VLOAD_DEF(__generic) | ||
#endif | ||
|
||
#undef VLOAD_DEF | ||
#undef CLC_VLOAD_TY | ||
|
||
// vload_half and vloada_half are available even if cl_khr_fp16 is unavailable. | ||
// Declare these functions when working on float types, which we know are | ||
// always available. | ||
#ifdef __CLC_FPSIZE | ||
#if __CLC_FPSIZE == 32 | ||
|
||
#define VLOAD_HALF_DEF(ADDRSPACE, A) \ | ||
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE SPIRV_VLOAD_HALF_NAME(A)( \ | ||
size_t offset, const ADDRSPACE half *mem) { \ | ||
return CLC_VLOAD_HALF_NAME(A)(offset, mem); \ | ||
} | ||
|
||
VLOAD_HALF_DEF(__private, ) | ||
VLOAD_HALF_DEF(__local, ) | ||
VLOAD_HALF_DEF(__constant, ) | ||
VLOAD_HALF_DEF(__global, ) | ||
|
||
#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED | ||
VLOAD_HALF_DEF(__generic, ) | ||
#endif | ||
|
||
#ifndef __CLC_SCALAR | ||
VLOAD_HALF_DEF(__private, a) | ||
VLOAD_HALF_DEF(__local, a) | ||
VLOAD_HALF_DEF(__constant, a) | ||
VLOAD_HALF_DEF(__global, a) | ||
|
||
#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED | ||
VLOAD_HALF_DEF(__generic, a) | ||
#endif | ||
#endif | ||
|
||
#undef VLOAD_HALF_DEF | ||
#endif | ||
#endif | ||
|
||
#undef CLC_VLOAD_NAME | ||
#undef CLC_VLOAD_HALF_NAME | ||
#undef SPIRV_VLOAD_NAME | ||
#undef SPIRV_VLOAD_HALF_NAME | ||
|
||
#undef N_IF_VEC |
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.
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.
OpenCL spec doesn't define scalar variant of vloadn, right? Can we delete it?