Skip to content

Commit 6111d62

Browse files
authored
Merge branch 'intel:sycl' into sycl
2 parents 6bd9aff + 861161a commit 6111d62

File tree

7 files changed

+451
-109
lines changed

7 files changed

+451
-109
lines changed

.github/workflows/gh_pages.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ jobs:
5454
git config --global user.name "iclsrc"
5555
git config --global user.email "[email protected]"
5656
git add .
57-
git diff-index --quiet HEAD || git commit -m "Update docs" -s
58-
git push
57+
git diff-index --quiet HEAD || git commit --amend -m "Update docs" -s
58+
git push -f
Lines changed: 37 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,46 @@
1-
// RUN: %clang_cc1 -fsycl-is-host -triple x86_64-pc-linux-gnu -fsyntax-only -verify %s -DSYCLHOST
2-
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -verify %s
1+
// RUN: %clang_cc1 -fsycl-is-host -triple x86_64-pc-linux-gnu -fsyntax-only -verify %s
2+
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -verify=device %s
33

44
// Test checks the attribute is silently ignored during host compilation
55
// where -fsycl-is-host is passed on cc1.
66

7-
#ifdef SYCLHOST
87
// expected-no-diagnostics
9-
#endif
108

119
void foo()
1210
{
13-
#ifndef SYCLHOST
14-
// expected-warning@+2 {{'doublepump' attribute ignored}}
15-
#endif
16-
[[intel::doublepump]] unsigned int v_one[64];
17-
18-
#ifndef SYCLHOST
19-
// expected-warning@+2 {{'fpga_memory' attribute ignored}}
20-
#endif
21-
[[intel::fpga_memory]] unsigned int v_two[64];
22-
23-
#ifndef SYCLHOST
24-
// expected-warning@+2 {{'fpga_register' attribute ignored}}
25-
#endif
26-
[[intel::fpga_register]] unsigned int v_three[64];
27-
28-
#ifndef SYCLHOST
29-
// expected-warning@+2 {{'singlepump' attribute ignored}}
30-
#endif
31-
[[intel::singlepump]] unsigned int v_four[64];
32-
33-
#ifndef SYCLHOST
34-
// expected-warning@+2 {{'bankwidth' attribute ignored}}
35-
#endif
36-
[[intel::bankwidth(4)]] unsigned int v_five[32];
37-
38-
#ifndef SYCLHOST
39-
// expected-warning@+2 {{'numbanks' attribute ignored}}
40-
#endif
41-
[[intel::numbanks(8)]] unsigned int v_six[32];
42-
43-
#ifndef SYCLHOST
44-
// expected-warning@+2 {{'private_copies' attribute ignored}}
45-
#endif
46-
[[intel::private_copies(8)]] unsigned int v_seven[64];
47-
48-
#ifndef SYCLHOST
49-
// expected-warning@+2 {{'merge' attribute ignored}}
50-
#endif
51-
[[intel::merge("mrg1", "depth")]] unsigned int v_eight[64];
52-
53-
#ifndef SYCLHOST
54-
// expected-warning@+2 {{'max_replicates' attribute ignored}}
55-
#endif
56-
[[intel::max_replicates(2)]] unsigned int v_nine[64];
57-
58-
#ifndef SYCLHOST
59-
// expected-warning@+2 {{'simple_dual_port' attribute ignored}}
60-
#endif
61-
[[intel::simple_dual_port]] unsigned int v_ten[64];
62-
63-
#ifndef SYCLHOST
64-
// expected-warning@+2 {{'bank_bits' attribute ignored}}
65-
#endif
66-
[[intel::bank_bits(2, 3, 4, 5)]] unsigned int v_eleven[64];
67-
68-
#ifndef SYCLHOST
69-
// expected-warning@+2 {{'use_stall_enable_clusters' attribute ignored}}
70-
#endif
71-
[[intel::use_stall_enable_clusters]] void func();
72-
73-
#ifndef SYCLHOST
74-
// expected-warning@+2 {{'max_global_work_dim' attribute ignored}}
75-
#endif
76-
[[intel::max_global_work_dim(1)]] void func1();
77-
78-
#ifndef SYCLHOST
79-
// expected-warning@+2 {{'scheduler_target_fmax_mhz' attribute ignored}}
80-
#endif
81-
[[intel::scheduler_target_fmax_mhz(3)]] void func2();
82-
83-
#ifndef SYCLHOST
84-
// expected-warning@+2 {{'kernel_args_restrict' attribute ignored}}
85-
#endif
86-
[[intel::kernel_args_restrict]] void func3();
87-
88-
#ifndef SYCLHOST
89-
// expected-warning@+2 {{'num_simd_work_items' attribute ignored}}
90-
#endif
91-
[[intel::num_simd_work_items(12)]] void func4();
92-
93-
#ifndef SYCLHOST
94-
// expected-warning@+2 {{'max_work_group_size' attribute ignored}}
95-
#endif
96-
[[intel::max_work_group_size(32, 32, 32)]] void func5();
11+
[[intel::doublepump]] unsigned int v_one[64]; // device-warning {{'doublepump' attribute ignored}}
12+
13+
[[intel::fpga_memory]] unsigned int v_two[64]; // device-warning {{'fpga_memory' attribute ignored}}
14+
15+
[[intel::fpga_register]] unsigned int v_three[64]; // device-warning {{'fpga_register' attribute ignored}}
16+
17+
[[intel::singlepump]] unsigned int v_four[64]; // device-warning {{'singlepump' attribute ignored}}
18+
19+
[[intel::bankwidth(4)]] unsigned int v_five[32]; // device-warning {{'bankwidth' attribute ignored}}
20+
21+
[[intel::numbanks(8)]] unsigned int v_six[32]; // device-warning {{'numbanks' attribute ignored}}
22+
23+
[[intel::private_copies(8)]] unsigned int v_seven[64]; // device-warning {{'private_copies' attribute ignored}}
24+
25+
[[intel::merge("mrg1", "depth")]] unsigned int v_eight[64]; // device-warning {{'merge' attribute ignored}}
26+
27+
[[intel::max_replicates(2)]] unsigned int v_nine[64]; // device-warning {{'max_replicates' attribute ignored}}
28+
29+
[[intel::simple_dual_port]] unsigned int v_ten[64]; // device-warning {{'simple_dual_port' attribute ignored}}
30+
31+
[[intel::bank_bits(2, 3, 4, 5)]] unsigned int v_eleven[64]; // device-warning {{'bank_bits' attribute ignored}}
32+
33+
[[intel::use_stall_enable_clusters]] void func(); // device-warning {{'use_stall_enable_clusters' attribute ignored}}
34+
35+
[[intel::max_global_work_dim(1)]] void func1(); // device-warning {{'max_global_work_dim' attribute ignored}}
36+
37+
[[intel::scheduler_target_fmax_mhz(3)]] void func2(); // device-warning {{'scheduler_target_fmax_mhz' attribute ignored}}
38+
39+
[[intel::kernel_args_restrict]] void func3(); // device-warning {{'kernel_args_restrict' attribute ignored}}
40+
41+
[[intel::num_simd_work_items(12)]] void func4(); // device-warning {{'num_simd_work_items' attribute ignored}}
42+
43+
[[intel::max_work_group_size(32, 32, 32)]] void func5(); // device-warning {{'max_work_group_size' attribute ignored}}
44+
45+
[[intel::device_indirectly_callable]] void func6(); // device-warning {{'device_indirectly_callable' attribute ignored}}
9746
}

