Skip to content

Commit

Permalink
rename define __CUDA to __NCLGLIB_CUDA
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpintarelli committed Jan 19, 2021
1 parent 313a43d commit fcfd605
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion cmake/nlcglib_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ MACRO(NLCGLIB_SETUP_TARGET _target)
target_link_libraries(${_target} PRIVATE my_lapack)
endif()
target_compile_definitions(${_target} PUBLIC $<$<BOOL:${USE_OPENMP}>:__USE_OPENMP>)
target_compile_definitions(${_target} PUBLIC $<$<BOOL:${USE_CUDA}>:__CUDA>)
target_compile_definitions(${_target} PUBLIC $<$<BOOL:${USE_CUDA}>:__NLCGLIB__CUDA>)
ENDMACRO()
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ target_link_libraries(nlcglib_internal INTERFACE my_lapack)
target_include_directories(nlcglib_internal PUBLIC ${CMAKE_SOURCE_DIR}/src)
target_include_directories(nlcglib_internal PUBLIC ${CMAKE_SOURCE_DIR}/include)
target_include_directories(nlcglib_internal PUBLIC ${CUDA_INCLUDE_DIRS})
target_compile_definitions(nlcglib_internal PUBLIC $<$<BOOL:${USE_CUDA}>:__CUDA>)
target_compile_definitions(nlcglib_internal PUBLIC $<$<BOOL:${USE_CUDA}>:__NLCGLIB__CUDA>)
set(nlcglib_internal_location $<TARGET_FILE:nlcglib_internal>)


