File indexing completed on 2026-04-10 07:49:43
0001 #pragma once
0002 #include "QUDARAP_API_EXPORT.hh"
0003 #include "plog/Severity.h"
0004 #include <vector>
0005 #include <cstdint>
0006
0007 struct NP ;
0008 struct dim3 ;
0009 struct salloc ;
0010
0011 struct QUDARAP_API QU
0012 {
0013 static const plog::Severity LEVEL ;
0014
0015 static constexpr const char* _MEMCHECK = "QU__MEMCHECK" ;
0016 static bool MEMCHECK ;
0017
0018 static salloc* alloc ;
0019
0020 static void alloc_add(const char* label, uint64_t num_items, uint64_t sizeof_item );
0021
0022 template <typename T>
0023 static char typecode() ;
0024
0025 template <typename T>
0026 static std::string rng_sequence_reldir(const char* prefix, unsigned ni, unsigned nj, unsigned nk, unsigned ni_tranche_size );
0027
0028 template <typename T>
0029 static std::string rng_sequence_name(const char* prefix, unsigned ni, unsigned nj, unsigned nk, unsigned ioffset );
0030
0031 template <typename T>
0032 static T* UploadArray(const T* array, unsigned num_items, const char* label ) ;
0033
0034 template <typename T>
0035 static T* DownloadArray(const T* array, unsigned num_items ) ;
0036
0037 template <typename T>
0038 static void Download(std::vector<T>& vec, const T* d_array, unsigned num_items) ;
0039
0040
0041 static const char* _cudaMalloc_OOM_NOTES ;
0042 static void _cudaMalloc( void** p2p, size_t size, const char* label );
0043
0044
0045 template <typename T>
0046 static T* device_alloc( unsigned num_items, const char* label ) ;
0047
0048 template <typename T>
0049 static T* device_alloc_zero( unsigned num_items, const char* label ) ;
0050
0051 template <typename T>
0052 static void device_memset( T* d, int value, unsigned num_items );
0053
0054 template <typename T>
0055 static void device_free( T* d ) ;
0056
0057 template <typename T>
0058 static void device_free_and_alloc(T** dd, unsigned num_items );
0059
0060 template <typename T>
0061 static int copy_device_to_host( T* h, T* d, unsigned num_items);
0062
0063 template <typename T>
0064 static void copy_device_to_host_and_free( T* h, T* d, unsigned num_items, const char* label );
0065
0066 template <typename T>
0067 static void copy_host_to_device( T* d, const T* h, unsigned num_items);
0068
0069 template <typename T>
0070 static unsigned NumItems( const NP* a );
0071
0072 template <typename T>
0073 static unsigned copy_host_to_device( T* d, const NP* a);
0074
0075
0076 static void ConfigureLaunch16( dim3& numBlocks, dim3& threadsPerBlock );
0077 static void ConfigureLaunch( dim3& numBlocks, dim3& threadsPerBlock, unsigned width, unsigned height );
0078 static void ConfigureLaunch2D( dim3& numBlocks, dim3& threadsPerBlock, unsigned width, unsigned height );
0079 static void ConfigureLaunch1D( dim3& numBlocks, dim3& threadsPerBlock, unsigned num, unsigned threads_per_block );
0080
0081 static std::string Desc(const dim3& d, int w);
0082 static std::string DescLaunch( const dim3& numBlocks, const dim3& threadsPerBlock );
0083 };
0084