Answered step by step
Verified Expert Solution
Question
1 Approved Answer
hpc _ helper.hpp: #ifndef HPC _ HELPERS _ HPP #define HPC _ HELPERS _ HPP #include #include #ifndef _ _ CUDACC _ _ #include #endif
hpchelper.hpp:
#ifndef HPCHELPERSHPP
#define HPCHELPERSHPP
#include
#include
#ifndef CUDACC
#include
#endif
#ifndef CUDACC
#define TIMERSTARTlabel
std::chrono::timepoint a##label, b##label;
a##label std::chrono::systemclock::now;
#else
#define TIMERSTARTlabel
cudaEventt start##label, stop##label;
float time##label;
cudaEventCreate&start##label;
cudaEventCreate&stop##label;
cudaEventRecordstart##label, ;
#endif
#ifndef CUDACC
#define TIMERSTOPlabel
b##label std::chrono::systemclock::now;
std::chrono::duration delta##label b##labela##label;
std::cout # elapsed time #label :
delta##label.counts std::endl;
#else
#define TIMERSTOPlabel
cudaEventRecordstop##label, ;
cudaEventSynchronizestop##label;
cudaEventElapsedTime&time##label, start##label, stop##label;
std::cout "TIMING: time##label ms #label
std::endl;
#endif
#ifdef CUDACC
#define CUERR
cudaErrort err;
if err cudaGetLastError cudaSuccess
std::cout "CUDA error: cudaGetErrorStringerr :
FILE line LINE std::endl;
exit;
transfer constants
#define HD cudaMemcpyHostToDevice
#define DH cudaMemcpyDeviceToHost
#define HH cudaMemcpyHostToHost
#define DD cudaMemcpyDeviceToDevice
#endif
safe division
#define SDIVxyxyy
noinitt
#include
template
class noinitt
public:
staticassertstd::isfundamental::value &&
std::isarithmetic::value,
"wrapped type must be a fundamental, numeric type";
do nothing
constexpr noinitt noexcept
convertible from a T
constexpr noinittT value noexcept: vvalue
act as a T in all conversion contexts
constexpr operator T const noexcept return v;
negation on value and bit level
constexpr noinitt& operator noexcept vv; return this;
constexpr noinitt& operator ~ noexcept v ~v; return this;
prefix incrementdecrement operators
constexpr noinitt& operator noexcept v; return this;
constexpr noinitt& operator noexcept v; return this;
postfix incrementdecrement operators
constexpr noinitt operator int noexcept
auto oldthis;
v;
return old;
constexpr noinitt operator int noexcept
auto oldthis;
v;
return old;
assignment operators
constexpr noinitt& operator T v noexcept v v; return this;
constexpr noinitt& operator T v noexcept v v; return this;
constexpr noinitt& operator T v noexcept v v; return this;
constexpr noinitt& operator T v noexcept v v; return this;
bitwise operators
constexpr noinitt& operator &T v noexcept v & v; return this;
constexpr noinitt& operator T v noexcept v v; return this;
constexpr noinitt& operator T v noexcept v v; return this;
constexpr noinitt& operator T v noexcept v v; return this;
constexpr noinitt& operator T v noexcept v v; return this;
private:
T v;
;
#endif
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started