Compare commits

..

No commits in common. "af42b353c40521b416f8d297b468f7eb437d85d0" and "4e2d1143e5aae72f301361b40ccc4d95b88f809e" have entirely different histories.

4 changed files with 68 additions and 29 deletions

View File

@ -24,6 +24,15 @@ namespace acc {
// cuda kernels // cuda kernels
template <typename F>
__MAYBE_GLOBAL__
void zeroing(F* a, size_t n) {
F zero = {0};
for (size_t i = 0; i < n; i++) {
a[i] = zero;
}
}
//// ////
template <typename F> template <typename F>
__MAYBE_DEVICE__ __MAYBE_HOST__ __INLINE__ __MAYBE_DEVICE__ __MAYBE_HOST__ __INLINE__

View File

@ -160,9 +160,9 @@ Atrip::Output Atrip::run(Atrip::Input<F> const& in) {
LOG(0,"Atrip") << "ooo blocks: " LOG(0,"Atrip") << "ooo blocks: "
<< Atrip::kernelDimensions.ooo.blocks << "\n"; << Atrip::kernelDimensions.ooo.blocks << "\n";
LOG(0,"Atrip") << "ooo threads per block: " LOG(0,"Atrip") << "ooo threads per block: "
<< Atrip::kernelDimensions.ooo.threads << "\n"; << Atrip::kernelDimensions.ooo.threads << "\n";
#endif #endif
// allocate the three scratches, see piecuch // allocate the three scratches, see piecuch

View File

@ -21,6 +21,11 @@ namespace atrip {
template <> double maybeConjugate(const double a) { return a; } template <> double maybeConjugate(const double a) { return a; }
template <> Complex maybeConjugate(const Complex a) { return std::conj(a); } template <> Complex maybeConjugate(const Complex a) { return std::conj(a); }
#if defined(HAVE_CUDA)
#endif
namespace traits { namespace traits {
template <typename F> bool isComplex() { return false; } template <typename F> bool isComplex() { return false; }
template <> bool isComplex<double>() { return false; } template <> bool isComplex<double>() { return false; }

View File

@ -13,8 +13,6 @@
// limitations under the License. // limitations under the License.
// [[file:~/cuda/atrip/atrip.org::*Prolog][Prolog:2]] // [[file:~/cuda/atrip/atrip.org::*Prolog][Prolog:2]]
#include <cstring>
#include<atrip/Equations.hpp> #include<atrip/Equations.hpp>
#include<atrip/CUDA.hpp> #include<atrip/CUDA.hpp>
@ -28,7 +26,7 @@ namespace atrip {
#if defined(HAVE_CUDA) #if defined(HAVE_CUDA)
#define FOR_K() \ #define FOR_K() \
const size_t k = blockIdx.x * blockDim.x + threadIdx.x; \ const size_t k = blockIdx.x * blockDim.x + threadIdx.x; \
size_t idx = k*size*size; size_t idx = 0;
#else #else
#define FOR_K() for (size_t k=0, idx=0; k < size; k++) #define FOR_K() for (size_t k=0, idx=0; k < size; k++)
#endif #endif
@ -582,8 +580,13 @@ void getEnergySame
) )
#define MAYBE_CONJ(_conj, _buffer) \ #define MAYBE_CONJ(_conj, _buffer) \
do { \ do { \
acc::maybeConjugate<<<1, 1 \ acc::maybeConjugate<<< \
>>>((DataFieldType<F>*)_conj, \ \
Atrip::kernelDimensions.ooo.blocks, \
\
Atrip::kernelDimensions.ooo.threads \
\
>>>((DataFieldType<F>*)_conj, \
(DataFieldType<F>*)_buffer, \ (DataFieldType<F>*)_buffer, \
NoNoNo); \ NoNoNo); \
} while (0) } while (0)
@ -634,39 +637,61 @@ void getEnergySame
_t_buffer, \ _t_buffer, \
(int const*)&NoNo \ (int const*)&NoNo \
) )
#define MAYBE_CONJ(_conj, _buffer) \ #define MAYBE_CONJ(_conj, _buffer) \
acc::maybeConjugate((DataFieldType<F>*)_conj, \ do { \
(DataFieldType<F>*)_buffer,\ for (size_t __i = 0; __i < NoNoNo; ++__i) { \
NoNoNo); _conj[__i] \
= maybeConjugate<F>(_buffer[__i]); \
} \
} while (0)
#endif #endif
F one{1.0}, m_one{-1.0}, zero{0.0}; F one{1.0}, m_one{-1.0}, zero{0.0};
const size_t NoNoNo = No*NoNo; const size_t NoNoNo = No*NoNo;
// Zeroing vectors
#ifdef HAVE_CUDA #ifdef HAVE_CUDA
// DataFieldType<F>* _t_buffer;
// DataFieldType<F>* _vhhh;
// WITH_CHRONO("double:cuda:alloc",
// _CHECK_CUDA_SUCCESS("Allocating _t_buffer",
// cuMemAlloc((CUdeviceptr*)&_t_buffer,
// NoNoNo * sizeof(DataFieldType<F>)));
// _CHECK_CUDA_SUCCESS("Allocating _vhhh",
// cuMemAlloc((CUdeviceptr*)&_vhhh,
// NoNoNo * sizeof(DataFieldType<F>)));
// )
#if !defined(ATRIP_ONLY_DGEMM) #if !defined(ATRIP_ONLY_DGEMM)
{ // we still have to zero this
const size_t elements = NoNoNo * sizeof(DataFieldType<F>)/4; const size_t
WITH_CHRONO("double:zeroing", bs = Atrip::kernelDimensions.ooo.blocks,
_CHECK_CUDA_SUCCESS("Zeroing Tijk", ths = Atrip::kernelDimensions.ooo.threads;
cuMemsetD32_v2((CUdeviceptr)Tijk, 0x00, elements)); acc::zeroing<<<bs, ths>>>((DataFieldType<F>*)_t_buffer, NoNoNo);
_CHECK_CUDA_SUCCESS("Zeroing t buffer", acc::zeroing<<<bs, ths>>>((DataFieldType<F>*)_vhhh, NoNoNo);
cuMemsetD32_v2((CUdeviceptr)_t_buffer, 0x00, elements));
_CHECK_CUDA_SUCCESS("Zeroing vhhh buffer",
cuMemsetD32_v2((CUdeviceptr)_vhhh, 0x00, elements));
)
}
#endif #endif
#else #else
DataFieldType<F>* _t_buffer = (DataFieldType<F>*)malloc(NoNoNo * sizeof(F)); DataFieldType<F>* _t_buffer = (DataFieldType<F>*)malloc(NoNoNo * sizeof(F));
DataFieldType<F>* _vhhh = (DataFieldType<F>*)malloc(NoNoNo * sizeof(F)); DataFieldType<F>* _vhhh = (DataFieldType<F>*)malloc(NoNoNo * sizeof(F));
std::memset((void*)_t_buffer, 0x00, NoNoNo * sizeof(DataFieldType<F>)); DataFieldType<F> zero_h{0.0};
std::memset((void*)_vhhh, 0x00, NoNoNo * sizeof(DataFieldType<F>)); for (size_t i=0; i < NoNoNo; i++) {
std::memset((void*)Tijk, 0x00, NoNoNo * sizeof(DataFieldType<F>)); _t_buffer[i] = zero_h;
#endif /* HAVE_CUDA */ _vhhh[i] = zero_h;
}
#endif
// Set Tijk to zero
#if defined(HAVE_CUDA) && !defined(ATRIP_ONLY_DGEMM)
WITH_CHRONO("double:reorder",
acc::zeroing<<<bs, ths>>>((DataFieldType<F>*)Tijk,
NoNoNo);
)
#endif
#if !defined(HAVE_CUDA)
WITH_CHRONO("double:reorder",
for (size_t k = 0; k < NoNoNo; k++) {
Tijk[k] = DataFieldType<F>{0.0};
})
#endif /* !defined(HAVE_CUDA) */
#if defined(ATRIP_ONLY_DGEMM) #if defined(ATRIP_ONLY_DGEMM)