My linux version is 4.19.0-6-amd64 #1 SMP Debian 4.19.67-2+deb10u1 (2019-09-20) x86_64 GNU/Linux My gcc version is 8.3.0 i want to compile and run Sniper 7.2 with Pin 3.5. i am trying to compile benchmarks according to this post: https://groups.google.com/d/msg/snipersim/2yL2x6nNfVs/EmqQlVf6EwAJ
but i get this error:
/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/test/TestRTVec/TestRTVec.cxx:121:24: error: ‘int pow(double, int)’ conflicts with a previous declaration int pow(double a, int n) {
^
In file included from /usr/include/c++/8/math.h:36,
from /home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/common/RTInclude.hxx:18,
from /home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/common/RTVec.hxx:4,
from /home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/common/RTBox.hxx:4,
from /home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/test/TestRTVec/TestRTVec.cxx:3:
/usr/include/c++/8/cmath:399:3: note: previous declaration ‘double std::pow(double, int)’ pow(double __x, int __i)
^~~
/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/test/TestRTVec/TestRTVec.cxx:143:39: error: call of overloaded ‘pow(double, int)’ is ambiguous
if (v.minIndex() != 1 || dv != pow(convert<DataType>(11), N)) {
~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/features.h:424,
from /usr/include/time.h:25,
from /home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/test/TestRTVec/TestRTVec.cxx:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:140:1: note: candidate: ‘double pow(double, double)’
__MATHCALL_VEC (pow,, (_Mdouble_ __x, _Mdouble_ __y));
^~~~~~~~~~~~~~
I tried the recommendations from stackflow and others even the note in the report file but nothing changes. I find out pow() function should be like int pow(int a, int n) or double pow(double a, double n) but in TestRVec.cxx the deceleration is completely wrong. TestRTVec.cc seems to be built by makefile and then get compiled afterwards because it is not in the sniper_benchmark.tar file so i cannot do anything with that. is my observation true and what should i do??
i post a few prior lines in make report below:
cd /home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL && /usr/bin/g++ -std=gnu++98 -DTHIS_IS_CMAKE -I/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/libs/mesa/inst/amd64-linux.gcc-sniper/include -O3 -funroll-loops -fprefetch-loop-arrays -fpermissive -fno-exceptions -static-libgcc -Wl,--hash-style=both,--as-needed -DPARSEC_VERSION=2.1 -DENABLE_PARSEC_HOOKS -I/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/libs/hooks/inst/amd64-linux.gcc-sniper/include -I/home/ahmad/sniper-latest/sniper-7.2/benchmarks/tools/hooks -I/home/ahmad/sniper-latest/sniper-7.2/include -fexceptions -fno-strict-aliasing -fno-align-labels -DNDEBUG -D_MM_NO_ALIGN_CHECK -I/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/libs/mesa/inst/amd64-linux.gcc-sniper/include -I/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper -I/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL -I/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/common -I/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/BVH -I/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/SG -I/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/LRT/include -I/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/LRT -D__ahmad__ -o CMakeFiles/test_rtvec.dir/test/TestRTVec/TestRTVec.o -c /home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/test/TestRTVec/TestRTVec.cxx
The whole error section is this:
cd /home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL && /usr/bin/g++ -std=gnu++98 -DTHIS_IS_CMAKE -I/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/libs/mesa/inst/amd64-linux.gcc-sniper/include -O3 -funroll-loops -fprefetch-loop-arrays -fpermissive -fno-exceptions -static-libgcc -Wl,--hash-style=both,--as-needed -DPARSEC_VERSION=2.1 -DENABLE_PARSEC_HOOKS -I/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/libs/hooks/inst/amd64-linux.gcc-sniper/include -I/home/ahmad/sniper-latest/sniper-7.2/benchmarks/tools/hooks -I/home/ahmad/sniper-latest/sniper-7.2/include -fexceptions -fno-strict-aliasing -fno-align-labels -DNDEBUG -D_MM_NO_ALIGN_CHECK -I/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/libs/mesa/inst/amd64-linux.gcc-sniper/include -I/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper -I/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL -I/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/common -I/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/BVH -I/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/SG -I/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/LRT/include -I/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/LRT -D__ahmad__ -o CMakeFiles/test_rtvec.dir/test/TestRTVec/TestRTVec.o -c /home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/test/TestRTVec/TestRTVec.cxx
/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/test/TestRTVec/TestRTVec.cxx:121:24: error: ‘int pow(double, int)’ conflicts with a previous declaration
int pow(double a, int n) {
^
In file included from /usr/include/c++/8/math.h:36,
from /home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/common/RTInclude.hxx:18,
from /home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/common/RTVec.hxx:4,
from /home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/common/RTBox.hxx:4,
from /home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/test/TestRTVec/TestRTVec.cxx:3:
/usr/include/c++/8/cmath:399:3: note: previous declaration ‘double std::pow(double, int)’
pow(double __x, int __i)
^~~
/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/test/TestRTVec/TestRTVec.cxx: In instantiation of ‘void testbox() [with int N = 8; DataType = double]’:
/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/test/TestRTVec/TestRTVec.cxx:317:24: required from here
/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/test/TestRTVec/TestRTVec.cxx:143:39: error: call of overloaded ‘pow(double, int)’ is ambiguous
if (v.minIndex() != 1 || dv != pow(convert<DataType>(11), N)) {
~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/features.h:424,
from /usr/include/time.h:25,
from /home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/test/TestRTVec/TestRTVec.cxx:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:140:1: note: candidate: ‘double pow(double, double)’
__MATHCALL_VEC (pow,, (_Mdouble_ __x, _Mdouble_ __y));
^~~~~~~~~~~~~~
/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/test/TestRTVec/TestRTVec.cxx:114:5: note: candidate: ‘int pow(int, int)’
int pow(int a, int n) {
^~~
/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/test/TestRTVec/TestRTVec.cxx:121:5: note: candidate: ‘int pow(double, int)’
int pow(double a, int n) {
^~~
In file included from /usr/include/c++/8/math.h:36,
from /home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/common/RTInclude.hxx:18,
from /home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/common/RTVec.hxx:4,
from /home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/common/RTBox.hxx:4,
from /home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper/RTTL/test/TestRTVec/TestRTVec.cxx:3:
/usr/include/c++/8/cmath:415:5: note: candidate: ‘typename __gnu_cxx::__promote_2<_Tp, _Up>::__type std::pow(_Tp, _Up) [with _Tp = double; _Up = int; typename __gnu_cxx::__promote_2<_Tp, _Up>::__type = double]’
pow(_Tp __x, _Up __y)
^~~
/usr/include/c++/8/cmath:407:3: note: candidate: ‘long double std::pow(long double, int)’
pow(long double __x, int __n)
^~~
/usr/include/c++/8/cmath:403:3: note: candidate: ‘float std::pow(float, int)’
pow(float __x, int __n)
^~~
/usr/include/c++/8/cmath:399:3: note: candidate: ‘double std::pow(double, int)’
pow(double __x, int __i)
^~~
/usr/include/c++/8/cmath:392:3: note: candidate: ‘long double std::pow(long double, long double)’
pow(long double __x, long double __y)
^~~
/usr/include/c++/8/cmath:388:3: note: candidate: ‘float std::pow(float, float)’
pow(float __x, float __y)
^~~
make[4]: *** [RTTL/CMakeFiles/test_rtvec.dir/build.make:56: RTTL/CMakeFiles/test_rtvec.dir/test/TestRTVec/TestRTVec.o] Error 1
make[4]: Leaving directory '/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper'
make[3]: *** [CMakeFiles/Makefile2:224: RTTL/CMakeFiles/test_rtvec.dir/all] Error 2
make[3]: Leaving directory '/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper'
make[2]: *** [Makefile:114: all] Error 2
make[2]: Leaving directory '/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/apps/raytrace/obj/amd64-linux.gcc-sniper'
[PARSEC] Error: 'env CXXFLAGS=-I/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/libs/mesa/inst/amd64-linux.gcc-sniper/include -O3 -funroll-loops -fprefetch-loop-arrays -fpermissive -fno-exceptions -static-libgcc -Wl,--hash-style=both,--as-needed -DPARSEC_VERSION=2.1 -DENABLE_PARSEC_HOOKS -I/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/libs/hooks/inst/amd64-linux.gcc-sniper/include -I/home/ahmad/sniper-latest/sniper-7.2/benchmarks/tools/hooks -I/home/ahmad/sniper-latest/sniper-7.2/include -fexceptions -fno-strict-aliasing -fno-align-labels -DNDEBUG -D_MM_NO_ALIGN_CHECK LDFLAGS=-L/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/libs/mesa/inst/amd64-linux.gcc-sniper/lib -L/usr/lib64 -L/usr/lib -L/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec/parsec-2.1/pkgs/libs/hooks/inst/amd64-linux.gcc-sniper/lib -uparmacs_roi_end -uparmacs_roi_start -L/home/ahmad/sniper-latest/sniper-7.2/benchmarks/tools/hooks -lhooks_base -lrt -pthread LIBS= -lhooks -lXmu -lX11 -lGL -lGLU -lpthread /usr/bin/make' failed.
make[1]: *** [Makefile:31: parsec-build] Error 1
make[1]: Leaving directory '/home/ahmad/sniper-latest/sniper-7.2/benchmarks/parsec'
make: *** [Makefile:14: all] Error 2
The whole code file is this:
#include <time.h>
#include "RTTL/common/RTBox.hxx"
#include "RTTL/common/Timer.hxx"
using namespace RTTL;
template<int N, typename DataType>
void randomize(RTVec_t<N, DataType>& v, float scale = 1) {
for (int i = 0; i < v.nElements(); i++)
v[i] = DataType(scale * rand()/float(RAND_MAX));
}
template<int N>
void randomize(RTVec_t<N, sse_f>& v, float scale = 1) {
float* f = (float*)&v;
for (int i = 0; i < 4*v.nElements(); i++)
f[i] = float(scale * rand()/float(RAND_MAX));
}
template<int N>
void randomize(RTVec_t<N, sse_i>& v, float scale = 1) {
int* f = (int*)&v;
for (int i = 0; i < 4*v.nElements(); i++)
f[i] = int(scale * rand()/float(RAND_MAX));
}
// Elementary types
template<int N, typename DataType>
void test() {
typedef RTVec_t<N, DataType> rtvec;
DataType eps = epsilon<DataType>();
rtvec a(1);
rtvec b(2);
rtvec c(3);
rtvec d(4);
DataType q = 14;
rtvec dif = q*a - b - c*d; // should be ~0
if (dif.absMaximum() != 0) {
cout << "err101 = " << dif << ";" << endl;
//exit(101);
}
c += 1; // operator+=(const DataType q)
if (d != c) {
cout << "err102 = " << c << ";" << endl;
//exit(102);
}
const float scale = 100;
randomize(a, scale);
randomize(b, scale);
randomize(c, scale);
d = (a+b)*c - (a*c + b*c);
if (d.absMaximum() > 30 * N * scale * eps) {
// Could happen (rather infrequently but still)
cout << "err103 = " << d << ";" << endl;
//exit(103);
}
DataType e[] = {8,1,2,3,4,5,6,7,8,9,10};
a = 2;
a *= 2;
a -= e;
rtvec tt(e);
a += rtvec(5);
if (a.maximum() != ((rtvec&)e).maximum() || a.minimum() != ((rtvec&)e).minimum()) {
cout << "err104 = " << a << ";" << endl;
//exit(104);
}
}
// SSE types (also works for int/floats!)
template<int N, typename DataType>
void test4() {
typedef RTVec_t<N, DataType> rtvec;
DataType eps = epsilon<DataType>();
rtvec a(convert<DataType>(1));
rtvec b(convert<DataType>(2));
rtvec c(convert<DataType>(3));
rtvec d(convert<DataType>(4));
DataType q = convert<DataType>(14);
rtvec dif = q*a - b - c*d; // should be ~0
if (dif.absMaximum() != convert<DataType>(0)) {
cout << "err201 = " << dif << ";" << endl;
//exit(201);
}
c += convert<DataType>(1); // operator+=(const DataType q)
if (d != c) {
cout << "err202 = " << c << ";" << endl;
//exit(202);
}
#define scale 100
randomize(a, scale);
randomize(b, scale);
randomize(c, scale);
d = (a+b)*c - (a*c + b*c);
DataType dam = d.absMaximum();
if (!(30 * N * scale * eps >= dam)) {
cout << "err203 = " << d << ";" << endl;
//exit(203);
}
}
int pow(int a, int n) {
// versions for float/double are defined in stdlib.
int r = a;
for (int i = 1; i < n; i++) r *= a;
return r;
}
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
int pow(double a, int n) {
return pow(a, (double)n);
}
#endif
template<int N, typename DataType>
void testbox() {
typedef RTVec_t<N, DataType> rtvec;
typedef RTBox_t<N, DataType> rtbox;
rtbox a;
a[0] = rtvec(2);
a[1] = rtvec(12);
rtbox b(rtvec(1), rtvec(10));
rtbox d = a + b;
rtbox e = a - b;
if (d.sides().minimum() != 11 || e.center().maximum() != 6) {
cout << "err301 = " << a << ";" << endl;
//exit(301);
}
DataType dv = d.volume();
d[1][0] = 20;
rtvec v = d.sides();
if (v.minIndex() != 1 || dv != pow(convert<DataType>(11), N)) {
cout << "err302 = " << d << ";" << endl;
//exit(302);
}
}
template<int N, typename DataType>
void testbox4() {
typedef RTVec_t<N, DataType> rtvec;
typedef RTBox_t<N, DataType> rtbox;
rtbox a;
a[0] = rtvec(convert<DataType>(2));
a[1] = rtvec(convert<DataType>(12));
rtbox b(rtvec(convert<DataType>(1)), rtvec(convert<DataType>(10)));
rtbox d = a + b;
rtbox e = a - b;
if (d.sides().minimum() != 11 || e.center().maximum() != 6) {
cout << "err303 = " << a << ";" << endl;
//exit(303);
}
}
#include "RTTL/common/RTcoutRedirect.hxx"
int main() {
Timer timer; timer.start();
unsigned int seed = (unsigned int)(CLOCKS_PER_SEC*unsigned(time(NULL)));
srand(seed);
cout << "seed = " << seed << ";" << endl;
// Check if alignment is working...
int align0 = __alignof(RTData_t<3, float, 0>::AlignedDataType) ;
int alignx = __alignof(RTData_t<3, float, 16>::AlignedDataType);
if (align0 != __alignof(float) || alignx != __alignof(sse_f)) {
cout << "err00 = " << align0 << " vs " << alignx << endl;
//exit(1);
}
RTVec_t<4, float, 16> a(0.0f);
int aa = __alignof(a);
a.entry(1) = 1; // default cast (to float&)
a.entry<float>(2) = 2; // explicit cast
a.entry<float>(3) = 3;
// Different overloads for 'const' attribute (same behavior)
//const
_ALIGN(16) float a0[] = {0,1,2,3};
if (a != (RTVec_t<4, float, 16>&)a0) { // using cast
cout << "err01 = " << a << ";" << endl;
//exit(1);
}
if (a != a0) {
cout << "err021 = " << a << ";" << endl;
//exit(21);
}
if (a == *a0) { // operator==
cout << "err022 = " << a << ";" << endl;
//exit(22);
}
RTVec_t<4, float, 16> b;
b = 3.0f;
if (b != a0[3]) { // operator!=
cout << "err023 = " << a << ";" << endl;
//exit(23);
}
// Mixed operands and casts.
float* bv = b.pointer<float>();
bv[0] = 1;
bv[1] = 2;
bv[2] = 3;
bv[3] = 4;
if (a == b) { // comparing RTVec_t<4, float, 16>
cout << "err03 = " << a << ";" << endl;
//exit(3);
}
if (a != b - 1) {
cout << "err04 = " << a << ";" << endl;
//exit(4);
}
if (a != b - 1.0f) {
cout << "err05 = " << a << ";" << endl;
//exit(5);
}
RTVec_t<1, sse_f> asse;
asse = convert(3.0f, 2.0f, 1.0f, 0.0f); // _mm_set_ps
if (asse != a.entry<sse_f>()) {
cout << "err06 = " << asse << ";" << endl;
//exit(6);
}
// Access individual floats in sse_f vector.
asse.entry<float>(1) = 5;
if (asse != convert(3.0f, 2.0f, 5.0f, 0.0f)) {
cout << "err07 = " << asse << ";" << endl;
//exit(7);
}
// Difference between cast and convert.
RTVec_t<1, sse_i> assei;
assei = convert(3, 2, 5, 0);
if (assei[0] != convert(asse[0])) {
cout << "err081 = " << assei << ";" << endl;
//exit(81);
}
if (assei[0] == cast(asse[0])) {
cout << "err082 = " << assei << ";" << endl;
//exit(82);
}
// Check different sizes and data types.
test<5, float>();
//#if 0
test<6, float>();
test<8, float>();
test<5, int>();
test<6, int>();
test<8, int>();
test<5, double>();
test<6, double>();
test<8, double>();
test4<16, int>();
test4<16, float>();
test4<16, sse_f>();
// Specialized instances.
test<2, int>();
test<3, float>();
test<4, char>();
test4<3, sse_f>();
#if !defined(__GNUC__) || defined(__INTEL_COMPILER)
_ALIGN(16) float ef[] = {4,3,2,1, 8,7,6,5, 11,10,9,8};
sse_f* e = (sse_f*)ef;
RTVec_t<3, sse_f> a4;
a4 = RTVec_t<3, sse_f>(convert(2.0f)); // fine without template parameter
a4 *= convert<sse_f>(4); // need one
a4 -= e;
sse_f ama = a4.maximum();
sse_f ami = a4.minimum();
sse_f adi = ama - ami;
if (adi != 7) {
cout << "err09 = " << a4 << ";" << endl;
//exit(9);
}
#endif
RTVec_t<4, float, 16> at0(1.0f);
RTVec_t<3, float> at1(1.0f);
RTVec_t<4, float, 16> at2(1.0f);
// Vectors of different size are always not equal.
if (at1 == at0) {
cout << "err10 = " << at0 << ";" << endl;
//exit(10);
}
// The same size.
if (at2 != at0) {
cout << "err11 = " << at0 << ";" << endl;
//exit(11);
}
test4<4, float>();
test4<4, sse_f>();
test4<4, sse_i>();
testbox<2, float>();
testbox<3, int>();
testbox<4, float>();
testbox<8, double>();
testbox4<1, sse_f>();
RTBox_t<3, float, 16> b3;
_ALIGN(16) float b31[] = {1,2,3};
b3.m_min = (RTVec_t<3, float, 16>&)b31;
_ALIGN(16) float b32[] = {3,6,5};
b3.m_max = (RTVec_t<3, float, 16>&)b32;
int b3i = b3.maxIndex();
float b3ar = b3.area();
float b3vol = b3.volume();
if (b3i != 1 || b3ar != 40 || b3vol != 16) {
cout << "err12 = " << b3 << ";" << endl;
//exit(12);
}
RTBox_t<1, sse_f> b4;
b4[0] = _mm_set_ps(1,2,3,4);
b4[1] = _mm_set_ps(5,5,6,6);
b4[0].entry<float>(3) = 2;
sse_f bs = b4.sides()[0];
RTBox_t<4, float>& bf = (RTBox_t<4, float>&)b4;
float bfv = bf.volume();
if (bfv != 54) {
cout << "err13 = " << b4 << ";" << endl;
//exit(13);
}
#if 0
RTBox3a b3a;
b3a[0] = _mm_set_ps(-1,3,2,1);
b3a[1] = _mm_set_ps(-1,5,4,3);
float b3av = b3a.volume();
float b3aa = b3a.area();
if (b3av != 8 || b3aa != 24) {
cout << "err14 = " << b3a << ";" << endl;
//exit(14);
}
#else
cout << "WARNING: as layout if RTBox3a is unclear, code has been disabled" << endl;
#endif
//#endif
cout << "success (" << timer.stop() << " seconds)" << endl;
return 0;
}
The error lines are these
int pow(int a, int n) {
// versions for float/double are defined in stdlib.
int r = a;
for (int i = 1; i < n; i++) r *= a;
return r;
}
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
int pow(double a, int n) {
return pow(a, (double)n);
}
#endif
and
template<int N, typename DataType>
void testbox() {
typedef RTVec_t<N, DataType> rtvec;
typedef RTBox_t<N, DataType> rtbox;
rtbox a;
a[0] = rtvec(2);
a[1] = rtvec(12);
rtbox b(rtvec(1), rtvec(10));
rtbox d = a + b;
rtbox e = a - b;
if (d.sides().minimum() != 11 || e.center().maximum() != 6) {
cout << "err301 = " << a << ";" << endl;
//exit(301);
}
DataType dv = d.volume();
d[1][0] = 20;
rtvec v = d.sides();
if (v.minIndex() != 1 || dv != pow(convert<DataType>(11), N)) {
cout << "err302 = " << d << ";" << endl;
//exit(302);
}
}