Expand All @@ -18,7 +18,7 @@ target_include_directories(nlcglib
nlcglib_setup_target(nlcglib)
set_target_properties(nlcglib PROPERTIES
PUBLIC_HEADER ${CMAKE_SOURCE_DIR}/include/nlcglib.hpp)
target_compile_definitions(nlcglib PUBLIC $<$<BOOL:${USE_CUDA}>:__CUDA>)
target_compile_definitions(nlcglib PUBLIC $<$<BOOL:${USE_CUDA}>:__NLCGLIB__CUDA>)

include(GNUInstallDirs)

Expand Down
2 changes: 1 addition & 1 deletion src/exec_space.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct exec
{
};

#ifdef __CUDA
#ifdef __NLCGLIB__CUDA
template <>
struct exec<Kokkos::CudaSpace>
{
Expand Down
2 changes: 1 addition & 1 deletion src/gpu/acc.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifdef __CUDA
#ifdef __NLCGLIB__CUDA
#include <Kokkos_Complex.hpp>
#include <cassert>
#include <complex>
Expand Down
2 changes: 1 addition & 1 deletion src/la/cusolver.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifdef __CUDA
#ifdef __NLCGLIB__CUDA
#include "cusolver.hpp"
#include <iostream>

Expand Down
8 changes: 4 additions & 4 deletions src/la/lapack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <utility>
#include <la/map.hpp>
#include "lapack_cpu.hpp"
#ifdef __CUDA
#ifdef __NLCGLIB__CUDA
#include "lapack_cuda.hpp"
#endif
#include "mvector.hpp"
Expand Down Expand Up @@ -42,7 +42,7 @@ namespace nlcglib {
// return d;
// }

#ifdef __CUDA
#ifdef __NLCGLIB__CUDA
/// diag (on CUDA-GPU)
template <class T, class LAYOUT, class... KOKKOS>
std::enable_if_t<
Expand Down Expand Up @@ -367,7 +367,7 @@ struct innerh_tr
// return sum;
// }

#ifdef __CUDA
#ifdef __NLCGLIB__CUDA
template <class M1, class M2>
std::enable_if_t<
Kokkos::SpaceAccessibility<Kokkos::Cuda, typename M1::storage_t::memory_space>::accessible,
Expand Down Expand Up @@ -463,7 +463,7 @@ double l2norm(const mvector<X>& x) {
return Kokkos::real(z);
}

#ifdef __CUDA
#ifdef __NLCGLIB__CUDA
template<class memspace>
std::enable_if_t<Kokkos::SpaceAccessibility<Kokkos::Cuda, memspace>::accessible>
loewdin_aux(Kokkos::View<double*, memspace>& w)
Expand Down
6 changes: 3 additions & 3 deletions src/la/mvector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ make_mmatrix(std::shared_ptr<MatrixBaseZ> matrix_base, std::enable_if_t<std::is_
auto buffer = matrix_base->get(i);
auto kindex = matrix_base->kpoint_index(i);
Communicator comm(buffer.mpi_comm);
#ifdef __CUDA
#ifdef __NLCGLIB__CUDA
if (Kokkos::SpaceAccessibility<Kokkos::Cuda, memspace>::accessible) {
// make sure is memory type device
if (buffer.memtype != memory_type::device)
Expand Down Expand Up @@ -433,7 +433,7 @@ make_mmatrix(std::shared_ptr<MatrixBaseZ> matrix_base, std::enable_if_t<!std::is
auto buffer = matrix_base->get(i);
auto kindex = matrix_base->kpoint_index(i);
Communicator comm(buffer.mpi_comm);
#ifdef __CUDA
#ifdef __NLCGLIB__CUDA
if (Kokkos::SpaceAccessibility<Kokkos::Cuda, memspace>::accessible) {
// make sure is memory type device
if (buffer.memtype != memory_type::device)
Expand Down Expand Up @@ -467,7 +467,7 @@ auto make_mmvector(std::shared_ptr<VectorBaseZ> vector_base)
// vector_t vector();
auto buffer = vector_base->get(i);
if (buffer.memtype == memory_type::device) {
#ifdef __CUDA
#ifdef __NLCGLIB__CUDA
Kokkos::View<double*, Kokkos::CudaSpace, Kokkos::MemoryUnmanaged> src(buffer.data, buffer.size[0]);
vector_t dst("vector", buffer.size[0]);
Kokkos::deep_copy(dst, src);
Expand Down
8 changes: 4 additions & 4 deletions src/nlcglib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ nlcg_check_gradient_host(EnergyBase& energy)
void
nlcg_check_gradient_cuda(EnergyBase& energy)
{
#if defined (__CLANG) && defined (__CUDA)
#if defined (__CLANG) && defined (__NLCGLIB__CUDA)
Kokkos::initialize();
nlcg_check_gradient<Kokkos::CudaSpace>(energy);
Kokkos::finalize();
Expand All @@ -342,7 +342,7 @@ nlcg_mvp2_cpu(EnergyBase& energy_base, smearing_type smearing, double temp, doub
nlcg_info
nlcg_mvp2_device(EnergyBase& energy_base, smearing_type smearing, double temp, double tol, double kappa, double tau, int maxiter, int restart)
{
#ifdef __CUDA
#ifdef __NLCGLIB__CUDA
Kokkos::initialize();
auto info = nlcg<Kokkos::CudaSpace>(energy_base, smearing, temp, maxiter, tol, kappa, tau, restart);
Kokkos::finalize();
Expand All @@ -365,7 +365,7 @@ nlcg_mvp2_device_cpu(EnergyBase& energy_base,
int maxiter,
int restart)
{
#ifdef __CUDA
#ifdef __NLCGLIB__CUDA
Kokkos::initialize();
auto info = nlcg<Kokkos::CudaSpace, Kokkos::HostSpace>(energy_base, smearing, temp, maxiter, tol, kappa, tau, restart);
Kokkos::finalize();
Expand All @@ -388,7 +388,7 @@ nlcg_mvp2_cpu_device(EnergyBase& energy_base,
int maxiter,
int restart)
{
#ifdef __CUDA
#ifdef __NLCGLIB__CUDA
Kokkos::initialize();
auto info = nlcg<Kokkos::HostSpace, Kokkos::CudaSpace>(
energy_base, smearing, temp, maxiter, tol, kappa, tau, restart);
Expand Down
4 changes: 2 additions & 2 deletions test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ run_unmanaged()
eigh(H, eigvals, S);
}

#ifdef __CUDA
#ifdef __NLCGLIB__CUDA
void
run_unmanaged_cuda()
{
Expand Down Expand Up @@ -117,7 +117,7 @@ int main(int argc, char *argv[])

run();

#ifdef __CUDA
#ifdef __NLCGLIB__CUDA
run_unmanaged_cuda();
#endif

Expand Down

0 comments on commit fcfd605

Please sign in to comment.