Skip to content

Commit

Permalink
Add MatrixMarketDataset
Browse files Browse the repository at this point in the history
  • Loading branch information
francois141 committed Oct 26, 2023
1 parent 1600ca8 commit d0b5ab3
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
50 changes: 50 additions & 0 deletions src/benchmark/dataset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,56 @@ namespace SDDMM {
}

};

template<typename T>
class MatrixMarketDataset : public Dataset<T> {
private:
const std::string file_name = "1138_bus.tar";

public:

MatrixMarketDataset(const std::string& data_folder, const int K)
: Dataset<T>("MatrixMarket"), K(K)
{
this->generateDense(M, N, K);

std::vector<Triplet<T>> triplets;

std::string dataset_path(data_folder);
dataset_path.append(file_name);

std::fstream data_file;
data_file.open(dataset_path, std::ios::in);

assert(data_file.is_open()); // failed to open file

std::string line;
while (std::getline(data_file, line)) {
if(line[0] == '%') {
continue;
}

std::stringstream lineStream(line);

int x,y;
float value;

lineStream >> x >> y >> value;
triplets.push_back({x,y, value});
}
data_file.close();

this->S_csr = CSR<T>(M, N, triplets);
this->S_coo = COO<T>(M, N, triplets);

DEBUG_OUT("=== [" << this->getName() << "] Loaded " << triplets.size() << " sparse values from file ===\n" << std::endl);
}

private:
const int M = 11463;
const int N = 5811;
const int K;
};

template<typename T>
class NIPSDataset : public Dataset<T> {
Expand Down
5 changes: 3 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ int main(int argc, char* argv[]) {
FILE_DUMP("competitor,dataset,mat_repr,M,N,K,exec_time,correctness" << std::endl);
}

// DEBUG_OUT("\n=====================================================\n" << std::endl);
// benchmark_dummy();

DEBUG_OUT("\n=====================================================\n" << std::endl);
benchmark_dummy();

DEBUG_OUT("\n=====================================================\n" << std::endl);

Expand Down

0 comments on commit d0b5ab3

Please sign in to comment.