Hi,
I was naively thinking that it’d be fine if I just simply replaced by <accelmath.h> for the acc code that used some (common and simple) math functions. For the following code sample, pgc++ complained that identifier “floorf” was not defined.
/*
$ pgcc --version
pgcc 19.4-0 LLVM 64-bit target on x86-64 Linux -tp penryn
PGI Compilers and Tools
Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
pgc++ --version
pgc++ 19.4-0 LLVM 64-bit target on x86-64 Linux -tp penryn
PGI Compilers and Tools
Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
pgcc -c -acc -ta:tesla eg.c
pgc++ -c -acc -ta:tesla eg.cc
*/
#include <accelmath.h>
#pragma acc routine seq
float f1(float x) {
float y;
y = ceilf(x);
return y;
}
#pragma acc routine seq
float f2(float x) {
float y;
y = floorf(x);
return y;
}
#pragma acc routine seq
float f3(float x) {
float y;
y = sqrtf(x);
return y;
}
I had suspected that this was a C++11 compatibility issue because float std::floorf(float) and float std::ceilf(float) only became available since C++11 (ref. https://en.cppreference.com/w/cpp/numeric/math/ceil and https://en.cppreference.com/w/cpp/numeric/math/floor), but the source code (/opt/pgi/linux86-64-llvm/2019/include/accelmath.h) only safeguards “extern float floorf(float)” within #ifndef __cplusplus, which eventually confused me.
Apparently I cannot convert the whole project to C… What should I do to get around it?
Thanks.
stw