From 9244239f467fb5f6fa97ee42afbde799dbfbdff4 Mon Sep 17 00:00:00 2001 From: fanasina Date: Tue, 26 Mar 2024 14:27:33 +0100 Subject: [PATCH] debug -Werr and creake Makefile to build libneurons.so --- dimension_t/src/dimension_t/dimension_t.c | 2 +- dimension_t/src/dimension_t/dimension_t.h | 1 - neuron_t/Makefile | 114 +++++++++++------- neuron_t/src/neuron_t/neuron_t.c | 1 + tensor_t/src/tensor_t/tensor_t.c | 30 +++-- .../src/permutation_t/permutation_t.c | 4 +- 6 files changed, 97 insertions(+), 55 deletions(-) diff --git a/dimension_t/src/dimension_t/dimension_t.c b/dimension_t/src/dimension_t/dimension_t.c index 973fc0d..a549ed2 100644 --- a/dimension_t/src/dimension_t/dimension_t.c +++ b/dimension_t/src/dimension_t/dimension_t.c @@ -212,7 +212,7 @@ void printDebug_dimension(dimension *d,char *msg){ printf("(%s)->size = %ld | (%s)->rank = %ld \n[",msg,d->size,msg,d->rank); for(size_t i=0; isize; ++i) printf(" %ld,", d->perm[i]); - printf("] \n"); + printf("] \n"); //printf("[%ld: %ld] |", i,d->perm[i]); /* if(endian) printf("\nendian (true): the bigest index varies first, e.g: [x0,x1,x2,...,xn] xn is the bigest index\n"); diff --git a/dimension_t/src/dimension_t/dimension_t.h b/dimension_t/src/dimension_t/dimension_t.h index 4211acf..14f18a8 100644 --- a/dimension_t/src/dimension_t/dimension_t.h +++ b/dimension_t/src/dimension_t/dimension_t.h @@ -5,7 +5,6 @@ extern bool endian; - bool isLessEqThan(long int a, long int b) ; bool isLessThan(long int a, long int b) ; bool isGreatEqThan(long int a, long int b) ; diff --git a/neuron_t/Makefile b/neuron_t/Makefile index 7f48d0e..4ef7dff 100644 --- a/neuron_t/Makefile +++ b/neuron_t/Makefile @@ -1,64 +1,92 @@ +# lib: -lneurons + +PROJECT_LIB=libneurons.so CC=gcc -TOOLDIR=$(PWD)/../ytools_t -PERMDIR=$(PWD)/../ypermutation_t +ROOT_DIR=$(PWD) +YTESTDIR=$(PWD)/../ytest_t +YPERMDIR=$(PWD)/../ypermutation_t -DIMDIR=$(PWD)/../dimension_t TENSDIR=$(PWD)/../tensor_t -INCLUDE_NEURO=$(PWD)/src -INCLUDE_TENS=$(TENSDIR)/src -INCLUDE_PERMDIR=$(PERMDIR)/src -INCLUDE_DIMDIR=$(DIMDIR)/src -INCLUDE_TOOLDIR=$(TOOLDIR)/include -CFLAGS=-I$(INCLUDE_TOOLDIR) -I$(INCLUDE_PERMDIR) -I$(INCLUDE_DIMDIR) -I$(INCLUDE_TENS) -I$(INCLUDE_NEURO) -lpthread +NEURODIR=$(PWD) +DIMDIR=$(PWD)/../dimension_t +INCLUDE_DIR=$(PWD)/sr + +#CFLAGS=-I$(INCLUDE_DIR) -I$(YPERMDIR)/src -I$(YTESTDIR)/include_ytest/include -I$(DIMDIR)/src -I$(TENSDIR)/src #"-D DEBUG=1" +INCLUDE=-I$(NEURODIR)/src -I$(YPERMDIR)/src -I$(DIMDIR)/src -I$(TENSDIR)/src #"-D DEBUG=1" +#LDFLAGS=-L$(YTESTDIR) -lytest -lOpenCL -lm -lpthread +#CFLAGS= -Wall -Werror -fpic $(INCLUDE) +CFLAGS= -Wall -Werror -fpic $(INCLUDE) +LDFLAGS= -lOpenCL -lpthread #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 + +NEUROSRC=$(NEURODIR)/src/neuron_t/neuron_t.c +NEUROSRC_O=$(NEUROSRC:.c=.o) + +INCLUDE_HEADERS_NEURONS=$(NEURODIR)/include_neurons/include + +TENSRC=$(TENSDIR)/src/tensor_t/tensor_t.c +TENSRC_O=$(TENSRC:.c=.o) + +PERMSRC_O=$(YPERMDIR)/src/permutation_t/permutation_t.o DIMSRC_O=$(DIMDIR)/src/dimension_t/dimension_t.o -NEUROSRC=src/neuron_t/neuron_t.c -NEUROSRC_O=$(NEUROSRC:.c=.o) +TOPTARGETS := all clean -TENSRC=$(TENSDIR)src/tensor_t/tensor_t.c -TENSRC_O=$(TENSRC:.c=.o) +#DEPS=$(DIMDIR) $(YPERMDIR) $(YTESTDIR) $(TENSDIR) $(NEURODIR) +DEPS=$(DIMDIR) $(YPERMDIR) $(TENSDIR) $(NEURODIR) -clTENSRC=$(TENSDIR)/src/tensor_t/cl_tensor_t.c -clTENSRC_O=$(clTENSRC:.c=.o) +OBJ=$(DIMSRC_O) $(PERMSRC_O) $(TENSRC_O) $(NEUROSRC_O) -PERMSRC_O=$(PERMDIR)/src/permutation_t/permutation_t.o +#LIB_YTEST=$(YTESTDIR)/libytest.so -#TOOLSRC_O=$(TOOLDIR)/src/tools_t/tools_t.o + +$(TOPTARGETS): $(DEPS) + +all: $(PROJECT_LIB) update_headers + +$(PROJECT_LIB): $(OBJ) + echo $(OBJ) + #$(CC) -shared -o $@ $^ $(INCLUDE) $(LDFLAGS) + #$(CC) -shared -o $@ $^ $(LDFLAGS) + #$(CC) -shared -o $@ $^ $(CFLAGS) + $(CC) -shared -o $@ $^ $(CFLAGS) $(LDFLAGS) + + + +$(DEPS): + $(MAKE) -C $@ $(MAKECMDGOALS) + +update_headers: $(PROJECT_LIB) + for file_h in $(DEPS); do + cd ${file_h}/src + #cp --parents "$$file_h/include/" include_neurons/; done + cp --parents "*/*.h" "$(INCLUDE_HEADERS_NEURONS)/" ; + done + + +#PERMSRC_O=$(PERMSRC:.c=.o) +#SETTSRC_O=$(PWD)/../src/set_theoric_t/set_theoric_t.o +#SETTSRC_O=$(SETTSRC:.c=.o) #TOOLSRC=$(TOOLDIR)/src/tools_t/tools_t.c #TOOLSRC_O=$(TOOLSRC:.c=.o) -#SRC=$(wildcard **/**/*.c) -#OBJ=$(SRC:.c=.o) #$(TOOLSRC_O) -OBJ=$(NEUROSRC_O) - -TOPTARGETS := all clean -DEP=$(DIMDIR) $(PERMDIR) $(TENSDIR) - -$(TOPTARGETS): $(DEP) - -all: $(NEUROSRC_O) - -$(NEUROSRC_O) : $(NEUROSRC) $(TENSRC_0) $(DIMSRC_O) $(PERMSRC_O) - $(CC) -o $@ -c $^ $(CFLAGS) -#$(DIMSRC_O) : $(DIMSRC) $(PERMSRC_O) -# $(CC) -o $@ -c $< $(CFLAGS) - -$(DEP): - $(MAKE) -C $@ $(MAKECMDGOALS) - -#$(TOOLSRC_O): $(TOOLSRC) -# $(CC) -o $@ -c $< $(CFLAGS) +#$(EXEC): $(EXECSRC) $(OBJ) +# $(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) .PHONY: clean mrproper @@ -66,7 +94,11 @@ clean: rm -f $(OBJ) mrproper: clean - rm -f $(EXEC) + rm -f $(PROJECT_LIB) -run: $(EXEC) - $(EXEC) -h +remove_headers: + rm -r $(INCLUDE_HEADERS_NEURONS)/* + + +#run: $(EXEC) +# $(EXEC) -h diff --git a/neuron_t/src/neuron_t/neuron_t.c b/neuron_t/src/neuron_t/neuron_t.c index 57d6913..1bc0334 100644 --- a/neuron_t/src/neuron_t/neuron_t.c +++ b/neuron_t/src/neuron_t/neuron_t.c @@ -893,6 +893,7 @@ void* run_learnCloneuronset_thread_##type(void *arg){\ sem_post(semaphore_learn);\ }\ sem_post(semaphore_learn);\ + return 0;\ }\ \ size_t learning_cloneuronset_##type(cloneuronset_##type *clnrnst, data_set_##type *dataset, bool (*condition)(type, size_t)){\ diff --git a/tensor_t/src/tensor_t/tensor_t.c b/tensor_t/src/tensor_t/tensor_t.c index 1caf422..b574b11 100644 --- a/tensor_t/src/tensor_t/tensor_t.c +++ b/tensor_t/src/tensor_t/tensor_t.c @@ -353,14 +353,14 @@ tensor_##type* CLONE_TENSOR_##type(tensor_##type *tens){\ }\ \ void print_tensor_msg_##type(tensor_##type *T,char *msg) {\ - size_t j=0,k=0;\ - long int *coord = malloc(sizeof(long int)*(T->dim)->size); \ + /*size_t j=0 ,k=0*/;\ + size_t *coord = malloc(sizeof(long int)*(T->dim)->size); \ char *val=NULL;\ char *dimsg=malloc(512);\ sprintf(dimsg,"(%s)->dim",msg);\ printDebug_dimension(T->dim,dimsg);\ printf("%s\n",msg);\ - long int begin , end, beginIter, endIter ;\ + long int begin , end /*, beginIter , endIter*/ ;\ long int (*iter)(long int) ;\ bool (*cond)(long int, long int) ; \ if (endian ) {\ @@ -404,15 +404,15 @@ void print_tensor_msg_##type(tensor_##type *T,char *msg) {\ \ \ void fprint_tensor_##type(char *file_name, tensor_##type *T) {\ - size_t j=0,k=0;\ - long int *coord = malloc(sizeof(long int)*(T->dim)->size); \ + /*size_t j=0,k=0;*/\ + size_t *coord = malloc(sizeof(long int)*(T->dim)->size); \ char *val=NULL;\ FILE *fileWrite = fopen(file_name, "w");\ if(fileWrite == NULL) {\ printf("error while opening %s\n",file_name);\ exit(1);\ }\ - long int begin , end, beginIter, endIter ;\ + long int begin , end /*, beginIter, endIter*/ ;\ long int (*iter)(long int) ;\ bool (*cond)(long int, long int) ; \ if (endian ) {\ @@ -427,7 +427,7 @@ void fprint_tensor_##type(char *file_name, tensor_##type *T) {\ fprintf(fileWrite,"[");\ for(size_t i=0; i<(T->dim)->size; ++i)\ fprintf(fileWrite," %ld,", (T->dim)->perm[i]);\ - fprintf(fileWrite,"] \n");\ + fprintf(fileWrite,"] \n");\ \ for(long int i=0;i<(T->dim)->rank;++i){\ vCoordFromLin(coord,i,T->dim);\ @@ -468,9 +468,9 @@ size_t sprint_tensor_##type(char **tensorContent,tensor_##type *T, bool withInde /*printf("malloc %ld char\n",sz);*/\ *tensorContent = malloc(sz ) ;\ size_t cur=0;\ - long int *coord = malloc(sizeof(long int)*(T->dim)->size); \ + size_t *coord = malloc(sizeof(long int)*(T->dim)->size); \ char *val=NULL;\ - long int begin , end, beginIter, endIter ;\ + long int begin , end /*, beginIter, endIter*/ ;\ long int (*iter)(long int) ;\ bool (*cond)(long int, long int) ; \ if (endian ) {\ @@ -705,6 +705,7 @@ void* runProd_thread_##type(void *arg){\ }\ arg_t->Mx[i] = arg_t->M0x[a0_id] * arg_t->M1x[a1_id];\ }\ + return 0;\ }\ \ void tensorProdThread_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1, size_t nbthread) { \ @@ -767,6 +768,7 @@ void* runProd_thread2d_##type(void *arg){\ arg_t->Mx[k] = arg_t->M0x[i] * arg_t->M1x[j];\ }\ }\ + return 0;\ }\ \ void tensorProdThrea2d_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1, size_t nbthread) { \ @@ -836,6 +838,7 @@ void* runProdContract_thread_##type(void *arg){\ arg_t->Mx[i] += arg_t->M0x[n0_id] * arg_t->M1x[n1_id];\ }\ }\ + return 0;\ }\ /* M[x0,x1,x3..xn] X M[y0,y1,y3..ym] = M[z0,z1...zp] (deep = l > 0) /exists 1<= l<...=n-l alor p=n+m-2l\ M[x0,x1,x3..xl x{l+1}...xn] X M[xn,x{n-1},x{n-2}...xl y{l+1} ..ym] = M[x0,x1..xly{l+1}...y{n+m-2l}] (deep = l > 0)\ @@ -933,6 +936,7 @@ void* runPro2dContract_thread_##type(void *arg){\ }\ }\ }\ + return 0;\ }\ /* M[x0,x1,x3..xn] X M[y0,y1,y3..ym] = M[z0,z1...zp] (deep = l > 0) /exists 1<= l<...=n-l alor p=n+m-2l\ M[x0,x1,x3..xl x{l+1}...xn] X M[xn,x{n-1},x{n-2}...xl y{l+1} ..ym] = M[x0,x1..xly{l+1}...y{n+m-2l}] (deep = l > 0)\ @@ -1246,7 +1250,7 @@ void parseInputOutput_withDim_to_tensors_##type(tensor_##type **Tpart1, tensor_# updateRankDim(ddim2);\ array_chainlist_##type *l_a1=NULL;\ array_chainlist_##type *l_a2=NULL;\ - size_t i1=0,i=0,j=0,i2=0;\ + size_t i1=0, /*i=0,j=0, */ i2=0;\ bool filled1=false,filled2=false;\ type x;\ while(ppEnd && (ppEnd[0] !='\0')){\ @@ -1616,6 +1620,7 @@ void* run1UpdatCalcfunc_thread_##type(void *arg){\ for (size_t i = arg_t->beginRange; i < arg_t->endRange; i++) {\ arg_t->M0x[i] = arg_t->func(arg_t->M0x[i]);\ }\ + return 0;\ }\ \ void update_1tensor_func_##type(tensor_##type *M0, type (*func)(type), size_t nbthread){\ @@ -1654,6 +1659,7 @@ void* run2UpdatCalcfunc_thread_##type(void *arg){\ for (size_t i = arg_t->beginRange; i < arg_t->endRange; i++) {\ arg_t->M0x[i] = arg_t->func(arg_t->M1x[i]);\ }\ + return 0;\ }\ \ void update_2tensor_func_##type(tensor_##type *M0, tensor_##type *M1, type (*func)(type), size_t nbthread){\ @@ -1695,6 +1701,7 @@ void* run3UpdatCalcfunc_thread_##type(void *arg){\ for (size_t i = arg_t->beginRange; i < arg_t->endRange; i++) {\ arg_t->M0x[i] = arg_t->func(arg_t->M1x[i], arg_t->M2x[i]);\ }\ + return 0;\ }\ \ void update_3tensor_func_##type(tensor_##type *M0, tensor_##type *M1, tensor_##type *M2, type (*func)(type,type), size_t nbthread){\ @@ -1739,6 +1746,7 @@ void* run4UpdatCalcfunc_thread_##type(void *arg){\ for (size_t i = arg_t->beginRange; i < arg_t->endRange; i++) {\ arg_t->M0x[i] = arg_t->func(arg_t->M1x[i], arg_t->M2x[i], arg_t->f1);\ }\ + return 0;\ }\ \ void update_4tensor_func_##type(tensor_##type *M0, tensor_##type *M1, tensor_##type *M2, \ @@ -1793,6 +1801,7 @@ void* run5UpdatCalcfunc_thread_##type(void *arg){\ for (size_t i = arg_t->beginRange; i < arg_t->endRange; i++) {\ arg_t->M0x[i] = arg_t->func(arg_t->M1x[i], arg_t->M2x[i], arg_t->M3x[i], arg_t->f1, arg_t->f2);\ }\ + return 0;\ }\ \ void update_5tensor_func_##type(tensor_##type *M0, tensor_##type *M1, tensor_##type *M2, tensor_##type *M3 , \ @@ -1843,6 +1852,7 @@ void* run6UpdatCalcfunc_thread_##type(void *arg){\ for (size_t i = arg_t->beginRange; i < arg_t->endRange; i++) {\ arg_t->M0x[i] = arg_t->func(arg_t->M0x[i], arg_t->M1x[i], arg_t->scalar);\ }\ + return 0;\ }\ \ void update_6tensor_func_##type(tensor_##type *M0, tensor_##type *M1, \ diff --git a/ypermutation_t/src/permutation_t/permutation_t.c b/ypermutation_t/src/permutation_t/permutation_t.c index f5c3cf7..6b5a368 100644 --- a/ypermutation_t/src/permutation_t/permutation_t.c +++ b/ypermutation_t/src/permutation_t/permutation_t.c @@ -173,7 +173,7 @@ size_t TabToPlaceNotab_##type(const PERMUTATION_##type *p){\ size_t sz = p->size;\ PERMUTATION_TYPE_SIZE_T *t_p = TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(p);\ size_t *tb= t_p->perm;\ - size_t mx = sz - 1;\ + /*size_t mx = sz - 1;*/\ size_t q = 0;\ size_t pl;\ for (long int i = 0; i < sz; i++) {\ @@ -199,7 +199,7 @@ PERMUTATION_TYPE_SIZE_T * PlaceToTab_##type(PERMUTATION_##type *p, size_t pl){\ /*PERMUTATION_TYPE_SIZE_T *t_p = CREATE_PERMUTATION_TYPE_SIZE_T(sz);*/\ PERMUTATION_TYPE_SIZE_T *t_p = TRANSLATE_TO_SET_THEORIC_SIZE_T_##type(p);\ type *save_perm = malloc(sz*sizeof(type));\ - long int *tb= t_p->perm;\ + size_t *tb= t_p->perm;\ size_t a = pl;\ size_t pltbi;\ for (long int i = 0;i < sz;i++) {\