diff --git a/Makefile b/Makefile index bcb35f8..8812d1b 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,18 @@ CXX ?= g++ OPTFLAGS ?= -O3 -march=native - VECTOR_SIZE ?= 268435456 -CPPFLAGS = -DVECTOR_SIZE=$(VECTOR_SIZE) -INCLUDES = -I./include -I$(EVENTIFY_ROOT)/include +ENABLE_EVENTIFY ?= YES +CPPFLAGS = -DVECTOR_SIZE=$(VECTOR_SIZE) +INCLUDES = -I./include CXXFLAGS = $(CPPFLAGS) -std=c++20 -fopenmp $(INCLUDES) $(OPTFLAGS) -LDFLAGS = -fopenmp -L$(EVENTIFY_ROOT)/lib -leventify +LDFLAGS = -fopenmp + +ifeq ($(ENABLE_EVENTIFY), "YES") + CPPFLAGS += -DENABLE_EVENTIFY + INCLUDES += -I$(EVENTIFY_ROOT)/include + LDFLAGS += -L$(EVENTIFY_ROOT)/lib -leventify +endif SRC_DIR = src INCLUDE_DIR = include diff --git a/README.md b/README.md index a6a5947..6163284 100644 --- a/README.md +++ b/README.md @@ -35,12 +35,10 @@ You may as well contact the author Patrick Lipka (patrick.lipka@sipearl.com). - C++20 or higher - OpenMP support (for OpenMP parallelization strategy) -- Eventify library (for Eventify parallelization strategy) -- Limitation: Providing installs for all implemented parallelization strategies is mandantory at this point. Selective compilation of strategies might be added later if needed. ### Dependencies: -- **Eventify**: Ensure that the Eventify library is properly installed and the environment variable `EVENTIFY_ROOT` points to the root directory of the Eventify installation. +- **Eventify**: If you want to compiler with eventify (`ENABLE_EVENTIFY=YES`), ensure that the eventify library is properly installed and the environment variable `EVENTIFY_ROOT` points to the root directory of the Eventify installation. ## Building the Project @@ -50,7 +48,13 @@ To build the project, run: make ``` -This will compile the source files and generate an executable called `benchmark` in the `bin/` directory. +The default is to compile with eventify enabled `ENABLE_EVENTIFY=YES`. If you want to build without eventify, please done + +``` +ENABLE_EVENTIFY=NO make +``` + +The make command will compile the source files and generate an executable called `benchmark` in the `bin/` directory. Similar to the STREAM benchmark´s Makefile, the vector sizes are defined by the preprocessor variable `VECTOR_SIZE` that can be set in the Makefile. ### Clean Up @@ -158,11 +162,11 @@ To add a new kernel to the project, follow these steps: - Kernels must be registered with a **name** (e.g., `"vector_product"`) and should include the corresponding **allocations and data initialization** (`prepare`) and **kernel logic** (`execute`). - Kernels must consist out of an outer loop at least for now. -- The kernel’s execution should be parallelizable using all of the available strategies (`omp` (OpenMP) and `eventify` (Eventify) for now). You can add more strategies by extending the `strategy` namespace. +- The kernel’s execution should be parallelizable using all of the available strategies (`omp` (OpenMP) and `eventify` (eventify tasking library) for now). You can add more strategies by extending the `strategy` namespace. - The `VECTOR_SIZE` preprocessor variable defines the size of the input data and should be appropriate for the kernel you are implementing. ## Known Isuues and Limitations -- The instantiation of Eventify's `task_system` is inckluded in the kernel timing, leading to a constant overhead compared to OpenMP. On NVIDIA Grace, this is 2.8 ms. It's ongoning discussion whether to include it or not. +- The instantiation of eventify's `task_system` is inckluded in the kernel timing, leading to a constant overhead compared to OpenMP. On NVIDIA Grace, this is 2.8 ms. It's ongoning discussion whether to include it or not. ## Contributing diff --git a/include/strategy.hpp b/include/strategy.hpp index d4f93ed..07fd1ed 100644 --- a/include/strategy.hpp +++ b/include/strategy.hpp @@ -2,11 +2,13 @@ #define STRATEGY_HPP #include - -#include #include #include +#ifdef ENABLE_EVENTIFY +#include +#endif + // Parallelization strategies are defined here. Assumption for now: there is // always an outer loop than can be parallelized. The strategies are templates // instanciated when adding kernels to the kernel registry. @@ -35,6 +37,7 @@ void openmp_strategy(int kernel_start_idx, int kernel_end_idx, int n_threads, } } +#ifdef ENABLE_EVENTIFY // for eventify, we calculate indices for evenly divided chunks of the outermost // loop, create independent tasks and submit them to the tasking system template @@ -59,7 +62,8 @@ void eventify_strategy(int kernel_start_idx, int kernel_end_idx, int n_tasks, task_system.submit(task); } } - +#endif //ENABLE_EVENTIFY + // parallelization strategy selector template requires invocable_with_int @@ -69,9 +73,11 @@ void execute_strategy(const std::string& strategy_name, int kernel_start_idx, if (strategy_name == "omp") { openmp_strategy(kernel_start_idx, kernel_end_idx, num_threads_or_tasks, std::forward(loop_body)); +#ifdef ENABLE_EVENTIFY } else if (strategy_name == "eventify") { eventify_strategy(kernel_start_idx, kernel_end_idx, num_threads_or_tasks, std::forward(loop_body)); +#endif } else { throw std::invalid_argument("Unknown strategy: " + strategy_name); }