Skip to content

[SYCL][libclc] Add generic addrspace overloads of math builtins #13015

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

Merged
merged 8 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions libclc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
endif()
message( " DEVICE: ${d} ( ${${d}_aliases} )" )

set ( supports_generic_addrspace TRUE )
if ( ${ARCH} STREQUAL "spirv" OR ${ARCH} STREQUAL "spirv64" )
if( ${ARCH} STREQUAL "spirv" )
set( t "spir--" )
Expand All @@ -416,6 +417,14 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
elseif( ${ARCH} STREQUAL "nvptx" OR ${ARCH} STREQUAL "nvptx64" )
set( build_flags )
set( opt_flags -O3 "--nvvm-reflect-enable=false" )
# Note: when declaring builtins, we don't consider NVIDIA as supporting
# the generic address space. This is because it maps to the same target
# address space as the private address space, resulting in a mangling
# clash.
# Since we can't declare builtins overloaded on both address spaces
# simultaneously, we choose declare the builtins using the private space,
# which will also work for the generic address space.
set( supports_generic_addrspace FALSE )
elseif( ${ARCH} STREQUAL "clspv64" )
set( t "spir64--" )
set( build_flags "-Wno-unknown-assumption")
Expand All @@ -437,8 +446,10 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
"+cl_khr_fp16,"
"+__opencl_c_3d_image_writes,"
"+__opencl_c_images,"
"+cl_khr_3d_image_writes,"
"+__opencl_c_generic_address_space")
"+cl_khr_3d_image_writes")
if(supports_generic_addrspace)
string( APPEND CL_3_0_EXTENSIONS ",+__opencl_c_generic_address_space" )
endif()
list( APPEND flags ${CL_3_0_EXTENSIONS})

# Add platform specific flags
Expand Down
5 changes: 5 additions & 0 deletions libclc/generic/include/clc/math/fract.inc
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE fract(__CLC_GENTYPE x, global __CLC_GENTYPE *iptr);
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE fract(__CLC_GENTYPE x, local __CLC_GENTYPE *iptr);
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE fract(__CLC_GENTYPE x, private __CLC_GENTYPE *iptr);
#if __OPENCL_C_VERSION__ == CL_VERSION_2_0 || \
(__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && \
defined(__opencl_c_generic_address_space))
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE fract(__CLC_GENTYPE x, generic __CLC_GENTYPE *iptr);
#endif
5 changes: 5 additions & 0 deletions libclc/generic/include/clc/math/frexp.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE frexp(__CLC_GENTYPE x, global __CLC_INTN *iptr);
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE frexp(__CLC_GENTYPE x, local __CLC_INTN *iptr);
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE frexp(__CLC_GENTYPE x, private __CLC_INTN *iptr);
#if __OPENCL_C_VERSION__ == CL_VERSION_2_0 || \
(__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && \
defined(__opencl_c_generic_address_space))
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE frexp(__CLC_GENTYPE x, generic __CLC_INTN *iptr);
#endif
5 changes: 5 additions & 0 deletions libclc/generic/include/clc/math/modf.inc
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE modf(__CLC_GENTYPE x, global __CLC_GENTYPE *iptr);
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE modf(__CLC_GENTYPE x, local __CLC_GENTYPE *iptr);
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE modf(__CLC_GENTYPE x, private __CLC_GENTYPE *iptr);
#if __OPENCL_C_VERSION__ == CL_VERSION_2_0 || \
(__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && \
defined(__opencl_c_generic_address_space))
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE modf(__CLC_GENTYPE x, generic __CLC_GENTYPE *iptr);
#endif
9 changes: 9 additions & 0 deletions libclc/generic/include/clc/math/remquo.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,13 @@
#include <clc/math/gentype.inc>
#undef __CLC_ADDRESS_SPACE

#if __OPENCL_C_VERSION__ == CL_VERSION_2_0 || \
(__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && \
defined(__opencl_c_generic_address_space))
#define __CLC_BODY <clc/math/remquo.inc>
#define __CLC_ADDRESS_SPACE generic
#include <clc/math/gentype.inc>
#undef __CLC_ADDRESS_SPACE
#endif

#undef __CLC_FUNCTION
5 changes: 5 additions & 0 deletions libclc/generic/include/clc/math/sincos.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE sincos (__CLC_GENTYPE x, global __CLC_GENTYPE * cosval);
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE sincos (__CLC_GENTYPE x, local __CLC_GENTYPE * cosval);
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE sincos (__CLC_GENTYPE x, private __CLC_GENTYPE * cosval);
#if __OPENCL_C_VERSION__ == CL_VERSION_2_0 || \
(__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && \
defined(__opencl_c_generic_address_space))
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE sincos (__CLC_GENTYPE x, generic __CLC_GENTYPE * cosval);
#endif
Loading