Skip to content
This repository has been archived by the owner on Oct 19, 2020. It is now read-only.

Commit

Permalink
Closer to actually applying matrices.
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Jul 30, 2009
1 parent a627a1e commit 6afce29
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 65 deletions.
5 changes: 1 addition & 4 deletions CMake/FindMETIS.cmake
Expand Up @@ -30,8 +30,7 @@ FIND_LIBRARY(METIS_LIBRARY metis
/usr/lib
)

MESSAGE("${METIS_INCLUDE_DIR} yo")
MESSAGE("${METIS_LIBRARY} yo")
MARK_AS_ADVANCED(METIS_INCLUDE_DIR METIS_LIBRARY)

IF(METIS_INCLUDE_DIR AND METIS_LIBRARY)
SET( METIS_FOUND "YES" )
Expand All @@ -40,5 +39,3 @@ ELSE()
MESSAGE(FATAL_ERROR "METIS not found")
ENDIF()
ENDIF()

MARK_AS_ADVANCED(METIS_INCLUDE_DIR METIS_LIBRARY)
2 changes: 2 additions & 0 deletions CMakeLists.txt
Expand Up @@ -7,6 +7,8 @@ set(CMAKE_MODULE_PATH

project(iterative_cuda)

set(CUDA_ARCH "compute_13" CACHE STRING "Target CUDA architecture")

find_package(CUDA QUIET REQUIRED)
find_package(METIS REQUIRED)

Expand Down
13 changes: 4 additions & 9 deletions include/iterative-cuda.hpp
Expand Up @@ -64,6 +64,7 @@ namespace iterative_cuda
void to_cpu(value_type *cpu);

value_type *ptr();
const value_type *ptr() const;
};


Expand Down Expand Up @@ -100,16 +101,10 @@ namespace iterative_cuda
index_type row_count() const;
index_type column_count() const;

void permute(
vector_type const &dest,
vector_type const &src) const;
void unpermute(
vector_type const &dest,
vector_type const &src) const;
void permute(vector_type &dest, vector_type const &src) const;
void unpermute(vector_type &dest, vector_type const &src) const;

void operator()(
vector_type const &dest,
vector_type const &src) const;
void operator()(vector_type &dest, vector_type const &src) const;
};


Expand Down
3 changes: 1 addition & 2 deletions src/CMakeLists.txt
@@ -1,11 +1,10 @@
set(BUILD_SHARED_LIBS ON)

include_directories(${METIS_INCLUDE_DIR})
message("${METIS_LIBRARY} bitches")

cuda_add_library(iterativecuda
host_instantiation.cpp
instantiation.cu
OPTIONS "-arch=${CUDA_ARCH}"
)

target_link_libraries(iterativecuda ${METIS_LIBRARY})
Expand Down
31 changes: 20 additions & 11 deletions src/gpu-sparse-matrix.hpp
Expand Up @@ -35,6 +35,7 @@ SOFTWARE.
#include "helpers.hpp"
#include "spmv/partition.h"
#include "spmv/csr_to_pkt.h"
#include "spmv/utils.h"



Expand Down Expand Up @@ -69,7 +70,7 @@ namespace iterative_cuda
csr_mat.Aj = const_cast<index_type *>(csr_column_indices);
csr_mat.Ax = const_cast<value_type *>(csr_nonzeros);

index_type rows_per_packet =
index_type rows_per_packet =
(SHARED_MEM_BYTES - 100)
/ (2*sizeof(value_type));

Expand All @@ -78,7 +79,10 @@ namespace iterative_cuda
std::vector<index_type> partition;
partition_csr(csr_mat, block_count, partition, /*Kway*/ true);

pimpl->matrix = csr_to_pkt(csr_mat, partition.data());
pkt_matrix<index_type, value_type> host_matrix =
csr_to_pkt(csr_mat, partition.data());

pimpl->matrix = copy_matrix_to_device(host_matrix);
}


Expand All @@ -87,44 +91,49 @@ namespace iterative_cuda
template <typename VT, typename IT>
gpu_sparse_pkt_matrix<VT, IT>::~gpu_sparse_pkt_matrix()
{
delete_pkt_matrix(pimpl->matrix);
delete_pkt_matrix(pimpl->matrix, DEVICE_MEMORY);
}




template <typename VT, typename IT>
gpu_sparse_pkt_matrix<VT, IT>::index_type
gpu_sparse_pkt_matrix<VT, IT>::row_count() const
{
IT gpu_sparse_pkt_matrix<VT, IT>::row_count() const
{
return pimpl->matrix.num_rows;
}




template <typename VT, typename IT>
gpu_sparse_pkt_matrix<VT, IT>::index_type
gpu_sparse_pkt_matrix<VT, IT>::column_count() const
{
IT gpu_sparse_pkt_matrix<VT, IT>::column_count() const
{
return pimpl->matrix.num_cols;
}




template <typename VT, typename IT>
void gpu_sparse_pkt_matrix<VT, IT>::permute(
vector_type const &dest,
vector_type &dest,
vector_type const &src) const
{
gather_device(dest.ptr(), src.ptr(),
pimpl->matrix.permute_old_to_new, row_count());
}




template <typename VT, typename IT>
void gpu_sparse_pkt_matrix<VT, IT>::unpermute(
vector_type const &dest,
vector_type &dest,
vector_type const &src) const
{
gather_device(dest.ptr(), src.ptr(),
pimpl->matrix.permute_new_to_old, row_count());
}
}

Expand Down
39 changes: 0 additions & 39 deletions src/host_instantiation.cpp

This file was deleted.

10 changes: 10 additions & 0 deletions src/instantiation.cu
Expand Up @@ -26,8 +26,18 @@ SOFTWARE.


#include <iterative-cuda.hpp>
#include "gpu-vector.hpp"
#include "gpu-sparse-matrix.hpp"




using namespace iterative_cuda;




template class gpu_vector<float>;
template class gpu_vector<double>;
template class gpu_sparse_pkt_matrix<float>;
template class gpu_sparse_pkt_matrix<double>;

0 comments on commit 6afce29

Please sign in to comment.