Use __CUDACC__ guard around CUDA to make sure that the CUDA code is only sent to
nvcc and not the host compiler when CUDA support is enable.
#include <deal.II/base/config.h>
-#ifdef DEAL_II_WITH_CUDA
-
-# include <deal.II/base/exceptions.h>
+#include <deal.II/base/exceptions.h>
+#if defined(DEAL_II_WITH_CUDA) && defined(__CUDACC__)
# include <cusolverDn.h>
# include <cusolverSp.h>
# include <cusparse.h>
+#endif
-# include <vector>
+#include <vector>
DEAL_II_NAMESPACE_OPEN
namespace Utilities
*/
~Handle();
+#if defined(DEAL_II_WITH_CUDA) && defined(__CUDACC__)
cusolverDnHandle_t cusolver_dn_handle;
cusolverSpHandle_t cusolver_sp_handle;
* Handle to the cuSPARSE library.
*/
cusparseHandle_t cusparse_handle;
+#endif
};
/**
inline void
malloc(T *&pointer, const unsigned int n_elements)
{
+#if defined(DEAL_II_WITH_CUDA) && defined(__CUDACC__)
cudaError_t cuda_error_code =
cudaMalloc(&pointer, n_elements * sizeof(T));
AssertCuda(cuda_error_code);
+#else
+ (void)pointer;
+ (void)n_elements;
+#endif
}
/**
inline void
free(T *&pointer)
{
+#if defined(DEAL_II_WITH_CUDA) && defined(__CUDACC__)
cudaError_t cuda_error_code = cudaFree(pointer);
AssertCuda(cuda_error_code);
pointer = nullptr;
+#else
+ (void)pointer;
+#endif
}
/**
inline void
copy_to_host(const T *pointer_dev, std::vector<T> &vector_host)
{
+#if defined(DEAL_II_WITH_CUDA) && defined(__CUDACC__)
cudaError_t cuda_error_code = cudaMemcpy(vector_host.data(),
pointer_dev,
vector_host.size() * sizeof(T),
cudaMemcpyDeviceToHost);
AssertCuda(cuda_error_code);
+#else
+ (void)pointer_dev;
+ (void)vector_host;
+#endif
}
/**
inline void
copy_to_dev(const std::vector<T> &vector_host, T *pointer_dev)
{
+#if defined(DEAL_II_WITH_CUDA) && defined(__CUDACC__)
cudaError_t cuda_error_code = cudaMemcpy(pointer_dev,
vector_host.data(),
vector_host.size() * sizeof(T),
cudaMemcpyHostToDevice);
AssertCuda(cuda_error_code);
+#else
+ (void)vector_host;
+ (void)pointer_dev;
+#endif
}
} // namespace CUDA
} // namespace Utilities
DEAL_II_NAMESPACE_CLOSE
#endif
-
-#endif
#include <complex>
#include <cstdlib>
-#ifdef DEAL_II_WITH_CUDA
-# include <cuda_runtime_api.h>
+#if defined(DEAL_II_WITH_CUDA) && defined(__CUDACC__)
# define DEAL_II_CUDA_HOST_DEV __host__ __device__
#else
# define DEAL_II_CUDA_HOST_DEV
#include <deal.II/base/config.h>
-#ifdef DEAL_II_WITH_CUDA
+#if defined(DEAL_II_WITH_CUDA) && defined(__CUDACC__)
DEAL_II_NAMESPACE_OPEN
#include <deal.II/base/config.h>
-#ifdef DEAL_II_WITH_CUDA
+#if defined(DEAL_II_WITH_CUDA) && defined(__CUDACC__)
# include <deal.II/base/cuda_size.h>
#include <deal.II/lac/cuda_kernels.h>
+#if defined(DEAL_II_WITH_CUDA) && defined(__CUDACC__)
+
DEAL_II_NAMESPACE_OPEN
namespace LinearAlgebra
DEAL_II_NAMESPACE_CLOSE
#endif
+
+#endif
#include <deal.II/base/config.h>
-#ifdef DEAL_II_WITH_CUDA
+#if defined(DEAL_II_WITH_CUDA) && defined(__CUDACC__)
# include <deal.II/base/cuda.h>
# include <deal.II/lac/cuda_sparse_matrix.h>
#include <deal.II/base/subscriptor.h>
-#ifdef DEAL_II_WITH_CUDA
+#if defined(DEAL_II_WITH_CUDA) && defined(__CUDACC__)
# include <deal.II/base/cuda.h>
# include <deal.II/lac/cuda_vector.h>
# include <Epetra_Import.h>
#endif
-#ifdef DEAL_II_WITH_CUDA
+#if defined(DEAL_II_WITH_CUDA)
# include <deal.II/lac/cuda_vector.h>
# include <cuda_runtime_api.h>
-#ifdef DEAL_II_WITH_CUDA
+#if defined(DEAL_II_WITH_CUDA)
template <typename Number>
void
ReadWriteVector<Number>::import(
#include <deal.II/base/config.h>
-#ifdef DEAL_II_WITH_CUDA
+#if defined(DEAL_II_WITH_CUDA) && defined(__CUDACC__)
# include <deal.II/base/tensor.h>
# include <deal.II/base/utilities.h>
#include <deal.II/base/config.h>
-#ifdef DEAL_II_WITH_CUDA
+#if defined(DEAL_II_WITH_CUDA) && defined(__CUDACC__)
# include <deal.II/base/utilities.h>
#include <deal.II/base/config.h>
-#ifdef DEAL_II_WITH_CUDA
+#if defined(DEAL_II_WITH_CUDA) && defined(__CUDACC__)
# include <deal.II/base/quadrature.h>
# include <deal.II/base/tensor.h>
# include <deal.II/lac/affine_constraints.h>
# include <deal.II/lac/cuda_vector.h>
-# include <cuda_runtime_api.h>
-
DEAL_II_NAMESPACE_OPEN
#include <deal.II/matrix_free/cuda_matrix_free.h>
-#ifdef DEAL_II_WITH_CUDA
+#if defined(DEAL_II_WITH_CUDA) && defined(__CUDACC__)
# include <deal.II/base/cuda_size.h>
# include <deal.II/base/graph_coloring.h>
#include <deal.II/base/config.h>
+#if defined(DEAL_II_WITH_CUDA) && defined(__CUDACC__)
DEAL_II_NAMESPACE_OPEN
DEAL_II_NAMESPACE_CLOSE
#endif
+
+#endif
${_include_dir}/deal.II/*.h
)
-#
-# Files that contain CUDA code cannot be sent to the host compiler so we removed
-# them from the list
-#
-LIST(REMOVE_ITEM _headers "lac/cuda_atomic.h"
- "lac/cuda_kernels.h"
- "lac/cuda_kernels.templates.h"
- "matrix_free/cuda_fe_evaluation.h"
- "matrix_free/cuda_hanging_nodes_internal.h"
- "matrix_free/cuda_matrix_free.templates.h"
- "matrix_free/cuda_tensor_product_kernels.h")
# Do not test bundled headers to avoid issues when tests are run
# for an already installed library