Skip to content

Commit

Permalink
[poisson] Fix configuration
Browse files Browse the repository at this point in the history
- Detect 'cuSparse' from 'CUDAToolkit'
- Remove setting of 'CUDA_ARCHITECTURES'
- Fix compilation with cusparse.
  • Loading branch information
grospelliergilles committed Feb 4, 2024
1 parent c03e22b commit 55f9811
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
17 changes: 8 additions & 9 deletions poisson/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
set (USE_CUSPARSE_ADD OFF)

if (ARCANE_HAS_CUDA)
find_library(CUSPARSE_LIB cusparse HINTS ${CUDA_TOOLKIT_ROOT_DIR}/lib64)
if(CUSPARSE_LIB)
message(STATUS "CUSPARSE found: ${CUSPARSE_LIB}. Arcane installation has CUDA. Enabling features that depends of Cusparse.")
message(STATUS "Arcane has been compiled with cuda. Enabling features that need CUDA.")
if (TARGET CUDA::cusparse)
message(STATUS "cuSPARSE is available. Enabling cusparse assembly")
set(USE_CUSPARSE_ADD ON)
else()
message(STATUS "cuSPARSE is not available")
endif()
endif()

Expand All @@ -32,12 +32,8 @@ target_sources(Poisson PRIVATE
arcane_accelerator_add_to_target(Poisson)

if(USE_CUSPARSE_ADD)
target_link_libraries(Poisson PRIVATE ${CUSPARSE_LIB})
endif()

set_target_properties(Poisson PROPERTIES CUDA_ARCHITECTURES "72")


arcane_generate_axl(Fem)
arcane_add_arcane_libraries_to_target(Poisson)
target_include_directories(Poisson PUBLIC . ${CMAKE_CURRENT_BINARY_DIR})
Expand All @@ -56,7 +52,10 @@ configure_file(${MSH_DIR}/L-shape-3D.msh ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)

target_link_libraries(Poisson PUBLIC FemUtils)

target_compile_definitions(Poisson PRIVATE $<$<BOOL:${USE_CUSPARSE_ADD}>:USE_CUSPARSE_ADD>)
if (USE_CUSPARSE_ADD)
target_compile_definitions(Poisson PRIVATE USE_CUSPARSE_ADD)
target_link_libraries(Poisson PRIVATE CUDA::cusparse)
endif()
target_compile_definitions(Poisson PRIVATE $<$<BOOL:${ARCANE_HAS_ACCELERATOR}>:ARCANE_HAS_ACCELERATOR>)

find_program(GMSH NAMES gmsh)
Expand Down
9 changes: 3 additions & 6 deletions poisson/CusparseBiliAssembly.hxx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
//-----------------------------------------------------------------------------
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
Expand Down Expand Up @@ -227,7 +227,6 @@ _computeCusparseElementMatrix(cusparseCsr& result, cusparseCsr& global, Cell cel
CHECK_CUDA(cudaFree(local.csrCol));
CHECK_CUDA(cudaFree(local.csrRow));
CHECK_CUSPARSE(cusparseDestroyMatDescr(local.desc));

}

/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -293,15 +292,13 @@ _assembleCusparseBilinearOperatorTRIA3()

CHECK_CUDA(cudaFree(res1.csrCol));
CHECK_CUDA(cudaFree(res1.csrVal));
_computeCusparseElementMatrix(res1, res2, cell, handle, node_dof,
t);
_computeCusparseElementMatrix(res1, res2, cell, handle, node_dof);
}
//computation of the local matrix and adding it in the global one
else {
CHECK_CUDA(cudaFree(res2.csrCol));
CHECK_CUDA(cudaFree(res2.csrVal));
_computeCusparseElementMatrix(res2, res1, cell, handle, node_dof,
t);
_computeCusparseElementMatrix(res2, res1, cell, handle, node_dof);
}
i++;
}
Expand Down
3 changes: 1 addition & 2 deletions poisson/FemModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,6 @@ _doStationarySolve()

#ifdef USE_CUSPARSE_ADD
if (m_use_cusparse_add) {
cusparseHandle_t handle;
_assembleCusparseBilinearOperatorTRIA3();
if (m_cache_warming != 1) {
m_time_stats->resetStats("AssembleCusparseBilinearOperator");
Expand All @@ -418,8 +417,8 @@ _doStationarySolve()
}
}
}

#endif

if (m_use_coo) {
m_linear_system.clearValues();
_assembleCooBilinearOperatorTRIA3();
Expand Down

0 comments on commit 55f9811

Please sign in to comment.