Skip to content
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
10 changes: 7 additions & 3 deletions libclc/libspirv/lib/generic/math/half_cos.cl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
//
//===----------------------------------------------------------------------===//

#include <clc/math/clc_half_cos.h>
#include <libspirv/spirv.h>

#define __CLC_BUILTIN __spirv_ocl_cos
#define __CLC_FUNCTION __spirv_ocl_half_cos
#include <clc/math/unary_builtin_scalarize.inc>
#define __FLOAT_ONLY
#define FUNCTION __spirv_ocl_half_cos
#define __IMPL_FUNCTION(x) __clc_half_cos
#define __CLC_BODY <clc/shared/unary_def.inc>
Comment on lines +12 to +15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not going to let it block this PR, as I don't think it's new to it, but I don't particularly like the naming of these macros. It seems very inconsistent that FUNCTION doesn't use the "reserved" naming with __ prefixed, then we have something as generic as __FLOAT_ONLY. Previously everything was prefixed with __CLC_ to make the association to libclc clear, but now it's only __CLC_BODY, in which the CLC mention now feels redundant given it isn't actually related to the others.

My point is, I prefer the __CLC_ prefix on these, as at the very least it makes their relationship clear. As a reader of this, having __CLC_ on all of these makes it clear to me that they are all intended for the CLC definition generators. I suggest the following names as a follow-up:

Suggested change
#define __FLOAT_ONLY
#define FUNCTION __spirv_ocl_half_cos
#define __IMPL_FUNCTION(x) __clc_half_cos
#define __CLC_BODY <clc/shared/unary_def.inc>
#define __CLC_GENERATE_FLOAT_ONLY
#define __CLC_FUNCTION __spirv_ocl_half_cos
#define __CLC_IMPL_FUNCTION(x) __clc_half_cos
#define __CLC_BODY <clc/shared/unary_def.inc>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point is, I prefer the __CLC_ prefix on these, as at the very least it makes their relationship clear. As a reader of this, having __CLC_ on all of these makes it clear to me that they are all intended for the CLC definition generators. I suggest the following names as a follow-up:

thanks @steffenlarsen for the suggestion. I've created PR llvm/llvm-project#153523 to add _CLC to all macros.


#include <clc/math/gentype.inc>
10 changes: 6 additions & 4 deletions libclc/libspirv/lib/generic/math/half_divide.cl
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
//
//===----------------------------------------------------------------------===//

#include <clc/math/clc_half_divide.h>
#include <libspirv/spirv.h>

#define divide(x, y) (x / y)
#define __FLOAT_ONLY
#define FUNCTION __spirv_ocl_half_divide
#define __IMPL_FUNCTION(x) __clc_half_divide
#define __CLC_BODY <clc/shared/binary_def.inc>

#define __CLC_BUILTIN divide
#define __CLC_FUNCTION __spirv_ocl_half_divide
#include <clc/math/binary_builtin.inc>
#include <clc/math/gentype.inc>
10 changes: 7 additions & 3 deletions libclc/libspirv/lib/generic/math/half_exp.cl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
//
//===----------------------------------------------------------------------===//

#include <clc/math/clc_half_exp.h>
#include <libspirv/spirv.h>

#define __CLC_BUILTIN __spirv_ocl_exp
#define __CLC_FUNCTION __spirv_ocl_half_exp
#include <clc/math/unary_builtin_scalarize.inc>
#define __FLOAT_ONLY
#define FUNCTION __spirv_ocl_half_exp
#define __IMPL_FUNCTION(x) __clc_half_exp
#define __CLC_BODY <clc/shared/unary_def.inc>

#include <clc/math/gentype.inc>
10 changes: 7 additions & 3 deletions libclc/libspirv/lib/generic/math/half_exp10.cl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
//
//===----------------------------------------------------------------------===//

#include <clc/math/clc_half_exp10.h>
#include <libspirv/spirv.h>

#define __CLC_BUILTIN __spirv_ocl_exp10
#define __CLC_FUNCTION __spirv_ocl_half_exp10
#include <clc/math/unary_builtin_scalarize.inc>
#define __FLOAT_ONLY
#define FUNCTION __spirv_ocl_half_exp10
#define __IMPL_FUNCTION(x) __clc_half_exp10
#define __CLC_BODY <clc/shared/unary_def.inc>

#include <clc/math/gentype.inc>
10 changes: 7 additions & 3 deletions libclc/libspirv/lib/generic/math/half_exp2.cl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
//
//===----------------------------------------------------------------------===//

#include <clc/math/clc_half_exp2.h>
#include <libspirv/spirv.h>

#define __CLC_BUILTIN __spirv_ocl_exp2
#define __CLC_FUNCTION __spirv_ocl_half_exp2
#include <clc/math/unary_builtin_scalarize.inc>
#define __FLOAT_ONLY
#define FUNCTION __spirv_ocl_half_exp2
#define __IMPL_FUNCTION(x) __clc_half_exp2
#define __CLC_BODY <clc/shared/unary_def.inc>

#include <clc/math/gentype.inc>
10 changes: 7 additions & 3 deletions libclc/libspirv/lib/generic/math/half_log.cl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
//
//===----------------------------------------------------------------------===//

#include <clc/math/clc_half_log.h>
#include <libspirv/spirv.h>

#define __CLC_BUILTIN __spirv_ocl_log
#define __CLC_FUNCTION __spirv_ocl_half_log
#include <clc/math/unary_builtin_scalarize.inc>
#define __FLOAT_ONLY
#define FUNCTION __spirv_ocl_half_log
#define __IMPL_FUNCTION(x) __clc_half_log
#define __CLC_BODY <clc/shared/unary_def.inc>