sycl/include/CL/sycl/half_type.hpp

Lines changed: 194 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -386,14 +386,200 @@ class half {
386386
operator--();
387387
return ret;
388388
}
389-
constexpr half &operator-() {
390-
Data = -Data;
391-
return *this;
392-
}
393-
constexpr half operator-() const {
394-
half r = *this;
395-
return -r;
396-
}
389+
__SYCL_CONSTEXPR_HALF friend half operator-(const half other) {
390+
return half(-other.Data);
391+
}
392+
393+
// Operator +, -, *, /
394+
#define OP(op, op_eq) \
395+
__SYCL_CONSTEXPR_HALF friend half operator op(const half lhs, \
396+
const half rhs) { \
397+
half rtn = lhs; \
398+
rtn op_eq rhs; \
399+
return rtn; \
400+
} \
401+
__SYCL_CONSTEXPR_HALF friend double operator op(const half lhs, \
402+
const double rhs) { \
403+
double rtn = lhs; \
404+
rtn op_eq rhs; \
405+
return rtn; \
406+
} \
407+
__SYCL_CONSTEXPR_HALF friend double operator op(const double lhs, \
408+
const half rhs) { \
409+
double rtn = lhs; \
410+
rtn op_eq rhs; \
411+
return rtn; \
412+
} \
413+
__SYCL_CONSTEXPR_HALF friend float operator op(const half lhs, \
414+
const float rhs) { \
415+
float rtn = lhs; \
416+
rtn op_eq rhs; \
417+
return rtn; \
418+
} \
419+
__SYCL_CONSTEXPR_HALF friend float operator op(const float lhs, \
420+
const half rhs) { \
421+
float rtn = lhs; \
422+
rtn op_eq rhs; \
423+
return rtn; \
424+
} \
425+
__SYCL_CONSTEXPR_HALF friend half operator op(const half lhs, \
426+
const int rhs) { \
427+
half rtn = lhs; \
428+
rtn op_eq rhs; \
429+
return rtn; \
430+
} \
431+
__SYCL_CONSTEXPR_HALF friend half operator op(const int lhs, \
432+
const half rhs) { \
433+
half rtn = lhs; \
434+
rtn op_eq rhs; \
435+
return rtn; \
436+
} \
437+
__SYCL_CONSTEXPR_HALF friend half operator op(const half lhs, \
438+
const long rhs) { \
439+
half rtn = lhs; \
440+
rtn op_eq rhs; \
441+
return rtn; \
442+
} \
443+
__SYCL_CONSTEXPR_HALF friend half operator op(const long lhs, \
444+
const half rhs) { \
445+
half rtn = lhs; \
446+
rtn op_eq rhs; \
447+
return rtn; \
448+
} \
449+
__SYCL_CONSTEXPR_HALF friend half operator op(const half lhs, \
450+
const long long rhs) { \
451+
half rtn = lhs; \
452+
rtn op_eq rhs; \
453+
return rtn; \
454+
} \
455+
__SYCL_CONSTEXPR_HALF friend half operator op(const long long lhs, \
456+
const half rhs) { \
457+
half rtn = lhs; \
458+
rtn op_eq rhs; \
459+
return rtn; \
460+
} \
461+
__SYCL_CONSTEXPR_HALF friend half operator op(const half &lhs, \
462+
const unsigned int &rhs) { \
463+
half rtn = lhs; \
464+
rtn op_eq rhs; \
465+
return rtn; \
466+
} \
467+
__SYCL_CONSTEXPR_HALF friend half operator op(const unsigned int &lhs, \
468+
const half &rhs) { \
469+
half rtn = lhs; \
470+
rtn op_eq rhs; \
471+
return rtn; \
472+
} \
473+
__SYCL_CONSTEXPR_HALF friend half operator op(const half &lhs, \
474+
const unsigned long &rhs) { \
475+
half rtn = lhs; \
476+
rtn op_eq rhs; \
477+
return rtn; \
478+
} \
479+
__SYCL_CONSTEXPR_HALF friend half operator op(const unsigned long &lhs, \
480+
const half &rhs) { \
481+
half rtn = lhs; \
482+
rtn op_eq rhs; \
483+
return rtn; \
484+
} \
485+
__SYCL_CONSTEXPR_HALF friend half operator op( \
486+
const half &lhs, const unsigned long long &rhs) { \
487+
half rtn = lhs; \
488+
rtn op_eq rhs; \
489+
return rtn; \
490+
} \
491+
__SYCL_CONSTEXPR_HALF friend half operator op(const unsigned long long &lhs, \
492+
const half &rhs) { \
493+
half rtn = lhs; \
494+
rtn op_eq rhs; \
495+
return rtn; \
496+
}
497+
OP(+, +=)
498+
OP(-, -=)
499+
OP(*, *=)
500+
OP(/, /=)
501+
502+
#undef OP
503+
504+
// Operator ==, !=, <, >, <=, >=
505+
#define OP(op) \
506+
__SYCL_CONSTEXPR_HALF friend bool operator op(const half &lhs, \
507+
const half &rhs) { \
508+
return lhs.Data op rhs.Data; \
509+
} \
510+
__SYCL_CONSTEXPR_HALF friend bool operator op(const half &lhs, \
511+
const double &rhs) { \
512+
return lhs.Data op rhs; \
513+
} \
514+
__SYCL_CONSTEXPR_HALF friend bool operator op(const double &lhs, \
515+
const half &rhs) { \
516+
return lhs op rhs.Data; \
517+
} \
518+
__SYCL_CONSTEXPR_HALF friend bool operator op(const half &lhs, \
519+
const float &rhs) { \
520+
return lhs.Data op rhs; \
521+
} \
522+
__SYCL_CONSTEXPR_HALF friend bool operator op(const float &lhs, \
523+
const half &rhs) { \
524+
return lhs op rhs.Data; \
525+
} \
526+
__SYCL_CONSTEXPR_HALF friend bool operator op(const half &lhs, \
527+
const int &rhs) { \
528+
return lhs.Data op rhs; \
529+
} \
530+
__SYCL_CONSTEXPR_HALF friend bool operator op(const int &lhs, \
531+
const half &rhs) { \
532+
return lhs op rhs.Data; \
533+
} \
534+
__SYCL_CONSTEXPR_HALF friend bool operator op(const half &lhs, \
535+
const long &rhs) { \
536+
return lhs.Data op rhs; \
537+
} \
538+
__SYCL_CONSTEXPR_HALF friend bool operator op(const long &lhs, \
539+
const half &rhs) { \
540+
return lhs op rhs.Data; \
541+
} \
542+
__SYCL_CONSTEXPR_HALF friend bool operator op(const half &lhs, \
543+
const long long &rhs) { \
544+
return lhs.Data op rhs; \
545+
} \
546+
__SYCL_CONSTEXPR_HALF friend bool operator op(const long long &lhs, \
547+
const half &rhs) { \
548+
return lhs op rhs.Data; \
549+
} \
550+
__SYCL_CONSTEXPR_HALF friend bool operator op(const half &lhs, \
551+
const unsigned int &rhs) { \
552+
return lhs.Data op rhs; \
553+
} \
554+
__SYCL_CONSTEXPR_HALF friend bool operator op(const unsigned int &lhs, \
555+
const half &rhs) { \
556+
return lhs op rhs.Data; \
557+
} \
558+
__SYCL_CONSTEXPR_HALF friend bool operator op(const half &lhs, \
559+
const unsigned long &rhs) { \
560+
return lhs.Data op rhs; \
561+
} \
562+
__SYCL_CONSTEXPR_HALF friend bool operator op(const unsigned long &lhs, \
563+
const half &rhs) { \
564+
return lhs op rhs.Data; \
565+
} \
566+
__SYCL_CONSTEXPR_HALF friend bool operator op( \
567+
const half &lhs, const unsigned long long &rhs) { \
568+
return lhs.Data op rhs; \
569+
} \
570+
__SYCL_CONSTEXPR_HALF friend bool operator op(const unsigned long long &lhs, \
571+
const half &rhs) { \
572+
return lhs op rhs.Data; \
573+
}
574+
OP(==)
575+
OP(!=)
576+
OP(<)
577+
OP(>)
578+
OP(<=)
579+
OP(>=)
580+
581+
#undef OP
582+
397583
// Operator float
398584
__SYCL_CONSTEXPR_HALF operator float() const {
399585
return static_cast<float>(Data);

0 commit comments

Comments
 (0)