Added Eigen compilation option

main
Kenneth Jao 2 years ago
parent 3963e70391
commit be5d816140
  1. 2
      docs/Doxyfile
  2. 4
      docs/source/conf.py
  3. 1
      docs/source/core.rst
  4. 10
      include/Array.h
  5. 4
      include/BLAS.h
  6. 6
      include/Macros.h

@ -829,7 +829,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched. # Note: If this tag is empty the current directory is searched.
INPUT = "./" INPUT = "./include"
# This tag can be used to specify the character encoding of the source files # This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses

@ -27,8 +27,8 @@ extensions = [
'breathe', 'breathe',
] ]
breathe_projects = {"DGEMS": "../build/xml"} breathe_projects = {"CudaTools": "../build/xml"}
breathe_default_project = "DGEMS" breathe_default_project = "CudaTools"
bibtex_bibfiles = ['refs.bib'] bibtex_bibfiles = ['refs.bib']

@ -42,6 +42,7 @@ Host-Device Automation
Compilation Options Compilation Options
------------------- -------------------
.. doxygendefine:: CUDATOOLS_ARRAY_MAX_AXES .. doxygendefine:: CUDATOOLS_ARRAY_MAX_AXES
.. doxygendefine:: CUDATOOLS_USE_EIGEN
Macro Functions Macro Functions
=============== ===============

@ -4,7 +4,7 @@
#include "Core.h" #include "Core.h"
#include "Macros.h" #include "Macros.h"
#include "Types.h" #include "Types.h"
#include <Eigen/Dense>
#include <cmath> #include <cmath>
#include <complex> #include <complex>
#include <cstdlib> #include <cstdlib>
@ -12,6 +12,10 @@
#include <random> #include <random>
#include <type_traits> #include <type_traits>
#ifdef CUDATOOLS_USE_EIGEN
#include <Eigen/Dense>
#endif
#ifdef DEVICE #ifdef DEVICE
#define POINTER pDevice #define POINTER pDevice
#else #else
@ -22,6 +26,7 @@ using namespace CudaTools::Types;
namespace CudaTools { namespace CudaTools {
#ifdef CUDATOOLS_USE_EIGEN
template <typename T> template <typename T>
using EigenMat = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor>; using EigenMat = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor>;
template <typename T> using EigenMapMat = Eigen::Map<EigenMat<T>>; template <typename T> using EigenMapMat = Eigen::Map<EigenMat<T>>;
@ -30,6 +35,7 @@ template <typename T> using ConstEigenMapMat = Eigen::Map<const EigenMat<T>>;
template <typename T> struct EigenAdaptConst_S { typedef EigenMapMat<T> type; }; template <typename T> struct EigenAdaptConst_S { typedef EigenMapMat<T> type; };
template <typename T> struct EigenAdaptConst_S<const T> { typedef ConstEigenMapMat<T> type; }; template <typename T> struct EigenAdaptConst_S<const T> { typedef ConstEigenMapMat<T> type; };
template <typename T> using EigenAdaptConst = typename EigenAdaptConst_S<T>::type; template <typename T> using EigenAdaptConst = typename EigenAdaptConst_S<T>::type;
#endif
template <typename T> class Array; template <typename T> class Array;
@ -496,6 +502,7 @@ template <typename T> class Array {
*/ */
HD void flatten() { reshape({mShape.mItems}); }; HD void flatten() { reshape({mShape.mItems}); };
#ifdef CUDATOOLS_USE_EIGEN
/** /**
* Returns the Eigen::Map of this Array. * Returns the Eigen::Map of this Array.
*/ */
@ -507,6 +514,7 @@ template <typename T> class Array {
return EigenAdaptConst<ComplexConversion<T>>((ComplexConversion<T>*)POINTER, mShape.rows(), return EigenAdaptConst<ComplexConversion<T>>((ComplexConversion<T>*)POINTER, mShape.rows(),
mShape.cols()); mShape.cols());
}; };
#endif
/** /**
* Gets the Shape of the Array. * Gets the Shape of the Array.

@ -1,6 +1,10 @@
#ifndef CUDATOOLS_BLAS_H #ifndef CUDATOOLS_BLAS_H
#define CUDATOOLS_BLAS_H #define CUDATOOLS_BLAS_H
#ifndef CUDATOOLS_USE_EIGEN
#error "Cannot use CudaTools BLAS.h header without Eigen."
#endif
#include "Array.h" #include "Array.h"
#include "Core.h" #include "Core.h"
#include "Macros.h" #include "Macros.h"

@ -49,6 +49,12 @@
*/ */
#define SHARED #define SHARED
/**
* \def CUDATOOLS_USE_EIGEN
* Compile the CudaTools library with Eigen support.
*/
#define CUDATOOLS_USE_EIGEN
/** /**
* \def KERNEL(call, settings, ...) * \def KERNEL(call, settings, ...)
* Used to call a CUDA kernel. * Used to call a CUDA kernel.

Loading…
Cancel
Save