#include <clc/math/gentype.inc>
10 changes: 7 additions & 3 deletions libclc/libspirv/lib/generic/math/half_log10.cl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
//
//===----------------------------------------------------------------------===//

#include <clc/math/clc_half_log10.h>
#include <libspirv/spirv.h>

#define __CLC_BUILTIN __spirv_ocl_log10
#define __CLC_FUNCTION __spirv_ocl_half_log10
#include <clc/math/unary_builtin_scalarize.inc>
#define __FLOAT_ONLY
#define FUNCTION __spirv_ocl_half_log10
#define __IMPL_FUNCTION(x) __clc_half_log10
#define __CLC_BODY <clc/shared/unary_def.inc>

#include <clc/math/gentype.inc>
10 changes: 7 additions & 3 deletions libclc/libspirv/lib/generic/math/half_log2.cl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
//
//===----------------------------------------------------------------------===//

#include <clc/math/clc_half_log2.h>
#include <libspirv/spirv.h>

#define __CLC_BUILTIN __spirv_ocl_log2
#define __CLC_FUNCTION __spirv_ocl_half_log2
#include <clc/math/unary_builtin_scalarize.inc>
#define __FLOAT_ONLY
#define FUNCTION __spirv_ocl_half_log2
#define __IMPL_FUNCTION(x) __clc_half_log2
#define __CLC_BODY <clc/shared/unary_def.inc>

#include <clc/math/gentype.inc>
10 changes: 7 additions & 3 deletions libclc/libspirv/lib/generic/math/half_powr.cl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
//
//===----------------------------------------------------------------------===//

#include <clc/math/clc_half_powr.h>
#include <libspirv/spirv.h>

#define __CLC_BUILTIN __spirv_ocl_powr
#define __CLC_FUNCTION __spirv_ocl_half_powr
#include <clc/math/binary_builtin.inc>
#define __FLOAT_ONLY
#define FUNCTION __spirv_ocl_half_powr
#define __IMPL_FUNCTION(x) __clc_half_powr
#define __CLC_BODY <clc/shared/binary_def.inc>

#include <clc/math/gentype.inc>
10 changes: 6 additions & 4 deletions libclc/libspirv/lib/generic/math/half_recip.cl
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
//
//===----------------------------------------------------------------------===//

#include <clc/math/clc_half_recip.h>
#include <libspirv/spirv.h>

#define recip(x) (1.0f / x)
#define __FLOAT_ONLY
#define FUNCTION __spirv_ocl_half_recip
#define __IMPL_FUNCTION(x) __clc_half_recip
#define __CLC_BODY <clc/shared/unary_def.inc>

#define __CLC_BUILTIN recip
#define __CLC_FUNCTION __spirv_ocl_half_recip
#include <clc/math/unary_builtin_scalarize.inc>
#include <clc/math/gentype.inc>
10 changes: 7 additions & 3 deletions libclc/libspirv/lib/generic/math/half_rsqrt.cl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
//
//===----------------------------------------------------------------------===//

#include <clc/math/clc_half_rsqrt.h>
#include <libspirv/spirv.h>

#define __CLC_BUILTIN __spirv_ocl_rsqrt
#define __CLC_FUNCTION __spirv_ocl_half_rsqrt
#include <clc/math/unary_builtin_scalarize.inc>
#define __FLOAT_ONLY
#define FUNCTION __spirv_ocl_half_rsqrt
#define __IMPL_FUNCTION(x) __clc_half_rsqrt
#define __CLC_BODY <clc/shared/unary_def.inc>

#include <clc/math/gentype.inc>
10 changes: 7 additions & 3 deletions libclc/libspirv/lib/generic/math/half_sin.cl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
//
//===----------------------------------------------------------------------===//

#include <clc/math/clc_half_sin.h>
#include <libspirv/spirv.h>

#define __CLC_BUILTIN __spirv_ocl_sin
#define __CLC_FUNCTION __spirv_ocl_half_sin
#include <clc/math/unary_builtin_scalarize.inc>
#define __FLOAT_ONLY
#define FUNCTION __spirv_ocl_half_sin
#define __IMPL_FUNCTION(x) __clc_half_sin
#define __CLC_BODY <clc/shared/unary_def.inc>

#include <clc/math/gentype.inc>
10 changes: 7 additions & 3 deletions libclc/libspirv/lib/generic/math/half_sqrt.cl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
//
//===----------------------------------------------------------------------===//

#include <clc/math/clc_half_sqrt.h>
#include <libspirv/spirv.h>

#define __CLC_BUILTIN __spirv_ocl_sqrt
#define __CLC_FUNCTION __spirv_ocl_half_sqrt
#include <clc/math/unary_builtin_scalarize.inc>
#define __FLOAT_ONLY
#define FUNCTION __spirv_ocl_half_sqrt
#define __IMPL_FUNCTION(x) __clc_half_sqrt
#define __CLC_BODY <clc/shared/unary_def.inc>

#include <clc/math/gentype.inc>
10 changes: 7 additions & 3 deletions libclc/libspirv/lib/generic/math/half_tan.cl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
//
//===----------------------------------------------------------------------===//

#include <clc/math/clc_half_tan.h>
#include <libspirv/spirv.h>

#define __CLC_BUILTIN __spirv_ocl_tan
#define __CLC_FUNCTION __spirv_ocl_half_tan
#include <clc/math/unary_builtin_scalarize.inc>
#define __FLOAT_ONLY
#define FUNCTION __spirv_ocl_half_tan
#define __IMPL_FUNCTION(x) __clc_half_tan
#define __CLC_BODY <clc/shared/unary_def.inc>

#include <clc/math/gentype.inc>
Loading