diff --git a/Makefile b/Makefile index 5ceb88d..c904d8b 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,12 @@ NVCCFLAGS = -g # -fsanitize=address -lasan #! WARNING: test/cnn-neuron_io fails with this option enabled + + all: dense cnn; + + + # # Build dense # @@ -61,82 +66,95 @@ $(BUILDDIR)/dense_%.o: $(DENSE_SRCDIR)/%.c $(DENSE_SRCDIR)/include/%.h $(CC) -c $< -o $@ $(CFLAGS) + # # Build cnn # cnn: $(BUILDDIR)/cnn-main $(BUILDDIR)/cnn-main-cuda $(BUILDDIR)/cnn-preview $(BUILDDIR)/cnn-export; $(BUILDDIR)/cnn-main: $(CNN_SRCDIR)/main.c \ - $(BUILDDIR)/cnn_train.o \ - $(BUILDDIR)/cnn_test_network.o \ - $(BUILDDIR)/cnn_cnn.o \ - $(BUILDDIR)/cnn_creation.o \ + $(BUILDDIR)/cnn_backpropagation.o \ $(BUILDDIR)/cnn_initialisation.o \ - $(BUILDDIR)/cnn_make.o \ + $(BUILDDIR)/cnn_test_network.o \ + $(BUILDDIR)/cnn_convolution.o \ $(BUILDDIR)/cnn_neuron_io.o \ $(BUILDDIR)/cnn_function.o \ - $(BUILDDIR)/cnn_utils.o \ + $(BUILDDIR)/cnn_creation.o \ + $(BUILDDIR)/cnn_models.o \ $(BUILDDIR)/cnn_update.o \ + $(BUILDDIR)/cnn_train.o \ + $(BUILDDIR)/cnn_utils.o \ + $(BUILDDIR)/cnn_make.o \ $(BUILDDIR)/cnn_free.o \ $(BUILDDIR)/cnn_jpeg.o \ - $(BUILDDIR)/cnn_convolution.o \ - $(BUILDDIR)/cnn_backpropagation.o \ + $(BUILDDIR)/cnn_cnn.o \ + \ $(BUILDDIR)/memory_management.o \ $(BUILDDIR)/colors.o \ $(BUILDDIR)/mnist.o \ $(BUILDDIR)/utils.o $(CC) $^ -o $@ $(CFLAGS) $(LD_CFLAGS) + ifdef NVCC_INSTALLED $(BUILDDIR)/cnn-main-cuda: $(BUILDDIR)/cnn_main.cuda.o \ - $(BUILDDIR)/cnn_train.cuda.o \ - $(BUILDDIR)/cnn_test_network.cuda.o \ - $(BUILDDIR)/cnn_cnn.cuda.o \ - $(BUILDDIR)/cnn_creation.cuda.o \ $(BUILDDIR)/cnn_initialisation.cuda.o \ - $(BUILDDIR)/cnn_cuda_make.o \ + $(BUILDDIR)/cnn_test_network.cuda.o \ $(BUILDDIR)/cnn_neuron_io.cuda.o \ - $(BUILDDIR)/cnn_cuda_function.o \ - $(BUILDDIR)/cnn_utils.cuda.o \ + $(BUILDDIR)/cnn_creation.cuda.o \ + $(BUILDDIR)/cnn_models.cuda.o \ $(BUILDDIR)/cnn_update.cuda.o \ + $(BUILDDIR)/cnn_train.cuda.o \ + $(BUILDDIR)/cnn_utils.cuda.o \ $(BUILDDIR)/cnn_free.cuda.o \ $(BUILDDIR)/cnn_jpeg.cuda.o \ - $(BUILDDIR)/cnn_cuda_convolution.o \ + $(BUILDDIR)/cnn_cnn.cuda.o \ + \ $(BUILDDIR)/cnn_cuda_backpropagation.o \ - $(BUILDDIR)/colors.cuda.o \ + $(BUILDDIR)/cnn_cuda_convolution.o \ + $(BUILDDIR)/cnn_cuda_function.o \ + $(BUILDDIR)/cnn_cuda_make.o \ + \ $(BUILDDIR)/cuda_memory_management.o \ + $(BUILDDIR)/colors.cuda.o \ $(BUILDDIR)/mnist.cuda.o \ - $(BUILDDIR)/cuda_utils.o + $(BUILDDIR)/cuda_utils.o $(NVCC) $(LD_NVCCFLAGS) $(NVCCFLAGS) $^ -o $@ else $(BUILDDIR)/cnn-main-cuda: @echo "$(NVCC) not found, skipping" endif + $(BUILDDIR)/cnn-preview: $(CNN_SRCDIR)/preview.c $(BUILDDIR)/cnn_jpeg.o $(BUILDDIR)/colors.o $(BUILDDIR)/utils.o $(CC) $^ -o $@ $(CFLAGS) $(LD_CFLAGS) + $(BUILDDIR)/cnn-export: $(CNN_SRCDIR)/export.c \ - $(BUILDDIR)/cnn_free.o \ - $(BUILDDIR)/cnn_neuron_io.o \ - $(BUILDDIR)/utils.o \ - $(BUILDDIR)/memory_management.o \ - $(BUILDDIR)/cnn_cnn.o \ - $(BUILDDIR)/cnn_make.o \ $(BUILDDIR)/cnn_backpropagation.o \ + $(BUILDDIR)/cnn_convolution.o \ + $(BUILDDIR)/cnn_neuron_io.o \ $(BUILDDIR)/cnn_function.o \ - $(BUILDDIR)/cnn_convolution.o \ + $(BUILDDIR)/cnn_free.o \ + $(BUILDDIR)/cnn_make.o \ + $(BUILDDIR)/cnn_cnn.o \ + $(BUILDDIR)/cnn_jpeg.o \ + \ + $(BUILDDIR)/memory_management.o \ $(BUILDDIR)/colors.o \ $(BUILDDIR)/mnist.o \ - $(BUILDDIR)/cnn_jpeg.o + $(BUILDDIR)/utils.o $(CC) $^ -o $@ $(CFLAGS) $(LD_CFLAGS) + $(BUILDDIR)/cnn_%.o: $(CNN_SRCDIR)/%.c $(CNN_SRCDIR)/include/%.h $(CC) -c $< -o $@ $(CFLAGS) + $(BUILDDIR)/cnn_%.cuda.o: $(CNN_SRCDIR)/%.c $(CNN_SRCDIR)/include/%.h $(CC) -c $< -o $@ $(CFLAGS) -DUSE_CUDA -lcuda -I$(CUDA_INCLUDE) + ifdef NVCC_INSTALLED $(BUILDDIR)/cnn_cuda_%.o: $(CNN_SRCDIR)/%.cu $(CNN_SRCDIR)/include/%.h $(NVCC) $(NVCCFLAGS) -c -dc $< -o $@ @@ -144,15 +162,20 @@ else $(BUILDDIR)/cnn_cuda_%.o: $(CNN_SRCDIR)/%.cu $(CNN_SRCDIR)/include/%.h @echo "$(NVCC) not found, skipping" endif + + + # # Build general files # $(BUILDDIR)/%.o: $(COMMON_SRCDIR)/%.c $(COMMON_SRCDIR)/include/%.h $(CC) -c $< -o $@ $(CFLAGS) + $(BUILDDIR)/%.cuda.o: $(COMMON_SRCDIR)/%.c $(COMMON_SRCDIR)/include/%.h $(CC) -c $< -o $@ $(CFLAGS) -DUSE_CUDA -lcuda -I$(CUDA_INCLUDE) + ifdef NVCC_INSTALLED $(BUILDDIR)/cuda_%.o: $(COMMON_SRCDIR)/%.cu $(COMMON_SRCDIR)/include/%.h $(NVCC) $(NVCCFLAGS) -c -dc $< -o $@ @@ -160,6 +183,8 @@ else @echo "$(NVCC) not found, skipping" endif + + # # Tests # @@ -207,6 +232,8 @@ $(BUILDDIR)/test-cnn_%: $(TEST_SRCDIR)/cnn_%.cu @echo "$(NVCC) not found, skipping" endif + + # # Utils # @@ -231,6 +258,7 @@ $(CACHE_DIR)/mnist-reseau-cnn.bin: $(BUILDDIR)/cnn-main --out $(CACHE_DIR)/mnist-reseau-cnn.bin + # # Clean project # diff --git a/src/cnn/train.c b/src/cnn/train.c index c292c11..ad971dd 100644 --- a/src/cnn/train.c +++ b/src/cnn/train.c @@ -8,15 +8,15 @@ #include #include "../common/include/memory_management.h" +#include "../common/include/colors.h" +#include "../common/include/utils.h" #include "../common/include/mnist.h" #include "include/initialisation.h" #include "include/test_network.h" #include "include/neuron_io.h" -#include "../common/include/colors.h" -#include "../common/include/utils.h" #include "include/function.h" -#include "include/creation.h" #include "include/update.h" +#include "include/models.h" #include "include/utils.h" #include "include/free.h" #include "include/jpeg.h" diff --git a/test/cnn_neuron_io.c b/test/cnn_neuron_io.c index ee9a44f..987c448 100644 --- a/test/cnn_neuron_io.c +++ b/test/cnn_neuron_io.c @@ -6,6 +6,7 @@ #include "../src/common/include/colors.h" #include "../src/cnn/include/neuron_io.h" #include "../src/cnn/include/creation.h" +#include "../src/cnn/include/models.h" #include "../src/cnn/include/utils.h" #include "../src/cnn/include/free.h" diff --git a/test/cnn_structure.c b/test/cnn_structure.c index bb1ce73..1f8d594 100644 --- a/test/cnn_structure.c +++ b/test/cnn_structure.c @@ -5,6 +5,7 @@ #include "../src/common/include/colors.h" #include "../src/cnn/include/creation.h" +#include "../src/cnn/include/models.h" #include "../src/cnn/include/utils.h" #include "../src/cnn/include/free.h" diff --git a/test/cnn_utils.c b/test/cnn_utils.c index d522325..22d212a 100644 --- a/test/cnn_utils.c +++ b/test/cnn_utils.c @@ -3,6 +3,7 @@ #include "../src/common/include/colors.h" #include "../src/cnn/include/creation.h" +#include "../src/cnn/include/models.h" #include "../src/cnn/include/utils.h" #include "../src/cnn/include/free.h"