HW3: RC4 - Add a qsort for reference

This commit is contained in:
Christos Choutouridis 2025-02-21 19:16:21 +02:00
parent dac00ed194
commit ac53a58a70
3 changed files with 20 additions and 1 deletions

View File

@ -187,6 +187,16 @@ bitonic_v2deb: $(BUILD_DIR)/$(TARGET)
cp $(BUILD_DIR)/$(TARGET) $(OUTPUT_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: CC := nvcc -x cu
bitonic_v0: CXX := nvcc -x cu bitonic_v0: CXX := nvcc -x cu

View File

@ -16,6 +16,7 @@
#include <cstdint> #include <cstdint>
#include <utility> #include <utility>
#include <stdexcept> #include <stdexcept>
#include <algorithm>
#include "utils.hpp" #include "utils.hpp"
@ -117,8 +118,15 @@ __device__ void exchange(ValueT* data, threadId_t tid, threadId_t partner, bool
data[partner] = temp; 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 * This is the body of each thread. This function compare and exchange data

View File

@ -28,6 +28,7 @@ static constexpr char version[] = "0.4";
#define V0 0 #define V0 0
#define V1 1 #define V1 1
#define V2 2 #define V2 2
#define SERIAL 's'
// Fail-safe version selection // Fail-safe version selection
#if !defined CODE_VERSION #if !defined CODE_VERSION