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

Integrate Modified AC-SpGEMM / GALATIC #26

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "ext/moderngpu"]
path = ext/moderngpu
url = https://ctcyang@github.com/ctcyang/moderngpu.git
url = git@github.com:ctcyang/moderngpu.git
Copy link
Collaborator

@ctcyang ctcyang Jun 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Kind of a personal preference thing, but could you change these to use HTTPS verification rather than SSH? I usually don't have ssh-key installed, so I typically use HTTPS.

I've tried with HTTPS and for people with access to GALATIC private repo, then so long as that they enter my Github login + pw, it lets them pull in the submodule.

[submodule "ext/GALATIC"]
path = ext/GALATIC
url = git@github.com:richardlett/GALATIC.git
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ set( PROJ_PATH ${CMAKE_SOURCE_DIR})
set( PROJ_OUT_PATH ${CMAKE_BINARY_DIR})
set( PROJ_HEADERS "" )
set( PROJ_LIBRARIES "" )
set( PROJ_INCLUDES "./" "ext/moderngpu/include")
set( PROJ_INCLUDES "./" "ext/moderngpu/include" "ext")
set( mgpu_SRC_FILES "ext/moderngpu/src/mgpucontext.cu" "ext/moderngpu/src/mgpuutil.cpp")
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin )
#set( CUDA_CURAND_LIBRARY "$ENV{CUDA_HOME}/lib64/libcurand.so" )
#set( CUDA_CUBLAS_LIBRARY "$ENV{CUDA_HOME}/lib64/libcublas.so" )
set( CUDA_CUSPARSE_LIBRARY "$ENV{CUDA_HOME}/lib64/libcusparse.so" )
#FILE( GLOB_RECURSE PROJ_SOURCES graphblas/*.cu ../graphblas/*.cpp )
#FILE( G LOB_RECURSE PROJ_SOURCES graphblas/*.cu ../graphblas/*.cpp )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra tab here

#FILE( GLOB_RECURSE PROJ_LIBRARIES ext/cublas1.1/*.cu )
FILE( GLOB_RECURSE PROJ_HEADERS graphblas/*.hpp)
# nvcc flags
Expand Down
2 changes: 1 addition & 1 deletion ext/GALATIC
2 changes: 1 addition & 1 deletion graphblas/backend/cuda/operations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Info mxm(Matrix<c>* C,
&B->sparse_, desc));
else {
if (s_mode != GrB_GALATIC) {
std::cout << R"(Unknown mode (Options are: "cusspare2" and "galatic"; defaulting to galatic)" << std::endl;
std::cout << R"(Unknown mode (Options are: "cuspare2" and "galatic"; defaulting to galatic)" << std::endl;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: cusparse2

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦 wow

}
CHECK(GALATIC_spgemm(&C->sparse_,
op,
Expand Down
19 changes: 1 addition & 18 deletions graphblas/backend/cuda/spgemm.hpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
#ifndef GRAPHBLAS_BACKEND_CUDA_SPGEMM_HPP_
#define GRAPHBLAS_BACKEND_CUDA_SPGEMM_HPP_


#include "../../../ext/GALATIC/include/dCSR.cuh"
#include "../../../ext/GALATIC/include/SemiRingInterface.h"
#include "../../../ext/GALATIC/source/device/Multiply.cuh"
#include <GALATIC/GALATICMinimumIncludes.cuh>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind changing this to #include "GALATICMinimumIncludes.cuh"? According to the Google C++ style guide, typically nonsystem headers use the quotation marks instead of angled brackets.

That way, the PROJ_INCLUDES can be set( PROJ_INCLUDES "./" "ext/moderngpu/include" "ext/GALATIC"), so it's easier for someone trying to install graphblast to debug for example when PROJ_INCLUDES can't find the GALATIC folder.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, bad inference made me think that was for files that were resolved based on relative path to current file -I!


#include "graphblas/backend/cuda/sparse_matrix.hpp"


#include <cuda.h>
#include <cusparse.h>

#include <iostream>
#include <vector>





namespace graphblas {
namespace backend {
template <typename T>
Expand Down Expand Up @@ -218,11 +210,8 @@ Info GALATIC_spgemm(SparseMatrix<c>* C,
matrixToGalatic(A, leftInputMatrixGPU);
matrixToGalatic(B, rightInputMatrixGPU);



GPUMatrixMatrixMultiplyTraits DefaultTraits;


// GALATIC has its own semiring interface;
// GalaticSemiring is a shim here for conversion of graphblast-style
// SemiringT type. GalaticSemiring definition is above this function
Expand All @@ -231,8 +220,6 @@ Info GALATIC_spgemm(SparseMatrix<c>* C,

ExecutionStats stats;
try {


Desc_value nt_mode;
CHECK(desc->get(GrB_NT, &nt_mode));
const int num_threads = static_cast<int>(nt_mode);
Expand Down Expand Up @@ -288,22 +275,18 @@ Info GALATIC_spgemm(SparseMatrix<c>* C,
nullizeGalaticMatrix(leftInputMatrixGPU);
nullizeGalaticMatrix(rightInputMatrixGPU);


if (C->h_csrRowPtr_ == NULL)
C->h_csrRowPtr_ = reinterpret_cast<Index*>(malloc((A_nrows+1)*
sizeof(Index)));
C->h_csrColInd_ = reinterpret_cast<Index*>(malloc(C->ncapacity_*sizeof(Index)));
C->h_csrVal_ = reinterpret_cast<c*>(malloc(C->ncapacity_*sizeof(c)));


C->need_update_ = true; // Set flag that we need to copy data from GPU
C->csr_initialized_ = true;
C->csc_initialized_ = false;
return GrB_SUCCESS;
}



template <typename c, typename a, typename b, typename m,
typename BinaryOpT, typename SemiringT>
Info cusparse_spgemm(SparseMatrix<c>* C,
Expand Down