# # Arquiteturas de Alto Desempenho 2025/2026 # # makefile for the first practical assignment (A1) # # makefile automatic variables: # $@ is the name of the target # $< is the name of the first prerequisite # $^ is the list of names of all prerequisites (without duplicates) # # # CUDA installation directory --- /usr/local/cuda or $(CUDA_HOME) # CUDA_DIR = /opt/cuda # # OpenCL installation directory (for a NVidia graphics card, sama as CUDA) # OPENCL_DIR = $(CUDA_DIR) # # CUDA device architecture # # GeForce GTX 1660 Ti --- sm_75 # RTX A2000 Ada --------- sm_86 # RTX A6000 Ada --------- sm_86 # RTX 4070 -------------- sm_89 # CUDA_ARCH = sm_86 # # clean up # clean: rm -f sha1_tests rm -f sha1_cuda_test sha1_cuda_kernel.cubin rm -f coin_miner_cpu coin_miner_simd coin_miner_cuda coin_miner_cuda_kernel.cubin coin_miner_ocl rm -f coin_miner_wasm.js coin_miner_wasm.wasm rm -f benchmark rm -f a.out # # test the CUSTOM_SHA1_CODE macro # sha1_tests: aad_sha1_cpu_tests.c aad_sha1.h aad_data_types.h aad_utilities.h makefile cc -march=native -Wall -Wshadow -Werror -O3 $< -o $@ sha1_cuda_test: aad_sha1_cuda_test.c sha1_cuda_kernel.cubin aad_sha1.h aad_data_types.h aad_utilities.h aad_cuda_utilities.h makefile cc -march=native -Wall -Wshadow -Werror -O3 -I$(CUDA_DIR)/include $< -o $@ -lcuda # # compile the CUDA kernels # sha1_cuda_kernel.cubin: aad_sha1_cuda_kernel.cu aad_sha1.h makefile nvcc -arch=$(CUDA_ARCH) --compiler-options -O2,-Wall -I$(CUDA_DIR)/include --cubin $< -o $@ all: sha1_tests sha1_cuda_test sha1_cuda_kernel.cubin # # DETI coin miners # coin_miner_cpu: aad_coin_miner_cpu.c aad_sha1.h aad_sha1_cpu.h aad_data_types.h aad_utilities.h aad_vault.h makefile cc -march=native -Wall -Wshadow -Werror -O3 $< -o $@ coin_miner_simd: aad_coin_miner_simd.c aad_sha1.h aad_sha1_cpu.h aad_data_types.h aad_utilities.h aad_vault.h makefile cc -march=native -Wall -Wshadow -Werror -fopenmp -mavx2 -O3 $< -o $@ coin_miner_cuda_kernel.cubin: aad_coin_miner_cuda_kernel.cu aad_sha1.h makefile nvcc -arch=$(CUDA_ARCH) --compiler-options -O2,-Wall -I$(CUDA_DIR)/include --cubin $< -o $@ coin_miner_cuda: aad_coin_miner_cuda.c coin_miner_cuda_kernel.cubin aad_sha1.h aad_sha1_cpu.h aad_data_types.h aad_utilities.h aad_vault.h aad_cuda_utilities.h makefile cc -march=native -Wall -Wshadow -Werror -O3 -I$(CUDA_DIR)/include $< -o $@ -lcuda coin_miner_ocl: aad_coin_miner_ocl.c aad_coin_miner_ocl_kernel.cl aad_sha1.h aad_sha1_cpu.h aad_sha1_ocl_kernel.cl aad_data_types.h aad_utilities.h aad_vault.h aad_ocl_utilities.h makefile cc -march=native -Wall -Wshadow -O3 $< -o $@ -lOpenCL coin_miner_wasm: aad_coin_miner_wasm.c aad_sha1.h aad_sha1_cpu.h aad_sha1_wasm.h aad_data_types.h aad_utilities.h aad_vault.h makefile emcc -O3 -flto -msimd128 -o coin_miner_wasm.js aad_coin_miner_wasm.c \ -s WASM=1 \ -s EXPORTED_FUNCTIONS='["_mine_coins_wasm","_get_statistics","_stop_mining","_reset_mining","_get_found_coin","_get_found_coins_count","_malloc","_free"]' \ -s EXPORTED_RUNTIME_METHODS='["cwrap","ccall","getValue","setValue"]' \ -s ALLOW_MEMORY_GROWTH=1 \ -s MODULARIZE=1 \ -s EXPORT_NAME='CoinMinerModule' \ -s INITIAL_MEMORY=67108864 benchmark: aad_benchmark.c aad_sha1.h aad_sha1_cpu.h aad_data_types.h aad_utilities.h makefile cc -march=native -Wall -Wshadow -Werror -O3 $< -o $@ miners: coin_miner_cpu coin_miner_simd coin_miner_wasm coin_miner_cuda coin_miner_ocl benchmark all: sha1_tests sha1_cuda_test sha1_cuda_kernel.cubin \ coin_miner_cpu coin_miner_simd coin_miner_wasm coin_miner_cuda coin_miner_cuda_kernel.cubin coin_miner_ocl \ benchmark