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

Add custom sparse matrix format #6

Open
IsolatedMy opened this issue Oct 9, 2023 · 3 comments
Open

Add custom sparse matrix format #6

IsolatedMy opened this issue Oct 9, 2023 · 3 comments

Comments

@IsolatedMy
Copy link

Hi. I am interested in adding custom sparse matrix format. Is there a tutorial on adding new formats to help me get started quickly?

BTW, when I ran make in the examples/ folder, I got the following error. I wondered if my inappropriate c++ version led to these errors.

g++ -std=c++20 -O3 -I../include -o mdspan_example mdspan_example.cpp 
mdspan_example.cpp: In function ‘int main(int, char**)’:
mdspan_example.cpp:13:8: error: ‘std::experimental’ has not been declared
   13 |   std::experimental::mdspan b_span(data.data(), b.shape()[0], b.shape()[1]);
      |        ^~~~~~~~~~~~
mdspan_example.cpp:15:31: error: ‘b_span’ was not declared in this scope
   15 |   auto view = grb::views::all(b_span);
      |                               ^~~~~~
mdspan_example.cpp:27:19: error: ‘grb::matrix<float, int>::backend_type grb::matrix<float, int>::backend_’ is private within this context
   27 |   auto values = a.backend_.values_.data();
      |                   ^~~~~~~~
In file included from ../include/grb/util/printing.hpp:6,
                 from ../include/grb/util/util.hpp:5,
                 from ../include/grb/grb.hpp:4,
                 from mdspan_example.cpp:1:
../include/grb/containers/matrix.hpp:171:16: note: declared private here
  171 |   backend_type backend_;
      |                ^~~~~~~~
mdspan_example.cpp:27:28: error: ‘grb::csr_matrix<float, int, std::allocator<float> >::vector_type<float, std::allocator<float> > grb::csr_matrix<float, int, std::allocator<float> >::values_’ is private within this context
   27 |   auto values = a.backend_.values_.data();
      |                            ^~~~~~~
In file included from ../include/grb/containers/matrix.hpp:4:
../include/grb/containers/backend/csr_matrix.hpp:180:34: note: declared private here
  180 |   vector_type<T, allocator_type> values_ = vector_type<T, allocator_type>(allocator_);
      |                                  ^~~~~~~
mdspan_example.cpp:28:19: error: ‘grb::matrix<float, int>::backend_type grb::matrix<float, int>::backend_’ is private within this context
   28 |   auto rowptr = a.backend_.rowptr_.data();
      |                   ^~~~~~~~
../include/grb/containers/matrix.hpp:171:16: note: declared private here
  171 |   backend_type backend_;
      |                ^~~~~~~~
mdspan_example.cpp:28:28: error: ‘grb::csr_matrix<float, int, std::allocator<float> >::vector_type<int, std::allocator<int> > grb::csr_matrix<float, int, std::allocator<float> >::rowptr_’ is private within this context
   28 |   auto rowptr = a.backend_.rowptr_.data();
      |                            ^~~~~~~
../include/grb/containers/backend/csr_matrix.hpp:178:49: note: declared private here
  178 |   vector_type<index_type, index_allocator_type> rowptr_ = vector_type<index_type, index_allocator_type>({0}, allocator_);
      |                                                 ^~~~~~~
mdspan_example.cpp:29:19: error: ‘grb::matrix<float, int>::backend_type grb::matrix<float, int>::backend_’ is private within this context
   29 |   auto colind = a.backend_.colind_.data();
      |                   ^~~~~~~~
../include/grb/containers/matrix.hpp:171:16: note: declared private here
  171 |   backend_type backend_;
      |                ^~~~~~~~
mdspan_example.cpp:29:28: error: ‘grb::csr_matrix<float, int, std::allocator<float> >::vector_type<int, std::allocator<int> > grb::csr_matrix<float, int, std::allocator<float> >::colind_’ is private within this context
   29 |   auto colind = a.backend_.colind_.data();
      |                            ^~~~~~~
../include/grb/containers/backend/csr_matrix.hpp:179:49: note: declared private here
  179 |   vector_type<index_type, index_allocator_type> colind_ = vector_type<index_type, index_allocator_type>(allocator_);
      |                                                 ^~~~~~~
make: *** [Makefile:14: mdspan_example] Error 1

My c++ version are as follows

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/12/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 12.3.0-1ubuntu1~23.04' --with-bugurl=file:///usr/share/doc/gcc-12/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-12 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-12-DAPbBt/gcc-12-12.3.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-12-DAPbBt/gcc-12-12.3.0/debian/tmp-gcn/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.3.0 (Ubuntu 12.3.0-1ubuntu1~23.04)

Thank you in advance!

@BenBrock
Copy link
Collaborator

BenBrock commented Oct 9, 2023

The mdspan_example in particular expects mdspan. The other examples will likely compile just fine without it, but that one will require mdspan. One option is to install it from here, or you could just try compiling other specific examples (e.g. make basic_ewise).

@BenBrock
Copy link
Collaborator

BenBrock commented Oct 9, 2023

As for implementing a custom sparse matrix format, what did you have in mind?

@IsolatedMy
Copy link
Author

Thanks for your reply. I was trying to implement sparse matrix format considering hardware features like CISR format in https://arxiv.org/pdf/1810.07517.pdf.

I have found that the underlying sparse matrix format of class grb::matrix cannot be directly changed by user input. It seems I need to change the format used in pick_backend_type.

template <>
struct pick_backend_type<sparse> {
	template <typename... Args>
	using type = grb::csr_matrix<Args...>;
};

As for new format, I think I need to create corresponding file in the containers/backend and create its iterator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants