From 51d7e6dd88c788057862d0afaba6d6c0ca237155 Mon Sep 17 00:00:00 2001 From: Christos Choutouridis Date: Mon, 11 Nov 2024 20:13:05 +0200 Subject: [PATCH] Enable openblas --- homework_1/Makefile | 24 +++++++++++++++++------- homework_1/src/main.cpp | 11 ++++++++++- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/homework_1/Makefile b/homework_1/Makefile index 7bfadec..ac341b5 100644 --- a/homework_1/Makefile +++ b/homework_1/Makefile @@ -25,7 +25,8 @@ TARGET := knnsearch # Source directories list(space seperated). Makefile-relative path, UNDER current directory. SRC_DIR_LIST := src # Include directories list(space seperated). Makefile-relative path. -INC_DIR_LIST := src inc +INC_DIR_LIST := inc \ + src # Exclude files list(space seperated). Filenames only. # EXC_FILE_LIST := bad.cpp old.cpp @@ -48,7 +49,7 @@ PRE_DEFS := # ============== Linker settings ============== # Linker flags (example: -pthread -lm) -LDFLAGS := -pthread +LDFLAGS := -pthread -lopenblas # Map output file MAP_FILE := output.map MAP_FLAG := -Xlinker -Map=$(BUILD_DIR)/$(MAP_FILE) @@ -57,7 +58,7 @@ MAP_FLAG := -Xlinker -Map=$(BUILD_DIR)/$(MAP_FILE) # We need: # - Bind the entire project directory(the dir that icludes all the code) as volume. # - In docker instance, change to working directory(where the makefile is). -DOCKER_VOL_DIR := $${PWD} +DOCKER_VOL_DIR := ${PWD} DOCKER_WRK_DIR := DOCKER_RUN := docker run --rm DOCKER_FLAGS := -v $(DOCKER_VOL_DIR):/usr/src/$(PROJECT) -w /usr/src/$(PROJECT)/$(DOCKER_WRK_DIR) @@ -137,8 +138,8 @@ include $(wildcard $(DEP)) $(BUILD_DIR)/$(TARGET): $(OBJ) @mkdir -p $(@D) @echo Linking to target: $(TARGET) - @echo $(DOCKER) $(CXX) $(LDFLAGS) $(MAP_FLAG) -o $(@D)/$(TARGET) '$$(OBJ)' - @$(DOCKER) $(CXX) $(LDFLAGS) $(MAP_FLAG) -o $(@D)/$(TARGET) $(OBJ) + @echo $(DOCKER) $(CXX) '$$(OBJ)' $(LDFLAGS) $(MAP_FLAG) -o $(@D)/$(TARGET) + @$(DOCKER) $(CXX) $(OBJ) $(LDFLAGS) $(MAP_FLAG) -o $(@D)/$(TARGET) @echo @echo Print size information @$(CSIZE) $(@D)/$(TARGET) @@ -221,7 +222,6 @@ v1: $(BUILD_DIR)/$(TARGET) cp $(BUILD_DIR)/$(TARGET) out/$(TARGET) - # # ========= Inside CSAL Image build rules =========== # @@ -258,4 +258,14 @@ csal_v1: TARGET := knnsearch_v1 csal_v1: $(BUILD_DIR)/$(TARGET) - +# +# ======== Run from container ========= +# +# examples: +# +# make IMAGE=hpcimage EXEC=knnsearch_v1 run +# make IMAGE=hpcimage EXEC=knnsearch_cilkv1 run +# +run: DOCKER := $(DOCKER_CMD) +run: + $(DOCKER) ./out/$(EXEC) diff --git a/homework_1/src/main.cpp b/homework_1/src/main.cpp index 4af4fc0..5b2e1d5 100644 --- a/homework_1/src/main.cpp +++ b/homework_1/src/main.cpp @@ -1,6 +1,15 @@ #include +#include int main(){ - std::cout << "Hello from knnsearch\n"; + + double A[6] = {1.0,2.0,1.0,-3.0,4.0,-1.0}; + double B[6] = {1.0,2.0,1.0,-3.0,4.0,-1.0}; + double C[9] = {.5,.5,.5,.5,.5,.5,.5,.5,.5}; + cblas_dgemm(CblasColMajor, CblasNoTrans, CblasTrans,3,3,2,1,A, 3, B, 3,2,C,3); + + for (int i=0 ; i<9 ; ++i) + std::cout << C[i] << ' '; + std::cout << '\n'; return 0; }