diff --git a/homework_3/Makefile b/homework_3/Makefile index 75914d9..caae5a1 100644 --- a/homework_3/Makefile +++ b/homework_3/Makefile @@ -187,6 +187,16 @@ bitonic_v2deb: $(BUILD_DIR)/$(TARGET) cp $(BUILD_DIR)/$(TARGET) $(OUTPUT_DIR)/$(TARGET) +bitonic_ser: CC := nvcc -x cu +bitonic_ser: CXX := nvcc -x cu +bitonic_ser: LINKER := nvcc +bitonic_ser: CFLAGS := $(REL_CFLAGS) -DCODE_VERSION=SERIAL +bitonic_ser: CXXFLAGS := $(REL_CXXFLAGS) -DCODE_VERSION=SERIAL +bitonic_ser: OUTPUT_DIR := $(OUTPUT_DIR)/serial +bitonic_ser: $(BUILD_DIR)/$(TARGET) + @mkdir -p $(OUTPUT_DIR) + cp $(BUILD_DIR)/$(TARGET) $(OUTPUT_DIR)/$(TARGET) + bitonic_v0: CC := nvcc -x cu bitonic_v0: CXX := nvcc -x cu diff --git a/homework_3/src/bitonicsort.hpp b/homework_3/src/bitonicsort.hpp index 98c8904..134beaa 100644 --- a/homework_3/src/bitonicsort.hpp +++ b/homework_3/src/bitonicsort.hpp @@ -16,6 +16,7 @@ #include <cstdint> #include <utility> #include <stdexcept> +#include <algorithm> #include "utils.hpp" @@ -117,8 +118,15 @@ __device__ void exchange(ValueT* data, threadId_t tid, threadId_t partner, bool data[partner] = temp; } } +#if CODE_VERSION == SERIAL -#if CODE_VERSION == V0 +template <typename DataT> +void bitonicSort(DataT& data) { + std::sort(data.begin(), data.end()); +} + + +#elif CODE_VERSION == V0 /*! * This is the body of each thread. This function compare and exchange data diff --git a/homework_3/src/config.h b/homework_3/src/config.h index 6dd5627..017d11d 100644 --- a/homework_3/src/config.h +++ b/homework_3/src/config.h @@ -28,6 +28,7 @@ static constexpr char version[] = "0.4"; #define V0 0 #define V1 1 #define V2 2 +#define SERIAL 's' // Fail-safe version selection #if !defined CODE_VERSION