Skip to content

Commit ea68589

Browse files
authored
[libclc] Reduce include usage in OpenCL builtins (#146840)
This commit starts the process of reducing the amount of code included by OpenCL builtins, hopefully reducing build times in the process. It introduces a minimal OpenCL header - opencl-base.h - which includes only the OpenCL type definitions and the macros necessary for declaring/defining functions. Where the OpenCL builtin implementations would currently include the whole of <clc/opencl/clc.h>, which defines *all* OpenCL builtins, now they include only the specific declaration they need. This mirrors how the CLC builtins are defined.
1 parent 08defcb commit ea68589

34 files changed

+151
-29
lines changed

libclc/opencl/include/clc/opencl/clc.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,7 @@
1515

1616
#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers : enable
1717

18-
#ifdef cl_khr_fp64
19-
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
20-
#endif
21-
22-
#ifdef cl_khr_fp16
23-
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
24-
#endif
25-
26-
/* Function Attributes */
27-
#include <clc/clcfunc.h>
28-
29-
/* 6.1 Supported Data Types */
30-
#include <clc/clctypes.h>
18+
#include <clc/opencl/opencl-base.h>
3119

3220
/* 6.2.3 Explicit Conversions */
3321
#include <clc/opencl/convert.h>

libclc/opencl/include/clc/opencl/integer/abs.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,12 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#ifndef __CLC_OPENCL_INTEGER_ABS_H__
10+
#define __CLC_OPENCL_INTEGER_ABS_H__
11+
12+
#include <clc/opencl/opencl-base.h>
13+
914
#define __CLC_BODY <clc/opencl/integer/abs.inc>
1015
#include <clc/integer/gentype.inc>
16+
17+
#endif // __CLC_OPENCL_INTEGER_ABS_H__

libclc/opencl/include/clc/opencl/integer/abs_diff.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,12 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#ifndef __CLC_OPENCL_INTEGER_ABS_DIFF_H__
10+
#define __CLC_OPENCL_INTEGER_ABS_DIFF_H__
11+
12+
#include <clc/opencl/opencl-base.h>
13+
914
#define __CLC_BODY <clc/opencl/integer/abs_diff.inc>
1015
#include <clc/integer/gentype.inc>
16+
17+
#endif // __CLC_OPENCL_INTEGER_ABS_DIFF_H__

libclc/opencl/include/clc/opencl/integer/add_sat.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#ifndef __CLC_OPENCL_INTEGER_ADD_SAT_H__
10+
#define __CLC_OPENCL_INTEGER_ADD_SAT_H__
11+
12+
#include <clc/opencl/opencl-base.h>
13+
914
#define FUNCTION add_sat
1015
#define __CLC_BODY <clc/shared/binary_decl.inc>
1116

1217
#include <clc/integer/gentype.inc>
1318

1419
#undef FUNCTION
20+
21+
#endif // __CLC_OPENCL_INTEGER_ADD_SAT_H__

libclc/opencl/include/clc/opencl/integer/clz.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#ifndef __CLC_OPENCL_INTEGER_CLZ_H__
10+
#define __CLC_OPENCL_INTEGER_CLZ_H__
11+
12+
#include <clc/opencl/opencl-base.h>
13+
914
#define FUNCTION clz
1015
#define __CLC_BODY <clc/shared/unary_decl.inc>
1116

1217
#include <clc/integer/gentype.inc>
1318

1419
#undef FUNCTION
20+
21+
#endif // __CLC_OPENCL_INTEGER_CLZ_H__

libclc/opencl/include/clc/opencl/integer/ctz.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#ifndef __CLC_OPENCL_INTEGER_CTZ_H__
10+
#define __CLC_OPENCL_INTEGER_CTZ_H__
11+
912
#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
1013

14+
#include <clc/opencl/opencl-base.h>
15+
1116
#define FUNCTION ctz
1217
#define __CLC_BODY <clc/shared/unary_decl.inc>
1318

@@ -16,3 +21,5 @@
1621
#undef FUNCTION
1722

1823
#endif // __OPENCL_C_VERSION__ >= CL_VERSION_2_0
24+
25+
#endif // __CLC_OPENCL_INTEGER_CTZ_H__

libclc/opencl/include/clc/opencl/integer/hadd.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#ifndef __CLC_OPENCL_INTEGER_HADD_H__
10+
#define __CLC_OPENCL_INTEGER_HADD_H__
11+
12+
#include <clc/opencl/opencl-base.h>
13+
914
#define FUNCTION hadd
1015
#define __CLC_BODY <clc/shared/binary_decl.inc>
1116

1217
#include <clc/integer/gentype.inc>
1318

1419
#undef FUNCTION
20+
21+
#endif // __CLC_OPENCL_INTEGER_HADD_H__

libclc/opencl/include/clc/opencl/integer/mad24.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#ifndef __CLC_OPENCL_INTEGER_MAD24_H__
10+
#define __CLC_OPENCL_INTEGER_MAD24_H__
11+
12+
#include <clc/opencl/opencl-base.h>
13+
914
#define FUNCTION mad24
1015
#define __CLC_BODY <clc/shared/ternary_decl.inc>
1116

1217
#include <clc/integer/gentype24.inc>
1318

1419
#undef FUNCTION
20+
21+
#endif // __CLC_OPENCL_INTEGER_MAD24_H__

libclc/opencl/include/clc/opencl/integer/mad_hi.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#ifndef __CLC_OPENCL_INTEGER_MAD_HI_H__
10+
#define __CLC_OPENCL_INTEGER_MAD_HI_H__
11+
12+
#include <clc/opencl/opencl-base.h>
13+
914
#define FUNCTION mad_hi
1015
#define __CLC_BODY <clc/shared/ternary_decl.inc>
1116

1217
#include <clc/integer/gentype.inc>
1318

1419
#undef FUNCTION
20+
21+
#endif // __CLC_OPENCL_INTEGER_MAD_HI_H__

libclc/opencl/include/clc/opencl/integer/mad_sat.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#ifndef __CLC_OPENCL_INTEGER_MAD_SAT_H__
10+
#define __CLC_OPENCL_INTEGER_MAD_SAT_H__
11+
12+
#include <clc/opencl/opencl-base.h>
13+
914
#define FUNCTION mad_sat
1015
#define __CLC_BODY <clc/shared/ternary_decl.inc>
1116

1217
#include <clc/integer/gentype.inc>
1318

1419
#undef FUNCTION
20+
21+
#endif // __CLC_OPENCL_INTEGER_MAD_SAT_H__

0 commit comments

Comments
 (0)