kokkos-kernels icon indicating copy to clipboard operation
kokkos-kernels copied to clipboard

Avoid reserved identifiers

Open dalg24 opened this issue 1 year ago • 4 comments

  • [x] Identifiers starting with two consecutive underscores are reserved in C++ (meaning user-defined program are not allowed to use them) e.g.
    batched/dense/impl/KokkosBatched_Axpy_Impl.hpp:16:#ifndef __KOKKOSBATCHED_AXPY_IMPL_HPP__
    batched/dense/impl/KokkosBatched_Axpy_Impl.hpp:17:#define __KOKKOSBATCHED_AXPY_IMPL_HPP__
    
    or
    batched/dense/impl/KokkosBatched_HostLevel_Gemm_Armpl_Impl.hpp:74:  HandleType *const __handle;
    batched/dense/impl/KokkosBatched_HostLevel_Gemm_Armpl_Impl.hpp:80:  AViewType __A;
    batched/dense/impl/KokkosBatched_HostLevel_Gemm_Armpl_Impl.hpp:81:  avt *__Adp = nullptr;
    batched/dense/impl/KokkosBatched_HostLevel_Gemm_Armpl_Impl.hpp:82:  armpl_int_t __Ajstrd, __Aistrd, __Abstrd;
    batched/dense/impl/KokkosBatched_HostLevel_Gemm_Armpl_Impl.hpp:84:  BViewType __B;
    
  • [ ] Identifiers starting with an underscore followed by an uppercase letter are reserved in C++ For example
    batched/dense/impl/KokkosBatched_HostLevel_Gemm_Serial_Impl.hpp:131:  BatchedSerialGemm(ScalarType _alpha, AViewType _A, BViewType _B, ScalarType _beta, CViewType _C)
    batched/dense/impl/KokkosBatched_HostLevel_Gemm_Serial_Impl.hpp:132:      : A(_A), B(_B), C(_C), alpha(_alpha), beta(_beta) {}
    
  • [x] Avoid defining macros starting with KOKKOS_ (this includes header guards)
    blas/impl/KokkosBlas_util.hpp:18:#define KOKKOS_BLAS_UTIL_HPP
    blas/tpls/KokkosBlas_tpl_spec.hpp:89:#define KOKKOS_CUBLAS_SAFE_CALL_IMPL(call) KokkosBlas::Impl::cublas_internal_safe_call(call, #call, __FILE__, __LINE__)
    
    instead consider doing KOKKOSBLAS_ or KOKKOSKERNELS_BLAS, etc.

dalg24 avatar Oct 07 '24 21:10 dalg24

Most KOKKOS_ macros are either include guards or Impl and we can search/replace, except this one: https://github.com/kokkos/kokkos-kernels/issues/2371

cwpearson avatar Oct 10 '24 15:10 cwpearson

The issue has only been partially addressed: they are still Identifiers starting with an underscore followed by an uppercase letter (2nd item on the list)

Is that an oversight or something that you deliberately consider a "won't fix"?

dalg24 avatar Jan 09 '25 21:01 dalg24

Oversight, I thought we had that resolved with the round of PRs that @cwpearson made recently. We can reopen

lucbv avatar Jan 09 '25 22:01 lucbv

podman run --rm -it \
  -v ${PWD}:/opt/kokkos-kernels \
  -v ${PWD}/kokkos:/opt/kokkos \
   ghcr.io/cwpearson/clang:16.0.6-cmake3.25.3

cmake -S /opt/kokkos -B build-kokkos \
  -DCMAKE_INSTALL_PREFIX=install-kokkos \
  -DCMAKE_CXX_COMPILER=clang++

cmake --build build-kokkos --parallel $(nproc) --target install

cmake -S /opt/kokkos-kernels -B build \
  -DCMAKE_CXX_COMPILER=clang++ \
  -DCMAKE_CXX_STANDARD=17 \
  -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  -DKokkos_ROOT=install-kokkos \
  -DKokkosKernels_ENABLE_TESTS=ON \
  -DKokkosKernels_ENABLE_BENCHMARKS=ON \
  -DKokkosKernels_ENABLE_PERFTESTS=ON \
  -DKokkosKernels_ENABLE_EXAMPLES=ON \
  -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
  -DCMAKE_CXX_CLANG_TIDY="clang-tidy"

cmake --build build --parallel 4

cwpearson avatar Mar 11 '25 18:03 cwpearson

I think this is finally done

cwpearson avatar Aug 12 '25 18:08 cwpearson