Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix OpenCL 1.2 double as an optional core feature behaviour
In OpenCL 1.2, using double no longer requires using the pragma cl_khr_fp64, instead a kernel is allowed to use double, but must first have queried clGetDeviceInfo's CL_DEVICE_DOUBLE_FP_CONFIG. Page 197, section 6.1.1 of the OpenCL 1.2 specification has a footnote 23 describing this behaviour. I've also added test cases such that the pragma must be used if targeting OpenCL 1.0 or 1.1, but is ignored in 1.2 and 2.0. Patch by Neil Henning! Reviewers: Pekka Jääskeläinen Differential Revision: http://reviews.llvm.org/D7245 llvm-svn: 227565
- Loading branch information
1 parent
9469a59
commit cc6e894
Showing
5 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 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,19 @@ | ||
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.1 | ||
|
||
void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}} | ||
double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}} | ||
(void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}} | ||
} | ||
|
||
#pragma OPENCL EXTENSION cl_khr_fp64 : enable | ||
|
||
void f2(void) { | ||
double d; | ||
(void) 1.0; | ||
} | ||
|
||
#pragma OPENCL EXTENSION cl_khr_fp64 : disable | ||
|
||
void f3(void) { | ||
double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}} | ||
} |
This file contains 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,20 @@ | ||
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2 | ||
// expected-no-diagnostics | ||
|
||
void f1(double da) { | ||
double d; | ||
(void) 1.0; | ||
} | ||
|
||
#pragma OPENCL EXTENSION cl_khr_fp64 : enable | ||
|
||
void f2(void) { | ||
double d; | ||
(void) 1.0; | ||
} | ||
|
||
#pragma OPENCL EXTENSION cl_khr_fp64 : disable | ||
|
||
void f3(void) { | ||
double d; | ||
} |
This file contains 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,20 @@ | ||
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 | ||
// expected-no-diagnostics | ||
|
||
void f1(double da) { | ||
double d; | ||
(void) 1.0; | ||
} | ||
|
||
#pragma OPENCL EXTENSION cl_khr_fp64 : enable | ||
|
||
void f2(void) { | ||
double d; | ||
(void) 1.0; | ||
} | ||
|
||
#pragma OPENCL EXTENSION cl_khr_fp64 : disable | ||
|
||
void f3(void) { | ||
double d; | ||
} |