Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

001-missing-niter #1

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.direnv
build
.cache
testing/matrices/*.mtx
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "thirdparty/gtest"]
path = thirdparty/gtest
url = https://github.com/google/googletest.git
46 changes: 46 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
cmake_minimum_required(VERSION 3.1)

###############################################################################
## CXX Setup ##################################################################
###############################################################################

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_COMPILER mpic++) # default, change in subdir if necessary

# to change build type (for checking optimization flags), do:
# cmake -DCMAKE_BUILD_TYPE=Release (acc. to stackoverflow)
# set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native")
set(CMAKE_EXPORT_COMPILE_COMMANDS on)

###############################################################################
## project setup ##############################################################
###############################################################################

project(SpCOMM3D)

###############################################################################
## file globbing ##############################################################
###############################################################################

file(GLOB_RECURSE GLOB_SOURCES src/*.cpp)
include_directories(src) # outdated method but not a big deal I think (Manuel)

###############################################################################
## target definitions #########################################################
###############################################################################

add_subdirectory(miniapp)

###############################################################################
## dependencies ###############################################################
###############################################################################

add_subdirectory(thirdparty)

###############################################################################
## testing ####################################################################
###############################################################################

add_subdirectory(testing)
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
description = "HPC Lab";

inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
};
in
{
formatter.${system} = pkgs.nixpkgs-fmt;

devShell.${system} = pkgs.mkShell rec {
nativeBuildInputs = with pkgs; [
cmake
clang-tools
mpich
];
buildInputs = with pkgs; [
];

CPATH = pkgs.lib.makeSearchPathOutput "dev" "include" buildInputs;
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
};
};
}
15 changes: 15 additions & 0 deletions miniapp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
###############################################################################
## target definitions #########################################################
###############################################################################

add_executable(benchSddmm bench_sddmm.cpp ${GLOB_SOURCES})

add_executable(benchSpMM bench_spmm.cpp ${GLOB_SOURCES})

# add_executable(benchBoth main_combined.cpp ${GLOB_SOURCES})

# add_executable(serialSim serialSim.cpp ${GLOB_SOURCES})

add_executable(numCheckSeq numCheckSeq.cpp ${GLOB_SOURCES})

add_executable(test test.cpp ${GLOB_SOURCES})
5 changes: 3 additions & 2 deletions miniapp/bench_sddmm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void vals_from_str(string str, vector<idx_t>& vals){
}
}

void process_args(int argc, char *argv[], std::vector<idx_t>& fvals, int& c, int& niter, string& filename){
void process_args(int argc, char *argv[], std::vector<idx_t>& fvals, int& c,/*int& niter,*/ string& filename){
int choice;
while (1)
{
Expand Down Expand Up @@ -113,7 +113,8 @@ int main(int argc, char *argv[])
string filename;
int c;
vector<idx_t> fvals;
process_args(argc, argv, fvals, c, filename);
int niter = 10;
process_args(argc, argv, fvals, c, niter, filename);
std::string::size_type const p(filename.find_last_of('.'));
std::string mtxName = filename.substr(0, p);
mtxName = mtxName.substr(mtxName.find_last_of("/\\") +1);
Expand Down
6 changes: 3 additions & 3 deletions miniapp/main_combined.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include <mpi.h>
#include <sys/types.h>
#include <vector>
#include "../src/basic.hpp"
#include "../src/mm.hpp"
#include "../src/comm_stats.hpp"
#include "basic.hpp"
#include "mm.hpp"
#include "comm_stats.hpp"
#include <getopt.h>
#include <chrono>
#include "distribute.hpp"
Expand Down
103 changes: 103 additions & 0 deletions miniapp/test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#include <mpi.h>
#include <array>
#include <vector>
#include <string>
#include "basic.hpp"
#include "SparseMatrix.hpp"
#include "comm.hpp"
#include "comm_stats.hpp"
#include <getopt.h>
#include <chrono>
#include "denseComm.hpp"
#include "distribute.hpp"
#include "distributed_comp.hpp"
#include "parallel_io.hpp"
#include "comm_setup.hpp"

using namespace std;

template <typename T>
void printfvec(vector<T> &vec) {
for (auto &v : vec) {
cout << v << " ";
}
printf("\n");
}

template <typename T>
void printfmap(unordered_map<T, T> &map) {
for (auto &m : map) {
cout << "(" << m.first << "," << m.second << ") ";
}
printf("\n");
}


int main(int argc, char *argv[]) {
MPI_Init(&argc, &argv);
int rank, size;
MPI_Comm comm = MPI_COMM_WORLD, xycomm, zcomm;
MPI_Comm_rank(comm, &rank);
MPI_Comm_size(comm, &size);

string filename;
if (argc == 2) {
filename = argv[1];
} else {
if (rank == 0) {
printf("Usage: %s filename\n", argv[0]);
}
MPI_Finalize();
return 1;
}

std::string::size_type const p(filename.find_last_of('.'));
std::string mtxName = filename.substr(0, p);
mtxName = mtxName.substr(mtxName.find_last_of("/\\") +1);

std::vector<int> rpvec, cpvec;
std::array<int, 3> dims = {0,0,0};
std::array<int,3> zeroArr ={0,0,0};
std::array<int,3> tdims ={0,0,0};
MPI_Dims_create(size, 3, dims.data());

MPI_Comm cartcomm;
MPI_Cart_create(comm, 3, dims.data(), zeroArr.data(), 0, &cartcomm);

int X = dims[0], Y = dims[1], Z = dims[2];

std::array<int, 3> remaindims = {true, true, false};
MPI_Cart_sub(cartcomm, remaindims.data(), &xycomm);

int myxyrank;
MPI_Comm_rank(xycomm, &myxyrank);

remaindims = {false, false, true};
MPI_Cart_sub(cartcomm, remaindims.data(), &zcomm);
cooMat Sloc;
Sloc.mtxName = mtxName;
{
std:: vector<int> rpvec2D, cpvec2D;
/* distribute C */
read_bin_parallel_distribute_coo(filename, Sloc, rpvec2D, cpvec2D,
cartcomm,xycomm, zcomm);
Sloc.localizeIndices();
MPI_Comm_rank(zcomm, &Sloc.zrank);
Sloc.rank = rank;
}

// output the matrix info on rank 0
if (rank == 0) {
printf("Matrix %s: %d x %d, %ld nnz\n", Sloc.mtxName.c_str(), Sloc.gnrows, Sloc.gncols, Sloc.gnnz);
printf("local to global row mapping:\n");
printfvec(Sloc.ltgR);
printf("local to global col mapping:\n");
printfvec(Sloc.ltgC);
printf("global to local row mapping:\n");
printfmap(Sloc.gtlR);
printf("global to local col mapping:\n");
printfmap(Sloc.gtlC);
printf("local matrix:\n");
Sloc.printMatrix();
}
}
Binary file added scripts/1138_bus.bin
Binary file not shown.
Loading