merged with master
This commit is contained in:
270
stdlib.ispc
270
stdlib.ispc
@@ -2403,8 +2403,12 @@ static inline uniform float frexp(uniform float x, uniform int * uniform pw2) {
|
||||
|
||||
__declspec(safe)
|
||||
static inline float sin(float x_full) {
|
||||
if (__math_lib == __math_lib_svml) {
|
||||
return __svml_sinf(x_full);
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
return __sin_varying_float(x_full);
|
||||
}
|
||||
else if (__math_lib == __math_lib_svml) {
|
||||
return __svml_sinf(x_full);
|
||||
}
|
||||
else if (__math_lib == __math_lib_system) {
|
||||
float ret;
|
||||
@@ -2465,7 +2469,11 @@ static inline float sin(float x_full) {
|
||||
|
||||
__declspec(safe)
|
||||
static inline uniform float sin(uniform float x_full) {
|
||||
if (__math_lib == __math_lib_system ||
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
return __sin_uniform_float(x_full);
|
||||
}
|
||||
else if (__math_lib == __math_lib_system ||
|
||||
__math_lib == __math_lib_svml) {
|
||||
return __stdlib_sinf(x_full);
|
||||
}
|
||||
@@ -2530,25 +2538,29 @@ static inline uniform float sin(uniform float x_full) {
|
||||
|
||||
|
||||
__declspec(safe)
|
||||
static inline float asin(float x) {
|
||||
bool isneg = x < 0;
|
||||
x = abs(x);
|
||||
|
||||
static inline float asin(float x0) {
|
||||
bool isneg = x0< 0;
|
||||
float x = abs(x0);
|
||||
bool isnan = (x > 1);
|
||||
|
||||
float v;
|
||||
if (__math_lib == __math_lib_svml) {
|
||||
return __svml_asinf(x);
|
||||
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
return __asin_varying_float(x0);
|
||||
}
|
||||
else if (__math_lib == __math_lib_svml) {
|
||||
return __svml_asinf(x0);
|
||||
}
|
||||
else if (__math_lib == __math_lib_system) {
|
||||
float ret;
|
||||
foreach_active (i) {
|
||||
uniform float r = __stdlib_asinf(extract(x, i));
|
||||
uniform float r = __stdlib_asinf(extract(x0, i));
|
||||
ret = insert(ret, i, r);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
else if (__math_lib == __math_lib_ispc)
|
||||
{
|
||||
// sollya
|
||||
// fpminimax(((asin(x)-pi/2)/-sqrt(1-x)), [|0,1,2,3,4,5,6,7,8,9,10|],
|
||||
// [|single...|], [1e-20;.9999999999999999]);
|
||||
@@ -2564,7 +2576,9 @@ static inline float asin(float x) {
|
||||
x * (3.05023305118083953857421875e-2f +
|
||||
x * (-1.2897425331175327301025390625e-2f +
|
||||
x * 2.38926825113594532012939453125e-3f)))))))));
|
||||
}
|
||||
else if (__math_lib == __math_lib_ispc_fast)
|
||||
{
|
||||
// sollya
|
||||
// fpminimax(((asin(x)-pi/2)/-sqrt(1-x)), [|0,1,2,3,4,5|],[|single...|],
|
||||
// [1e-20;.9999999999999999]);
|
||||
@@ -2575,6 +2589,7 @@ static inline float asin(float x) {
|
||||
x * (-4.489909112453460693359375e-2f +
|
||||
x * (1.928029954433441162109375e-2f +
|
||||
x * (-4.3095736764371395111083984375e-3f)))));
|
||||
}
|
||||
|
||||
v *= -sqrt(1.f - x);
|
||||
v = v + 1.57079637050628662109375;
|
||||
@@ -2589,18 +2604,21 @@ static inline float asin(float x) {
|
||||
|
||||
|
||||
__declspec(safe)
|
||||
static inline uniform float asin(uniform float x) {
|
||||
uniform bool isneg = x < 0;
|
||||
x = abs(x);
|
||||
|
||||
static inline uniform float asin(uniform float x0) {
|
||||
uniform bool isneg = x0 < 0;
|
||||
uniform float x = abs(x0);
|
||||
uniform bool isnan = (x > 1);
|
||||
|
||||
uniform float v;
|
||||
if (__math_lib == __math_lib_svml ||
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
return __asin_uniform_float(x0);
|
||||
}
|
||||
else if (__math_lib == __math_lib_svml ||
|
||||
__math_lib == __math_lib_system) {
|
||||
return __stdlib_asinf(x);
|
||||
return __stdlib_asinf(x0);
|
||||
}
|
||||
else if (__math_lib == __math_lib_ispc)
|
||||
{
|
||||
// sollya
|
||||
// fpminimax(((asin(x)-pi/2)/-sqrt(1-x)), [|0,1,2,3,4,5,6,7,8,9,10|],
|
||||
// [|single...|], [1e-20;.9999999999999999]);
|
||||
@@ -2616,7 +2634,9 @@ static inline uniform float asin(uniform float x) {
|
||||
x * (3.05023305118083953857421875e-2f +
|
||||
x * (-1.2897425331175327301025390625e-2f +
|
||||
x * 2.38926825113594532012939453125e-3f)))))))));
|
||||
}
|
||||
else if (__math_lib == __math_lib_ispc_fast)
|
||||
{
|
||||
// sollya
|
||||
// fpminimax(((asin(x)-pi/2)/-sqrt(1-x)), [|0,1,2,3,4,5|],[|single...|],
|
||||
// [1e-20;.9999999999999999]);
|
||||
@@ -2627,6 +2647,7 @@ static inline uniform float asin(uniform float x) {
|
||||
x * (-4.489909112453460693359375e-2f +
|
||||
x * (1.928029954433441162109375e-2f +
|
||||
x * (-4.3095736764371395111083984375e-3f)))));
|
||||
}
|
||||
|
||||
v *= -sqrt(1.f - x);
|
||||
v = v + 1.57079637050628662109375;
|
||||
@@ -2642,6 +2663,10 @@ static inline uniform float asin(uniform float x) {
|
||||
|
||||
__declspec(safe)
|
||||
static inline float cos(float x_full) {
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
return __cos_varying_float(x_full);
|
||||
}
|
||||
if (__math_lib == __math_lib_svml) {
|
||||
return __svml_cosf(x_full);
|
||||
}
|
||||
@@ -2703,7 +2728,11 @@ static inline float cos(float x_full) {
|
||||
|
||||
__declspec(safe)
|
||||
static inline uniform float cos(uniform float x_full) {
|
||||
if (__math_lib == __math_lib_system ||
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
return __cos_uniform_float(x_full);
|
||||
}
|
||||
else if (__math_lib == __math_lib_system ||
|
||||
__math_lib == __math_lib_svml) {
|
||||
return __stdlib_cosf(x_full);
|
||||
}
|
||||
@@ -2768,22 +2797,34 @@ static inline uniform float cos(uniform float x_full) {
|
||||
|
||||
__declspec(safe)
|
||||
static inline float acos(float v) {
|
||||
if (__have_native_trigonometry)
|
||||
return __acos_varying_float(v);
|
||||
else
|
||||
return 1.57079637050628662109375 - asin(v);
|
||||
}
|
||||
|
||||
__declspec(safe)
|
||||
static inline double acos(const double v) {
|
||||
if (__have_native_trigonometry)
|
||||
return __acos_varying_double(v);
|
||||
else
|
||||
return 1.57079637050628662109375d0 - asin(v);
|
||||
}
|
||||
|
||||
|
||||
__declspec(safe)
|
||||
static inline uniform float acos(uniform float v) {
|
||||
if (__have_native_trigonometry)
|
||||
return __acos_uniform_float(v);
|
||||
else
|
||||
return 1.57079637050628662109375 - asin(v);
|
||||
}
|
||||
|
||||
__declspec(safe)
|
||||
static inline uniform double acos(const uniform double v) {
|
||||
if (__have_native_trigonometry)
|
||||
return __acos_uniform_double(v);
|
||||
else
|
||||
return 1.57079637050628662109375d0 - asin(v);
|
||||
}
|
||||
|
||||
@@ -2791,6 +2832,10 @@ static inline uniform double acos(const uniform double v) {
|
||||
__declspec(safe)
|
||||
static inline void sincos(float x_full, varying float * uniform sin_result,
|
||||
varying float * uniform cos_result) {
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
__sincos_varying_float(x_full,sin_result,cos_result);
|
||||
}
|
||||
if (__math_lib == __math_lib_svml) {
|
||||
__svml_sincosf(x_full, sin_result, cos_result);
|
||||
}
|
||||
@@ -2861,6 +2906,10 @@ static inline void sincos(float x_full, varying float * uniform sin_result,
|
||||
__declspec(safe)
|
||||
static inline void sincos(uniform float x_full, uniform float * uniform sin_result,
|
||||
uniform float * uniform cos_result) {
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
__sincos_uniform_float(x_full, sin_result, cos_result);
|
||||
}
|
||||
if (__math_lib == __math_lib_system ||
|
||||
__math_lib == __math_lib_svml) {
|
||||
__stdlib_sincosf(x_full, sin_result, cos_result);
|
||||
@@ -2923,7 +2972,11 @@ static inline void sincos(uniform float x_full, uniform float * uniform sin_resu
|
||||
|
||||
__declspec(safe)
|
||||
static inline float tan(float x_full) {
|
||||
if (__math_lib == __math_lib_svml) {
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
return __tan_varying_float(x_full);
|
||||
}
|
||||
else if (__math_lib == __math_lib_svml) {
|
||||
return __svml_tanf(x_full);
|
||||
}
|
||||
else if (__math_lib == __math_lib_system) {
|
||||
@@ -3002,7 +3055,11 @@ static inline float tan(float x_full) {
|
||||
|
||||
__declspec(safe)
|
||||
static inline uniform float tan(uniform float x_full) {
|
||||
if (__math_lib == __math_lib_system ||
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
return __tan_uniform_float(x_full);
|
||||
}
|
||||
else if (__math_lib == __math_lib_system ||
|
||||
__math_lib == __math_lib_svml) {
|
||||
return __stdlib_tanf(x_full);
|
||||
}
|
||||
@@ -3074,7 +3131,11 @@ static inline uniform float tan(uniform float x_full) {
|
||||
|
||||
__declspec(safe)
|
||||
static inline float atan(float x_full) {
|
||||
if (__math_lib == __math_lib_svml) {
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
return __atan_varying_float(x_full);
|
||||
}
|
||||
else if (__math_lib == __math_lib_svml) {
|
||||
return __svml_atanf(x_full);
|
||||
}
|
||||
else if (__math_lib == __math_lib_system) {
|
||||
@@ -3125,7 +3186,11 @@ static inline float atan(float x_full) {
|
||||
|
||||
__declspec(safe)
|
||||
static inline uniform float atan(uniform float x_full) {
|
||||
if (__math_lib == __math_lib_system ||
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
return __atan_uniform_float(x_full);
|
||||
}
|
||||
else if (__math_lib == __math_lib_system ||
|
||||
__math_lib == __math_lib_svml) {
|
||||
return __stdlib_atanf(x_full);
|
||||
}
|
||||
@@ -3169,7 +3234,11 @@ static inline uniform float atan(uniform float x_full) {
|
||||
|
||||
__declspec(safe)
|
||||
static inline float atan2(float y, float x) {
|
||||
if (__math_lib == __math_lib_svml) {
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
return __atan2_varying_float(y,x);
|
||||
}
|
||||
else if (__math_lib == __math_lib_svml) {
|
||||
return __svml_atan2f(y, x);
|
||||
}
|
||||
else if (__math_lib == __math_lib_system) {
|
||||
@@ -3208,7 +3277,11 @@ static inline float atan2(float y, float x) {
|
||||
|
||||
__declspec(safe)
|
||||
static inline uniform float atan2(uniform float y, uniform float x) {
|
||||
if (__math_lib == __math_lib_system ||
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
return __atan2_uniform_float(y,x);
|
||||
}
|
||||
else if (__math_lib == __math_lib_system ||
|
||||
__math_lib == __math_lib_svml) {
|
||||
return __stdlib_atan2f(y, x);
|
||||
}
|
||||
@@ -3743,12 +3816,14 @@ static inline uniform double frexp(uniform double x, uniform int * uniform pw2)
|
||||
|
||||
__declspec(safe)
|
||||
static inline double sin(double x) {
|
||||
if (__math_lib == __math_lib_svml)
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
return __sin_varying_double(x);
|
||||
}
|
||||
else if (__math_lib == __math_lib_svml)
|
||||
{
|
||||
return __svml_sind(x);
|
||||
}
|
||||
else if (__math_lib == __math_lib_ispc_fast)
|
||||
return sin((float)x);
|
||||
else {
|
||||
double ret;
|
||||
foreach_active (i) {
|
||||
@@ -3758,23 +3833,46 @@ static inline double sin(double x) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
__declspec(safe)
|
||||
static inline double asin(double x) {
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
return __asin_varying_double(x);
|
||||
}
|
||||
else if (__math_lib == __math_lib_svml)
|
||||
{
|
||||
return __svml_asind(x);
|
||||
}
|
||||
else {
|
||||
double ret;
|
||||
foreach_active (i) {
|
||||
uniform double r = __stdlib_asin(extract(x, i));
|
||||
ret = insert(ret, i, r);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
__declspec(safe)
|
||||
static inline uniform double sin(uniform double x) {
|
||||
if (__math_lib == __math_lib_ispc_fast)
|
||||
return sin((float)x);
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
return __sin_uniform_double(x);
|
||||
}
|
||||
else
|
||||
return __stdlib_sin(x);
|
||||
}
|
||||
|
||||
__declspec(safe)
|
||||
static inline double asin(const double x) {
|
||||
if (__math_lib == __math_lib_svml)
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
return __asin_varying_double(x);
|
||||
}
|
||||
else if (__math_lib == __math_lib_svml)
|
||||
{
|
||||
return __svml_asind(x);
|
||||
}
|
||||
else if (__math_lib == __math_lib_ispc_fast)
|
||||
return asin((float)x);
|
||||
else {
|
||||
double ret;
|
||||
foreach_active (i) {
|
||||
@@ -3787,12 +3885,14 @@ static inline double asin(const double x) {
|
||||
|
||||
__declspec(safe)
|
||||
static inline double cos(const double x) {
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
return __cos_varying_double(x);
|
||||
}
|
||||
if (__math_lib == __math_lib_svml)
|
||||
{
|
||||
return __svml_cosd(x);
|
||||
}
|
||||
else if (__math_lib == __math_lib_ispc_fast)
|
||||
return cos((float)x);
|
||||
else {
|
||||
double ret;
|
||||
foreach_active (i) {
|
||||
@@ -3805,8 +3905,10 @@ static inline double cos(const double x) {
|
||||
|
||||
__declspec(safe)
|
||||
static inline uniform double cos(uniform double x) {
|
||||
if (__math_lib == __math_lib_ispc_fast)
|
||||
return cos((float)x);
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
return __cos_uniform_double(x);
|
||||
}
|
||||
else
|
||||
return __stdlib_cos(x);
|
||||
}
|
||||
@@ -3814,16 +3916,14 @@ static inline uniform double cos(uniform double x) {
|
||||
__declspec(safe)
|
||||
static inline void sincos(double x, varying double * uniform sin_result,
|
||||
varying double * uniform cos_result) {
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
__sincos_varying_double(x,sin_result,cos_result);
|
||||
}
|
||||
if (__math_lib == __math_lib_svml)
|
||||
{
|
||||
__svml_sincosd(x, sin_result, cos_result);
|
||||
}
|
||||
else if (__math_lib == __math_lib_ispc_fast) {
|
||||
float sr, cr;
|
||||
sincos((float)x, &sr, &cr);
|
||||
*sin_result = sr;
|
||||
*cos_result = cr;
|
||||
}
|
||||
else {
|
||||
foreach_active (i) {
|
||||
uniform double sr, cr;
|
||||
@@ -3837,11 +3937,9 @@ static inline void sincos(double x, varying double * uniform sin_result,
|
||||
__declspec(safe)
|
||||
static inline void sincos(uniform double x, uniform double * uniform sin_result,
|
||||
uniform double * uniform cos_result) {
|
||||
if (__math_lib == __math_lib_ispc_fast) {
|
||||
uniform float sr, cr;
|
||||
sincos((uniform float)x, &sr, &cr);
|
||||
*sin_result = sr;
|
||||
*cos_result = cr;
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
__sincos_uniform_double(x,sin_result, cos_result);
|
||||
}
|
||||
else
|
||||
__stdlib_sincos(x, sin_result, cos_result);
|
||||
@@ -3849,12 +3947,14 @@ static inline void sincos(uniform double x, uniform double * uniform sin_result,
|
||||
|
||||
__declspec(safe)
|
||||
static inline double tan(double x) {
|
||||
if (__math_lib == __math_lib_svml)
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
return __tan_varying_double(x);
|
||||
}
|
||||
else if (__math_lib == __math_lib_svml)
|
||||
{
|
||||
return __svml_tand(x);
|
||||
}
|
||||
else if (__math_lib == __math_lib_ispc_fast)
|
||||
return tan((float)x);
|
||||
else {
|
||||
double ret;
|
||||
foreach_active (i) {
|
||||
@@ -3867,16 +3967,20 @@ static inline double tan(double x) {
|
||||
|
||||
__declspec(safe)
|
||||
static inline uniform double tan(uniform double x) {
|
||||
if (__math_lib == __math_lib_ispc_fast)
|
||||
return tan((float)x);
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
return __tan_uniform_double(x);
|
||||
}
|
||||
else
|
||||
return __stdlib_tan(x);
|
||||
}
|
||||
|
||||
__declspec(safe)
|
||||
static inline double atan(double x) {
|
||||
if (__math_lib == __math_lib_ispc_fast)
|
||||
return atan((float)x);
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
return __atan_varying_double(x);
|
||||
}
|
||||
else {
|
||||
double ret;
|
||||
foreach_active (i) {
|
||||
@@ -3889,20 +3993,24 @@ static inline double atan(double x) {
|
||||
|
||||
__declspec(safe)
|
||||
static inline uniform double atan(uniform double x) {
|
||||
if (__math_lib == __math_lib_ispc_fast)
|
||||
return atan((float)x);
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
return __atan_uniform_double(x);
|
||||
}
|
||||
else
|
||||
return __stdlib_atan(x);
|
||||
}
|
||||
|
||||
__declspec(safe)
|
||||
static inline double atan2(double y, double x) {
|
||||
if (__math_lib == __math_lib_svml)
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
return __atan2_varying_double(y,x);
|
||||
}
|
||||
else if (__math_lib == __math_lib_svml)
|
||||
{
|
||||
return __svml_atan2d(y,x);
|
||||
}
|
||||
else if (__math_lib == __math_lib_ispc_fast)
|
||||
return atan2((float)y, (float)x);
|
||||
else {
|
||||
double ret;
|
||||
foreach_active (i) {
|
||||
@@ -3915,20 +4023,23 @@ static inline double atan2(double y, double x) {
|
||||
|
||||
__declspec(safe)
|
||||
static inline uniform double atan2(uniform double y, uniform double x) {
|
||||
if (__math_lib == __math_lib_ispc_fast)
|
||||
return atan2((float)y, (float)x);
|
||||
if (__have_native_trigonometry)
|
||||
{
|
||||
return __atan2_uniform_double(y,x);
|
||||
}
|
||||
else
|
||||
return __stdlib_atan2(y, x);
|
||||
}
|
||||
|
||||
__declspec(safe)
|
||||
static inline double exp(double x) {
|
||||
if (__math_lib == __math_lib_svml)
|
||||
if (__have_native_transcendentals) {
|
||||
return __exp_varying_double(x);
|
||||
}
|
||||
else if (__math_lib == __math_lib_svml)
|
||||
{
|
||||
return __svml_expd(x);
|
||||
}
|
||||
else if (__math_lib == __math_lib_ispc_fast)
|
||||
return exp((float)x);
|
||||
else {
|
||||
double ret;
|
||||
foreach_active (i) {
|
||||
@@ -3941,20 +4052,22 @@ static inline double exp(double x) {
|
||||
|
||||
__declspec(safe)
|
||||
static inline uniform double exp(uniform double x) {
|
||||
if (__math_lib == __math_lib_ispc_fast)
|
||||
return exp((float)x);
|
||||
if (__have_native_transcendentals) {
|
||||
return __exp_uniform_double(x);
|
||||
}
|
||||
else
|
||||
return __stdlib_exp(x);
|
||||
}
|
||||
|
||||
__declspec(safe)
|
||||
static inline double log(double x) {
|
||||
if (__math_lib == __math_lib_svml)
|
||||
if (__have_native_transcendentals) {
|
||||
return __log_varying_double(x);
|
||||
}
|
||||
else if (__math_lib == __math_lib_svml)
|
||||
{
|
||||
return __svml_logd(x);
|
||||
}
|
||||
else if (__math_lib == __math_lib_ispc_fast)
|
||||
return log((float)x);
|
||||
else {
|
||||
double ret;
|
||||
foreach_active (i) {
|
||||
@@ -3967,20 +4080,22 @@ static inline double log(double x) {
|
||||
|
||||
__declspec(safe)
|
||||
static inline uniform double log(uniform double x) {
|
||||
if (__math_lib == __math_lib_ispc_fast)
|
||||
return log((float)x);
|
||||
if (__have_native_transcendentals) {
|
||||
return __log_uniform_double(x);
|
||||
}
|
||||
else
|
||||
return __stdlib_log(x);
|
||||
}
|
||||
|
||||
__declspec(safe)
|
||||
static inline double pow(double a, double b) {
|
||||
if (__math_lib == __math_lib_svml)
|
||||
if (__have_native_transcendentals) {
|
||||
return __pow_varying_double(a,b);
|
||||
}
|
||||
else if (__math_lib == __math_lib_svml)
|
||||
{
|
||||
return __svml_powd(a,b);
|
||||
}
|
||||
else if (__math_lib == __math_lib_ispc_fast)
|
||||
return pow((float)a, (float)b);
|
||||
else {
|
||||
double ret;
|
||||
foreach_active (i) {
|
||||
@@ -3993,8 +4108,9 @@ static inline double pow(double a, double b) {
|
||||
|
||||
__declspec(safe)
|
||||
static inline uniform double pow(uniform double a, uniform double b) {
|
||||
if (__math_lib == __math_lib_ispc_fast)
|
||||
return pow((float)a, (float)b);
|
||||
if (__have_native_transcendentals) {
|
||||
return __pow_uniform_double(a,b);
|
||||
}
|
||||
else
|
||||
return __stdlib_pow(a, b);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user