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

Move functor-level GEMM routines to KokkosBlas #1519

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

mzuzek
Copy link

@mzuzek mzuzek commented Sep 8, 2022

@lucbv @fnrizzi

This PR moves GEMM

Status:

  • Implementation:
    • move implementations of SerialGemm, TeamGemm and TeamVectorGemm from KokkosBatched to KokkosBlas (BatchedSerialGemm stays in batched);
    • move MKL implementation to dedicated header;
  • Interface:
    • move selective Gemm interface (dispatching between SerialGemm and TeamGemm) from KokkosBatched to KokkosBlas;
  • Tests:
    • move unit tests for functor-level routines;

@fnrizzi
Copy link

fnrizzi commented Sep 8, 2022

just my opnion, but i think it would make sense to keep this PR only about moving things around, and then address the implementation of ConjTranspose and scalar stuff in a separate PR

@kokkos-devops-admin
Copy link

Status Flag 'Pre-Test Inspection' - - This Pull Request Requires Inspection... The code must be inspected by a member of the Team before Testing/Merging
NO INSPECTION HAS BEEN PERFORMED ON THIS PULL REQUEST! - This PR must be inspected by setting label 'AT: PRE-TEST INSPECTED'.

@mzuzek
Copy link
Author

mzuzek commented Sep 8, 2022

@lucbv @fnrizzi

Here are functor-level routines in their respective header files and namespaces - please let me know if you wish any adjustments in naming of file structure:

src

edit 2022-09-26: moved impl to top header, #1504 file structure changes, added MKL, added implementations to chart (blue boxes)


#include "KokkosBlas3_serial_gemm_inner_fixa_impl.hpp"
// TODO: fix compilation errors InnerGemmFixB (not used internally, not tested)
// #include "KokkosBlas3_serial_gemm_inner_fixb_impl.hpp"
Copy link
Author

Choose a reason for hiding this comment

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

Compiler errors in this header were not detected before, because it was not used anywhere (no internal need for InnerGemmFixB and no tests for it).

Copy link
Contributor

Choose a reason for hiding this comment

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

okay

///
template <typename ArgTransA, typename ArgTransB, typename ArgMode,
typename ArgAlgo = Algo::Gemm::Default>
struct Gemm {
Copy link
Author

Choose a reason for hiding this comment

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

@lucbv Should this interface be placed in KokkosBlas::Experimental namespace ? (it wasn't in KokkosBatched)

Copy link
Contributor

Choose a reason for hiding this comment

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

No need for experimental namespace here

@mzuzek mzuzek marked this pull request as ready for review September 9, 2022 15:34
@mzuzek
Copy link
Author

mzuzek commented Sep 9, 2022

@lucbv @fnrizzi
I reviewed the headers and interfaces trying to apply what we've discussed, so let me open the PR for reviews.

For the following tasks, I'll create follow-up PRs:

  • implement ConjTranspose (follow-up: cover in tests);
  • implement mixed input scalar types (value types in A, B and C matrices);
  • extend unit tests to cover Algo::Gemm::CompactMKL (MKL implementation that works on SIMD vectors);

@kokkos-devops-admin
Copy link

Status Flag 'Pre-Test Inspection' - - This Pull Request Requires Inspection... The code must be inspected by a member of the Team before Testing/Merging
NO INSPECTION HAS BEEN PERFORMED ON THIS PULL REQUEST! - This PR must be inspected by setting label 'AT: PRE-TEST INSPECTED'.

@kokkos-devops-admin
Copy link

Status Flag 'Pre-Test Inspection' - - This Pull Request Requires Inspection... The code must be inspected by a member of the Team before Testing/Merging
NO INSPECTION HAS BEEN PERFORMED ON THIS PULL REQUEST! - This PR must be inspected by setting label 'AT: PRE-TEST INSPECTED'.

@kokkos-devops-admin
Copy link

Status Flag 'Pre-Test Inspection' - - This Pull Request Requires Inspection... The code must be inspected by a member of the Team before Testing/Merging
NO INSPECTION HAS BEEN PERFORMED ON THIS PULL REQUEST! - This PR must be inspected by setting label 'AT: PRE-TEST INSPECTED'.

@kokkos-devops-admin
Copy link

Status Flag 'Pre-Test Inspection' - - This Pull Request Requires Inspection... The code must be inspected by a member of the Team before Testing/Merging
NO INSPECTION HAS BEEN PERFORMED ON THIS PULL REQUEST! - This PR must be inspected by setting label 'AT: PRE-TEST INSPECTED'.

Copy link
Contributor

@lucbv lucbv left a comment

Choose a reason for hiding this comment

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

You are defining a macro for COMPACT_MKL multiple times but it should really be centralized instead.

src/batched/dense/KokkosBatched_Gemm_Decl.hpp Outdated Show resolved Hide resolved
src/batched/dense/KokkosBatched_Gemm_Decl.hpp Outdated Show resolved Hide resolved
src/batched/dense/KokkosBatched_Gemm_Decl.hpp Outdated Show resolved Hide resolved
///
template <typename ArgTransA, typename ArgTransB, typename ArgMode,
typename ArgAlgo = Algo::Gemm::Default>
struct Gemm {
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for experimental namespace here


#include "KokkosBlas3_serial_gemm_inner_fixa_impl.hpp"
// TODO: fix compilation errors InnerGemmFixB (not used internally, not tested)
// #include "KokkosBlas3_serial_gemm_inner_fixb_impl.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

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

okay

@mzuzek
Copy link
Author

mzuzek commented Sep 22, 2022

@lucbv

You are defining a macro for COMPACT_MKL multiple times but it should really be centralized instead.

Thank you for pointing this out. On 34c50ea I've created common/impl/KokkosKernels_MKLUtils.hpp for common MKL utils used in blas and sparse (also fixed common/src/impl header path in CMake) and moved the duplicated macro there (also #inlcude <mkl.h> and KOKKOSKERNELS_MKL_SAFE_CALL). Let me know in case you'd wish a different location, name or content.

@mzuzek
Copy link
Author

mzuzek commented Sep 27, 2022

Added one trivial fix on 53c58bc and rebased on develop.

@kokkos-devops-admin
Copy link

Status Flag 'Pre-Test Inspection' - - This Pull Request Requires Inspection... The code must be inspected by a member of the Team before Testing/Merging
NO INSPECTION HAS BEEN PERFORMED ON THIS PULL REQUEST! - This PR must be inspected by setting label 'AT: PRE-TEST INSPECTED'.

@kokkos-devops-admin
Copy link

Status Flag 'Pre-Test Inspection' - - This Pull Request Requires Inspection... The code must be inspected by a member of the Team before Testing/Merging
NO INSPECTION HAS BEEN PERFORMED ON THIS PULL REQUEST! - This PR must be inspected by setting label 'AT: PRE-TEST INSPECTED'.

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

Successfully merging this pull request may close these issues.

4 participants