-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix native builtins with double as the input.
If double was used as the input for the native builtins then we would get a link error. native builtins don't have an overload for double but we were providing one. This was also true of some half native builtins. Removing from the overloads fixes the issue as double or half are then cast to float.
- Loading branch information
Showing
9 changed files
with
1,732 additions
and
96 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
55 changes: 55 additions & 0 deletions
55
source/cl/test/UnitCL/kernels/regression.109_libm_native_double_input.cl
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,55 @@ | ||
// Copyright (C) Codeplay Software Limited | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License") with LLVM | ||
// Exceptions; you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://github.com/codeplaysoftware/oneapi-construction-kit/blob/main/LICENSE.txt | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
// License for the specific language governing permissions and limitations | ||
// under the License. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
// CLC OPTIONS: -cl-fast-relaxed-math | ||
// SPIRV OPTIONS: -cl-fast-relaxed-math | ||
|
||
// The purpose of this test is to exercise builtin native functions where we use | ||
// half as input. We use the same logic as other testing of builtin functions | ||
// where we give opportunity to be replaced by LLVM intrinsics, which may in | ||
// turn be replaced by calls to libm. That can either only happen when libm is | ||
// accessible (e.g. by the loader linking in libm functions). | ||
// | ||
// This test specifically requires fast-math because that gives the compiler | ||
// more lee-way to do the replacement. | ||
|
||
// To avoid needing to account for ULP errors in the various functions being | ||
// tested, just compare the result against an impossible value (for the given | ||
// inputs, which the compiler does not know). For the trig functions a smart | ||
// compiler could maybe figure out that the comparison is impossible, but at | ||
// the time of writing ComputeAorta is not that smart. | ||
|
||
// REQUIRES: double | ||
|
||
#define BIG_VALF 5.0f | ||
|
||
kernel void libm_native_double_input(__global double* in, __global double* out) { | ||
uint index = 0; | ||
|
||
out[index] = native_cos(in[index]) >= BIG_VALF ? 2.0f : 1.0f; index++; | ||
out[index] = native_exp(in[index]) >= BIG_VALF ? 2.0f : 1.0f; index++; | ||
out[index] = native_exp2(in[index]) >= BIG_VALF ? 2.0f : 1.0f; index++; | ||
out[index] = native_exp10(in[index]) >= BIG_VALF * 3.0 ? 2.0f : 1.0f; index++; | ||
out[index] = native_log(in[index]) >= BIG_VALF ? 2.0f : 1.0f; index++; | ||
out[index] = native_log2(in[index]) >= BIG_VALF ? 2.0f : 1.0f; index++; | ||
out[index] = native_log10(in[index]) >= BIG_VALF ? 2.0f : 1.0f; index++; | ||
out[index] = native_rsqrt(in[index]) >= BIG_VALF ? 2.0f : 1.0f; index++; | ||
out[index] = native_sin(in[index]) >= BIG_VALF ? 2.0f : 1.0f; index++; | ||
out[index] = native_sqrt(in[index]) >= BIG_VALF ? 2.0f : 1.0f; index++; | ||
out[index] = native_divide(in[index], 1000.0) >= BIG_VALF ? 2.0f : 1.0f; index++; | ||
out[index] = native_powr(in[index], 1.0) >= BIG_VALF ? 2.0f : 1.0f; index++; | ||
|
||
} |
369 changes: 369 additions & 0 deletions
369
source/cl/test/UnitCL/kernels/regression.109_libm_native_double_input.spvasm32
Large diffs are not rendered by default.
Oops, something went wrong.
417 changes: 417 additions & 0 deletions
417
source/cl/test/UnitCL/kernels/regression.109_libm_native_double_input.spvasm64
Large diffs are not rendered by default.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
source/cl/test/UnitCL/kernels/regression.110_libm_native_half_input.cl
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,57 @@ | ||
// Copyright (C) Codeplay Software Limited | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License") with LLVM | ||
// Exceptions; you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://github.com/codeplaysoftware/oneapi-construction-kit/blob/main/LICENSE.txt | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
// License for the specific language governing permissions and limitations | ||
// under the License. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
// CLC OPTIONS: -cl-fast-relaxed-math | ||
// SPIRV OPTIONS: -cl-fast-relaxed-math | ||
|
||
// The purpose of this test is to exercise builtin native functions where we use | ||
// half as input. We use the same logic as other testing of builtin functions | ||
// where we give opportunity to be replaced by LLVM intrinsics, which may in | ||
// turn be replaced by calls to libm. That can either only happen when libm is | ||
// accessible (e.g. by the loader linking in libm functions). | ||
// | ||
// This test specifically requires fast-math because that gives the compiler | ||
// more lee-way to do the replacement. | ||
|
||
// To avoid needing to account for ULP errors in the various functions being | ||
// tested, just compare the result against an impossible value (for the given | ||
// inputs, which the compiler does not know). For the trig functions a smart | ||
// compiler could maybe figure out that the comparison is impossible, but at | ||
// the time of writing ComputeAorta is not that smart. | ||
|
||
// REQUIRES: half | ||
|
||
#pragma OPENCL EXTENSION cl_khr_fp16 : enable | ||
|
||
#define BIG_VALF 5.0h | ||
|
||
kernel void libm_native_half_input(__global half* in, __global half* out) { | ||
uint index = 0; | ||
|
||
out[index] = native_cos(in[index]) >= BIG_VALF ? 2.0h : 1.0h; index++; | ||
out[index] = native_exp(in[index]) >= BIG_VALF ? 2.0h : 1.0h; index++; | ||
out[index] = native_exp2(in[index]) >= BIG_VALF ? 2.0h : 1.0h; index++; | ||
out[index] = native_exp10(in[index]) >= BIG_VALF * 3.0 ? 2.0h : 1.0h; index++; | ||
out[index] = native_log(in[index]) >= BIG_VALF ? 2.0h : 1.0h; index++; | ||
out[index] = native_log2(in[index]) >= BIG_VALF ? 2.0h : 1.0h; index++; | ||
out[index] = native_log10(in[index]) >= BIG_VALF ? 2.0h : 1.0h; index++; | ||
out[index] = native_rsqrt(in[index]) >= BIG_VALF ? 2.0h : 1.0h; index++; | ||
out[index] = native_sin(in[index]) >= BIG_VALF ? 2.0h : 1.0h; index++; | ||
out[index] = native_sqrt(in[index]) >= BIG_VALF ? 2.0h : 1.0h; index++; | ||
out[index] = native_divide(in[index], (double)1000.0) >= BIG_VALF ? 2.0h : 1.0h; index++; | ||
out[index] = native_powr(in[index], 1.0h) >= BIG_VALF ? 2.0h : 1.0h; index++; | ||
out[index] = native_divide(in[index], 1000.0h) >= BIG_VALF ? 2.0h : 1.0h; index++; | ||
} |
Oops, something went wrong.