Added support for CUDA compute capability 3.0. Multiple CUDA architecture compilation support.
This commit is contained in:
parent
c864c27f13
commit
d8daeda7ba
2 changed files with 96 additions and 52 deletions
|
@ -394,7 +394,13 @@ if(WITH_CUDA)
|
||||||
set(
|
set(
|
||||||
CUDA_NVCC_FLAGS
|
CUDA_NVCC_FLAGS
|
||||||
${CUDA_NVCC_FLAGS};
|
${CUDA_NVCC_FLAGS};
|
||||||
-O3 -arch=compute_35 -std=c++11
|
-O3 -std=c++11 --ptxas-options=-v
|
||||||
|
-gencode=arch=compute_75,code="sm_75,compute_75"
|
||||||
|
-gencode=arch=compute_61,code="sm_61,compute_61"
|
||||||
|
-gencode=arch=compute_52,code="sm_52,compute_52"
|
||||||
|
-gencode=arch=compute_50,code="sm_50,compute_50"
|
||||||
|
-gencode=arch=compute_35,code="sm_35,compute_35"
|
||||||
|
-gencode=arch=compute_30,code="sm_30,compute_30"
|
||||||
)
|
)
|
||||||
cuda_add_library(cuda_hasher MODULE ${SOURCE_CUDA_HASHER})
|
cuda_add_library(cuda_hasher MODULE ${SOURCE_CUDA_HASHER})
|
||||||
set_target_properties(cuda_hasher
|
set_target_properties(cuda_hasher
|
||||||
|
|
|
@ -19,6 +19,11 @@
|
||||||
|
|
||||||
#include "blake2b.cu"
|
#include "blake2b.cu"
|
||||||
|
|
||||||
|
#ifndef __CUDA_ARCH__
|
||||||
|
#define __CUDA_ARCH__ 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (__CUDA_ARCH__ >= 350)
|
||||||
#define COMPUTE \
|
#define COMPUTE \
|
||||||
asm ("{" \
|
asm ("{" \
|
||||||
".reg .u32 s1, s2, s3, s4;\n\t" \
|
".reg .u32 s1, s2, s3, s4;\n\t" \
|
||||||
|
@ -70,6 +75,39 @@
|
||||||
"shf.r.wrap.b32 %3, s3, s4, 31;\n\t" \
|
"shf.r.wrap.b32 %3, s3, s4, 31;\n\t" \
|
||||||
"shf.r.wrap.b32 %2, s4, s3, 31;\n\t" \
|
"shf.r.wrap.b32 %2, s4, s3, 31;\n\t" \
|
||||||
"}" : "+r"(tmp_a.x), "+r"(tmp_a.y), "+r"(tmp_a.z), "+r"(tmp_a.w), "+r"(tmp_b.x), "+r"(tmp_b.y), "+r"(tmp_b.z), "+r"(tmp_b.w));
|
"}" : "+r"(tmp_a.x), "+r"(tmp_a.y), "+r"(tmp_a.z), "+r"(tmp_a.w), "+r"(tmp_b.x), "+r"(tmp_b.y), "+r"(tmp_b.z), "+r"(tmp_b.w));
|
||||||
|
#else
|
||||||
|
#define downsample(x, lo, hi) \
|
||||||
|
{ \
|
||||||
|
lo = (uint32_t)x; \
|
||||||
|
hi = (uint32_t)(x >> 32); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define upsample(lo, hi) (((uint64_t)(hi) << 32) | (uint64_t)(lo))
|
||||||
|
|
||||||
|
#define rotate(x, n) (((x) >> (64-n)) | ((x) << n))
|
||||||
|
|
||||||
|
#define fBlaMka(x, y) ((x) + (y) + 2 * upsample((uint32_t)(x) * (uint32_t)y, __umulhi((uint32_t)(x), (uint32_t)(y))))
|
||||||
|
|
||||||
|
#define COMPUTE \
|
||||||
|
{ \
|
||||||
|
uint64_t a64 = upsample(tmp_a.x, tmp_a.y); \
|
||||||
|
uint64_t b64 = upsample(tmp_a.z, tmp_a.w); \
|
||||||
|
uint64_t c64 = upsample(tmp_b.x, tmp_b.y); \
|
||||||
|
uint64_t d64 = upsample(tmp_b.z, tmp_b.w); \
|
||||||
|
a64 = fBlaMka(a64, b64); \
|
||||||
|
d64 = rotate(d64 ^ a64, 32); \
|
||||||
|
c64 = fBlaMka(c64, d64); \
|
||||||
|
b64 = rotate(b64 ^ c64, 40); \
|
||||||
|
a64 = fBlaMka(a64, b64); \
|
||||||
|
d64 = rotate(d64 ^ a64, 48); \
|
||||||
|
c64 = fBlaMka(c64, d64); \
|
||||||
|
b64 = rotate(b64 ^ c64, 1); \
|
||||||
|
downsample(a64, tmp_a.x, tmp_a.y); \
|
||||||
|
downsample(b64, tmp_a.z, tmp_a.w); \
|
||||||
|
downsample(c64, tmp_b.x, tmp_b.y); \
|
||||||
|
downsample(d64, tmp_b.z, tmp_b.w); \
|
||||||
|
}
|
||||||
|
#endif // __CUDA_ARCH__
|
||||||
|
|
||||||
#define G1(data) \
|
#define G1(data) \
|
||||||
{ \
|
{ \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue