debug ftest and update float precision tool
This commit is contained in:
@@ -22,6 +22,9 @@ DIMSRC_O=$(DIMDIR)/src/dimension_t/dimension_t.o
|
||||
TENSRC=src/tensor_t/tensor_t.c
|
||||
TENSRC_O=$(TENSRC:.c=.o)
|
||||
|
||||
clTENSRC=src/tensor_t/cl_tensor_t.c
|
||||
clTENSRC_O=$(clTENSRC:.c=.o)
|
||||
|
||||
PERMSRC_O=$(PERMDIR)/src/permutation_t/permutation_t.o
|
||||
|
||||
#TOOLSRC_O=$(TOOLDIR)/src/tools_t/tools_t.o
|
||||
@@ -42,6 +45,9 @@ all: $(TENSRC_O)
|
||||
$(TENSRC_O) : $(TENSRC) $(DIMSRC_O) $(PERMSRC_O)
|
||||
$(CC) -o $@ -c $^ $(CFLAGS)
|
||||
|
||||
$(clTENSRC_O) : $(clTENSRC) $(TENSRC_O)
|
||||
$(CC) -o $@ -c $^ $(CFLAGS)
|
||||
|
||||
#$(DIMSRC_O) : $(DIMSRC) $(PERMSRC_O)
|
||||
# $(CC) -o $@ -c $< $(CFLAGS)
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include "dimension_t/dimension_t.h"
|
||||
|
||||
void subArray(size_t* dst, size_t* src, size_t debDst, size_t finDst, size_t debSrc);
|
||||
|
||||
#define GENERATE_TENSOR_TYPE(type) \
|
||||
struct tensor_##type{\
|
||||
dimension *dim;\
|
||||
|
||||
@@ -12,19 +12,24 @@ TENSDIR=$(PWD)/..
|
||||
DIMDIR=$(PWD)/../../dimension_t
|
||||
INCLUDE_DIR=$(PWD)/../src
|
||||
CFLAGS=-I$(INCLUDE_DIR) -I$(YPERMDIR)/src -I$(YTESTDIR)/include_ytest/include -I$(DIMDIR)/src -I$(TENSDIR)/src
|
||||
LDFLAGS=-L$(YTESTDIR) -lytest
|
||||
LDFLAGS=-L$(YTESTDIR) -lytest -lOpenCL
|
||||
|
||||
#SRC_DIR=$(ROOT_DIR)/src
|
||||
#SRC=$(wildcard */*/*.c)
|
||||
SRC=$(wildcard **/**/*.c)
|
||||
#HEADS=$(OBJS:.o=.h)
|
||||
TEST_DIR=$(PWD)
|
||||
|
||||
EXECSRC=$(NAME_TEST).c
|
||||
#EXECSRC=openF.c
|
||||
|
||||
EXEC=launch_$(NAME_TEST)_m
|
||||
|
||||
TENSRC=$(TENSDIR)/src/tensor_t/tensor_t.c
|
||||
TENSRC_O=$(TENSRC:.c=.o)
|
||||
|
||||
clTENSRC=$(TENSDIR)/src/tensor_t/cl_tensor_t.c
|
||||
clTENSRC_O=$(clTENSRC:.c=.o)
|
||||
|
||||
|
||||
PERMSRC_O=$(YPERMDIR)/src/permutation_t/permutation_t.o
|
||||
@@ -35,7 +40,7 @@ TOPTARGETS := all clean
|
||||
|
||||
DEPS=$(DIMDIR) $(YPERMDIR) $(YTESTDIR) $(TENSDIR)
|
||||
|
||||
OBJ=$(DIMSRC_O) $(PERMSRC_O) $(TENSRC_O)
|
||||
OBJ=$(DIMSRC_O) $(PERMSRC_O) $(TENSRC_O) $(clTENSRC_O)
|
||||
|
||||
LIB_YTEST=$(YTESTDIR)/libytest.so
|
||||
|
||||
|
||||
+99
-10
@@ -16,6 +16,7 @@
|
||||
|
||||
//#include "permutation_t/permutation_t.h"
|
||||
#include "tensor_t/tensor_t.h"
|
||||
#include "tensor_t/cl_tensor_t.h"
|
||||
|
||||
TEST(rank){
|
||||
dimension *D=create_dim(4);
|
||||
@@ -36,15 +37,15 @@ void print_tensor_float(tensor_TYPE_FLOAT *M, char *msg){
|
||||
LOG("[%ld]: %f ",i,M->x[i]);
|
||||
|
||||
LOG("%s","\n");
|
||||
/*
|
||||
size_t x_index=0 ;
|
||||
for(size_t i=0; i<M->dim->size;++i){
|
||||
for(size_t j=0; j<M->dim->perm[i]; ++j){
|
||||
LOG("[%3ld:(%ld,%ld)]: %f ",x_index,i,j,M->x[x_index]);
|
||||
++x_index;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void print_tensor_double(tensor_TYPE_DOUBLE *M, char *msg){
|
||||
LOG("================= %s ===============\n",msg);
|
||||
for(size_t i=0; i<M->dim->rank;++i)
|
||||
LOG("[%ld]: %lf ",i,M->x[i]);
|
||||
|
||||
LOG("%s","\n");
|
||||
} */
|
||||
}
|
||||
|
||||
|
||||
@@ -136,7 +137,6 @@ TEST(tensorContractnProd_TYPE_FLOAT ){
|
||||
|
||||
}
|
||||
|
||||
|
||||
TEST(tensorContractnProd_TYPE_FLOAT2 ){
|
||||
dimension *d0=create_dim(3);
|
||||
dimension *d1=create_dim(3);
|
||||
@@ -175,13 +175,102 @@ TEST(tensorContractnProd_TYPE_FLOAT2 ){
|
||||
print_tensor_float(MnO,"MnO");
|
||||
|
||||
// for(size_t i=0;i<M->dim->rank;++i)
|
||||
// EXPECT_EQ_TYPE_FLOAT(M->x[i],MnO->x[i]);
|
||||
// EXPECT_EQ_TYPE_FLOAT(M->x[i],MnO->x[i]);
|
||||
|
||||
EXPECT_ARRAY_EQ_TYPE_FLOAT(M->x,M->dim->rank,MnO->x,MnO->dim->rank);
|
||||
|
||||
|
||||
}
|
||||
|
||||
TEST(cl_tensorContractnProd_TYPE_FLOAT2 ){
|
||||
dimension *d0=create_dim(3);
|
||||
dimension *d1=create_dim(3);
|
||||
|
||||
d0->perm[0]=5;
|
||||
d0->perm[1]=2; //3;
|
||||
d0->perm[2]=3;
|
||||
|
||||
d1->perm[0]=2;
|
||||
d1->perm[1]=3;//3;
|
||||
d1->perm[2]=4;
|
||||
|
||||
updateRankDim(d0);
|
||||
updateRankDim(d1);
|
||||
|
||||
|
||||
tensor_TYPE_FLOAT *M0 = CREATE_TENSOR_TYPE_FLOAT(d0);
|
||||
tensor_TYPE_FLOAT *M1 = CREATE_TENSOR_TYPE_FLOAT(d1);
|
||||
|
||||
LOG("M0->dim->rank = %ld\n",M0->dim->rank);
|
||||
LOG("M1->dim->rank = %ld\n",M1->dim->rank);
|
||||
for(size_t i=0; i<M0->dim->rank;++i) M0->x[i]=i*0.1 +1;
|
||||
for(size_t i=0; i<M1->dim->rank;++i) M1->x[i]=i*0.003 + 2;
|
||||
|
||||
print_tensor_float(M0,"M0");
|
||||
print_tensor_float(M1,"M1");
|
||||
|
||||
tensor_TYPE_FLOAT *M;
|
||||
tensor_TYPE_FLOAT *MnO;
|
||||
|
||||
tensorContractnProd_TYPE_FLOAT(&M, M0,M1,2);
|
||||
print_tensor_float(M,"M");
|
||||
cl_tensorContractnProd_TYPE_FLOAT(&MnO, M0,M1,2);
|
||||
|
||||
|
||||
print_tensor_float(MnO,"MnO");
|
||||
|
||||
// for(size_t i=0;i<M->dim->rank;++i)
|
||||
// EXPECT_EQ_TYPE_FLOAT(M->x[i],MnO->x[i]);
|
||||
|
||||
EXPECT_ARRAY_EQ_TYPE_FLOAT(M->x,M->dim->rank,MnO->x,MnO->dim->rank);
|
||||
|
||||
|
||||
}
|
||||
|
||||
TEST(cl_tensorContractnProd_TYPE_DOUBLE2 ){
|
||||
dimension *d0=create_dim(3);
|
||||
dimension *d1=create_dim(3);
|
||||
|
||||
d0->perm[0]=5;
|
||||
d0->perm[1]=2; //3;
|
||||
d0->perm[2]=3;
|
||||
|
||||
d1->perm[0]=2;
|
||||
d1->perm[1]=3;//3;
|
||||
d1->perm[2]=4;
|
||||
|
||||
updateRankDim(d0);
|
||||
updateRankDim(d1);
|
||||
|
||||
|
||||
tensor_TYPE_DOUBLE *M0 = CREATE_TENSOR_TYPE_DOUBLE(d0);
|
||||
tensor_TYPE_DOUBLE *M1 = CREATE_TENSOR_TYPE_DOUBLE(d1);
|
||||
|
||||
LOG("M0->dim->rank = %ld\n",M0->dim->rank);
|
||||
LOG("M1->dim->rank = %ld\n",M1->dim->rank);
|
||||
for(size_t i=0; i<M0->dim->rank;++i) M0->x[i]=i*0.1 +1;
|
||||
for(size_t i=0; i<M1->dim->rank;++i) M1->x[i]=i*0.003 + 2;
|
||||
|
||||
print_tensor_double(M0,"M0");
|
||||
print_tensor_double(M1,"M1");
|
||||
|
||||
tensor_TYPE_DOUBLE *M;
|
||||
tensor_TYPE_DOUBLE *MnO;
|
||||
|
||||
tensorContractnProd_TYPE_DOUBLE(&M, M0,M1,2);
|
||||
print_tensor_double(M,"M");
|
||||
cl_tensorContractnProd_TYPE_DOUBLE(&MnO, M0,M1,2);
|
||||
|
||||
|
||||
print_tensor_double(MnO,"MnO");
|
||||
|
||||
// for(size_t i=0;i<M->dim->rank;++i)
|
||||
// EXPECT_EQ_TYPE_DOUBLE(M->x[i],MnO->x[i]);
|
||||
|
||||
EXPECT_ARRAY_EQ_TYPE_DOUBLE(M->x,M->dim->rank,MnO->x,MnO->dim->rank);
|
||||
|
||||
|
||||
}
|
||||
int main(int argc, char **argv){
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user