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

Can I run KokkosKernels spgemm with float or int32 type? #583

Closed
Lilian92 opened this issue Jan 28, 2020 · 14 comments
Closed

Can I run KokkosKernels spgemm with float or int32 type? #583

Lilian92 opened this issue Jan 28, 2020 · 14 comments

Comments

@Lilian92
Copy link

I am running under ./example/buildlib/perf_test.

@srajama1
Copy link
Contributor

@Lilian92 Can you give me some more details ? What is the build script you used ? The code is fully templated, so yes float is supported. All the ids are ints typically. Are you trying to multiply where the matrix entries themselves are ints ?

@Lilian92
Copy link
Author

I am sorry for the lack of details in the question.

Myself:
I am a PhD. student at Gatech working with Prof. Ümit V. Çatalyürek.

What is the build script you used ?
./example/buildlib/compileKokkosKernelsSimple.sh

The code is fully templated, so yes float is supported. All the ids are ints typically. Are you trying to multiply where the matrix entries themselves are ints ?
Yes, I am trying to multiply with matrix having entries/value as int32 or float type.

I have tried to change:

KOKKOSKERNELS_SCALARS=double #the scalar types to instantiate =double,float...

To:
KOKKOSKERNELS_SCALARS=int

Then change:

#if defined(KOKKOSKERNELS_INST_DOUBLE) && \

To:
#if defined(KOKKOSKERNELS_INST_INT) && \


To:
#define SCALAR_TYPE int

#if !defined(KOKKOSKERNELS_INST_DOUBLE)

To:
#if !defined(KOKKOSKERNELS_INST_INT)

But during running, I will get error from:

std::cout << " not defined KOKKOSKERNELS_INST_DOUBLE" << std::endl;

@srajama1
Copy link
Contributor

@Lilian92 Thanks for the context.

This is technically a problem with that test file which assumes double. The actual source code does not have the assumption. Can you try SCALAR to be float first ? I will see what is needed for scalar to be int.

@Lilian92
Copy link
Author

Thank you so much for your fast reply!

I have tried with float. With float, it won't pass the compiling for spgemm.

@Lilian92
Copy link
Author

Thanks for checking things out!

@srajama1
Copy link
Contributor

Can you cut and paste the error ?

I will check.

@Lilian92
Copy link
Author

Below is the log from '"make build-test -j". Thanks!

https://www.dropbox.com/s/hx1c3izhj4wh4bd/log?dl=0

@srajama1
Copy link
Contributor

srajama1 commented Feb 7, 2020

@brian-kelley As you are deep into SpGEMM, this might be a good test.

@brian-kelley
Copy link
Contributor

@srajama1 I had a branch from December where I was cleaning up the sparse perf tests, and using sensible scalar, ordinal, size_t, layout types based on what is ETI'd. So I'll finish that up and make sure scalar=float works everywhere.

@Lilian92 If we get float to work, would you still want to try scalar=int? It won't be supported by the build system, but by including the right headers and plugging int into the template parameters it should be possible.

@brian-kelley
Copy link
Contributor

@Lilian92 I'm sorry this took so long, it turns out we had several issues with building the performance tests with scalar_t = float (as you saw). But I have a branch that can build the SPGEMM driver with scalar_t = float, and there's also a very easy way (1-line change) to get scalar_t=int.

For now, these instructions will involve checking out my branch, but within a few days this should be in the main develop branch.

Instructions for float:

# get my branch of kokkos-kernels
git clone https://www.github.com/brian-kelley/kokkos-kernels
cd kokkos-kernels
git checkout SparsePerfCleanup
cd ..
# build 
mkdir build
cd build
# use main Kokkos repository (develop branch)
# yes, kokkos goes in the build/ directory
git clone https://www.github.com/kokkos/kokkos
cd kokkos
git checkout develop
cd ..
# configure a basic build (serial only) using float
# run the script with --help to see the options (you'll probably want to run with CUDA or OpenMP)
../kokkos-kernels/cm_generate_makefile.bash --release --with-scalars=float
# build (where $N is the number of CPU cores)
make -j $N
# and then perf_test/sparse/test_spgemm will be using floats and should work

Instructions for int:

git clone https://www.github.com/brian-kelley/kokkos-kernels
cd kokkos-kernels
git checkout SparsePerfCleanup
# need to change one line to get scalar=int
cd perf_test/sparse
### using any editor, change line 51 of KokkosSparse_spgemm.cpp to "typedef int scalar_t;"
cd ../../..
mkdir build
cd build
git clone https://www.github.com/kokkos/kokkos
cd kokkos
git checkout develop
cd ..
# configure a basic build (serial only), the scalars option doesn't matter since it's changed for the SPGEMM perf_test
# run the script with --help to see the options
../kokkos-kernels/cm_generate_makefile.bash --release
# build (where $N is the number of CPU cores)
make -j $N
# and then perf_test/sparse/test_spgemm will be using ints and should work

Note that for the int version, you'll have to have integer-formatted MatrixMarket input files. The header should look like this (maybe 'general' is different, but 'integer' should be there).

%%MatrixMarket matrix coordinate integer general

@brian-kelley
Copy link
Contributor

@Lilian92 Apologies, I just realized that even if you compile with --scalars=float, double is still instantiated so it is used as the default. We'll figure out a permanent solution that lets users select the types at runtime somehow, but until then just follow the instructions for int but use "typedef float scalar_t;" instead.

@Lilian92
Copy link
Author

Cool, thank you so much!

@srajama1
Copy link
Contributor

srajama1 commented Mar 2, 2020

@Lilian92 Are you able to successfully run this case ?

@Lilian92
Copy link
Author

Lilian92 commented Mar 2, 2020 via email

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

No branches or pull requests

5 participants