Skip to content

Commit

Permalink
Fixed loading procedure for NIPS dataset to work correctly with the n…
Browse files Browse the repository at this point in the history
…ew naming in triplet.h
  • Loading branch information
Cobra8 committed Oct 24, 2023
1 parent fcab0e3 commit b399c5c
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 39 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.22)
project(dphpc)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

enable_language(CUDA)
Expand Down
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# set(CMAKE_BUILD_TYPE Debug) # Remove for measurements

set(SRC_FILES
# Matrix representations
matrices/Dense.hpp
Expand Down
74 changes: 42 additions & 32 deletions src/benchmark/benchmark.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,50 +52,60 @@ namespace SDDMM {
/* Run the benchmark with all competitors */
std::for_each(competitors.begin(), competitors.end(), [this](std::shared_ptr<Competitor<T>> competitor_ptr) {
auto competitor = competitor_ptr.get();
uint64_t ns;
uint64_t ns = 0;
bool csr_correctness = false, coo_correcntess = false;

/* ============================= */
/* Sparse matrices in CSR format */
/* ============================= */
DEBUG_OUT("Running competitor " << competitor->name << " (Sparse matrices represented as CSR)" << std::endl);

CSR<T> P_csr(this->getDataset().getS_CSR());
P_csr.clearValues();

// Running competitor
ns = timing([&] { // TODO: Cold/Warm Cache? CPU Calibration?
competitor->run_csr(this->getDataset().getA(), this->getDataset().getB(), this->getDataset().getS_CSR(), P_csr);
});

// Checking correctness if available
if (competitor->csr_supported() && this->getDataset().hasExpected()) {
csr_correctness = (P_csr == this->getDataset().getExpected_CSR());
if (csr_correctness) { DEBUG_OUT(" - Calculated correct results." << std::endl); }
else { DEBUG_OUT(" - !!! Wrong results calculated compared to CPU-Basic (CSR) !!!" << std::endl); }
if (competitor->csr_supported()) {
DEBUG_OUT("Running competitor " << competitor->name << " (Sparse matrices represented as CSR)" << std::endl);

CSR<T> P_csr(this->getDataset().getS_CSR());
P_csr.clearValues();

// Running competitor
ns = timing([&] { // TODO: Cold/Warm Cache? CPU Calibration?
competitor->run_csr(this->getDataset().getA(), this->getDataset().getB(), this->getDataset().getS_CSR(), P_csr);
});

// Checking correctness if available
if (this->getDataset().hasExpected()) {
csr_correctness = (P_csr == this->getDataset().getExpected_CSR());
if (csr_correctness) { DEBUG_OUT(" - Calculated correct results." << std::endl); }
else { DEBUG_OUT(" - !!! Wrong results calculated compared to CPU-Basic (CSR) !!!" << std::endl); }
}
DEBUG_OUT(" - Execution took " << SECOND(ns) << " seconds (" << ns << "ns)" << std::endl << std::endl);
} else {
DEBUG_OUT("Skipping competitor " << competitor->name << " (does not support CSR)" << std::endl << std::endl);
}
DEBUG_OUT(" - Execution took " << SECOND(ns) << " seconds (" << ns << "ns)" << std::endl << std::endl);

FILE_DUMP(competitor->name << "," << this->getDataset().getName() << ",CSR," << competitor->csr_supported() << "," << this->getDataset().getS_COO().getRows() << "," << this->getDataset().getS_COO().getCols() << "," << this->getDataset().getA().getCols() << "," << ns << "," << csr_correctness << std::endl);

/* ============================= */
/* Sparse matrices in COO format */
/* ============================= */
DEBUG_OUT("Running competitor " << competitor->name << " (Sparse matrices represented as COO)" << std::endl);

COO<T> P_coo(this->getDataset().getS_COO());
P_coo.clearValues();

ns = timing([&] { // TODO: Cold/Warm Cache? CPU Calibration?
competitor->run_coo(this->getDataset().getA(), this->getDataset().getB(), this->getDataset().getS_COO(), P_coo);
});

// Checking correctness if available
if (competitor->coo_supported() && this->getDataset().hasExpected()) {
coo_correcntess = (P_coo == this->getDataset().getExpected_COO());
if (coo_correcntess) { DEBUG_OUT(" - Calculated correct results." << std::endl); }
else { DEBUG_OUT(" - !!! Wrong results calculated compared to CPU-Basic (CSR) !!!" << std::endl); }
if (competitor->coo_supported()) {
DEBUG_OUT("Running competitor " << competitor->name << " (Sparse matrices represented as COO)" << std::endl);

COO<T> P_coo(this->getDataset().getS_COO());
P_coo.clearValues();

ns = timing([&] { // TODO: Cold/Warm Cache? CPU Calibration?
competitor->run_coo(this->getDataset().getA(), this->getDataset().getB(), this->getDataset().getS_COO(), P_coo);
});

// Checking correctness if available
if (competitor->coo_supported() && this->getDataset().hasExpected()) {
coo_correcntess = (P_coo == this->getDataset().getExpected_COO());
if (coo_correcntess) { DEBUG_OUT(" - Calculated correct results." << std::endl); }
else { DEBUG_OUT(" - !!! Wrong results calculated compared to CPU-Basic (CSR) !!!" << std::endl); }
}
DEBUG_OUT(" - Execution took " << SECOND(ns) << " seconds (" << ns << "ns)" << std::endl << std::endl);
} else {
DEBUG_OUT("Skipping competitor " << competitor->name << " (does not support COO)" << std::endl << std::endl);
}
DEBUG_OUT(" - Execution took " << SECOND(ns) << " seconds (" << ns << "ns)" << std::endl << std::endl);

FILE_DUMP(competitor->name << "," << this->getDataset().getName() << ",COO," << competitor->coo_supported() << "," << this->getDataset().getS_COO().getRows() << "," << this->getDataset().getS_COO().getCols() << "," << this->getDataset().getA().getCols() << "," << ns << "," << coo_correcntess << std::endl);

// TODO: Make size dynamic
Expand Down
4 changes: 2 additions & 2 deletions src/benchmark/dataset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@ namespace SDDMM {
std::stringstream lineStream(line);
std::string cell;

lineStream.ignore(32, ','); // skip the first column (word name)
lineStream.ignore(64, ','); // skip the first column (word name)

while (std::getline(lineStream, cell, ',')) {
if (cell == "0") { col++; continue; }

triplets.push_back({ col, row, (T) std::stod(cell) });
triplets.push_back({ row, col, (T) std::stod(cell) });
i++;

col++;
Expand Down
3 changes: 1 addition & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ void benchmark_email_enron(const std::string& data_folder, const int K) {

struct Config {
std::string data_folder;
// 32 // 128 // 512
int K;
int K; // 32 // 128 // 512
};

static void print_config(Config config) {
Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Quickstart tutorial : http://google.github.io/googletest/quickstart-cmake.html
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(FetchContent)
Expand Down

0 comments on commit b399c5c

Please sign in to comment.