Skip to content

Commit ba1bd4f

Browse files
committed
updated standalone function
1 parent d40e485 commit ba1bd4f

File tree

6 files changed

+21
-22
lines changed

6 files changed

+21
-22
lines changed

icicle/include/hash/blake2s/blake2s.cuh

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace blake2s {
4747
};
4848

4949
extern "C" {
50-
void
51-
mcm_cuda_blake2s_hash_batch(BYTE* key, WORD keylen, BYTE* in, WORD inlen, BYTE* out, WORD output_len, WORD n_batch);
50+
cudaError_t
51+
cuda_blake2s_hash_batch(BYTE* key, WORD keylen, BYTE* in, WORD inlen, BYTE* out, WORD output_len, WORD n_batch);
5252
}
5353
} // namespace blake2s

icicle/src/hash/blake2s/blake2s.cu

+7-8
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ namespace blake2s {
7272
return a;
7373
}
7474

75-
__device__ uint32_t cuda_blake2s_ROTR32(uint32_t a, uint8_t b) { return (a >> b) | (a << (32 - b)); }
75+
__inline__ __device__ uint32_t cuda_blake2s_ROTR32(uint32_t a, uint8_t b) { return (a >> b) | (a << (32 - b)); }
7676

7777
__device__ void
7878
cuda_blake2s_G(cuda_blake2s_ctx_t* ctx, uint32_t m1, uint32_t m2, int32_t a, int32_t b, int32_t c, int32_t d)
@@ -221,8 +221,8 @@ namespace blake2s {
221221
}
222222

223223
extern "C" {
224-
void
225-
mcm_cuda_blake2s_hash_batch(BYTE* key, WORD keylen, BYTE* in, WORD inlen, BYTE* out, WORD output_len, WORD n_batch)
224+
cudaError_t
225+
cuda_blake2s_hash_batch(BYTE* key, WORD keylen, BYTE* in, WORD inlen, BYTE* out, WORD output_len, WORD n_batch)
226226
{
227227
BYTE* cuda_indata;
228228
BYTE* cuda_outdata;
@@ -231,9 +231,6 @@ namespace blake2s {
231231
cudaMalloc(&cuda_outdata, BLAKE2S_BLOCK_SIZE * n_batch);
232232
assert(keylen <= 32);
233233

234-
// CUDA_BLAKE2S_CTX ctx;
235-
// cpu_blake2s_init(&ctx, key, keylen, n_outbit);
236-
// cudaMemcpyToSymbol(c_CTX, &ctx, sizeof(CUDA_BLAKE2S_CTX), 0, cudaMemcpyHostToDevice);
237234

238235
cudaMemcpy(cuda_indata, in, inlen * n_batch, cudaMemcpyHostToDevice);
239236

@@ -242,10 +239,12 @@ namespace blake2s {
242239
kernel_blake2s_hash<<<block, thread>>>(cuda_indata, inlen, cuda_outdata, n_batch, BLAKE2S_BLOCK_SIZE);
243240
cudaMemcpy(out, cuda_outdata, BLAKE2S_BLOCK_SIZE * n_batch, cudaMemcpyDeviceToHost);
244241
cudaDeviceSynchronize();
245-
cudaError_t error = cudaGetLastError();
246-
if (error != cudaSuccess) { printf("Error cuda blake2s hash: %s \n", cudaGetErrorString(error)); }
242+
// cudaError_t error = cudaGetLastError();
243+
// if (error != cudaSuccess) { printf("Error cuda blake2s hash: %s \n", cudaGetErrorString(error)); }
247244
cudaFree(cuda_indata);
248245
cudaFree(cuda_outdata);
246+
CHK_IF_RETURN(cudaPeekAtLastError());
247+
return CHK_LAST();
249248
}
250249
}
251250

icicle/src/hash/blake2s/test_blake2s.cu

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ using namespace blake2s;
1515
#define END_TIMER(timer, msg) \
1616
printf("%s: %.0f us\n", msg, FpMicroseconds(std::chrono::high_resolution_clock::now() - timer##_start).count());
1717

18-
extern "C" {
19-
void mcm_cuda_blake2s_hash_batch(BYTE* key, WORD keylen, BYTE* in, WORD inlen, BYTE* out, WORD outlen, WORD n_batch);
20-
}
18+
// extern "C" {
19+
// void cuda_blake2s_hash_batch(BYTE* key, WORD keylen, BYTE* in, WORD inlen, BYTE* out, WORD outlen, WORD n_batch);
20+
// }
2121

2222
void print_hash(BYTE* hash, WORD len)
2323
{
@@ -97,7 +97,7 @@ int main(int argc, char** argv)
9797

9898
// Perform the hashing
9999
START_TIMER(blake_timer)
100-
mcm_cuda_blake2s_hash_batch(key, keylen, input, inlen, output, outlen, n_batch);
100+
cuda_blake2s_hash_batch(key, keylen, input, inlen, output, outlen, n_batch);
101101
END_TIMER(blake_timer, "Blake Timer")
102102

103103
// Print the result

icicle/src/hash/blake2s/test_blake2s_batched.cu

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ int main(int argc, char** argv)
121121

122122
// Perform the hashing
123123
START_TIMER(blake_timer)
124-
// mcm_cuda_blake2s_hash_batch(key, keylen, batched_input, max_len, output, outlen, n_batch);
124+
// cuda_blake2s_hash_batch(key, keylen, batched_input, max_len, output, outlen, n_batch);
125125
blake2s_cuda(batched_input, output, n_batch, max_len, outlen, config);
126126
END_TIMER(blake_timer, "Blake Timer")
127127

icicle/src/hash/blake2s/test_blake2s_integ.cu

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ using namespace blake2s;
1414
#define END_TIMER(timer, msg) \
1515
printf("%s: %.0f us\n", msg, FpMicroseconds(std::chrono::high_resolution_clock::now() - timer##_start).count());
1616

17-
extern "C" {
18-
void mcm_cuda_blake2s_hash_batch(BYTE* key, WORD keylen, BYTE* in, WORD inlen, BYTE* out, WORD n_outbit, WORD n_batch);
19-
}
17+
// extern "C" {
18+
// void cuda_blake2s_hash_batch(BYTE* key, WORD keylen, BYTE* in, WORD inlen, BYTE* out, WORD n_outbit, WORD n_batch);
19+
// }
2020

2121
void print_hash(BYTE* hash, WORD len)
2222
{

icicle/src/hash/blake2s/test_blake2s_seq_sa.cu

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ using namespace blake2s;
1515
#define END_TIMER(timer, msg) \
1616
printf("%s: %.0f us\n", msg, FpMicroseconds(std::chrono::high_resolution_clock::now() - timer##_start).count());
1717

18-
extern "C" {
19-
void mcm_cuda_blake2s_hash_batch(BYTE* key, WORD keylen, BYTE* in, WORD inlen, BYTE* out, WORD n_outbit, WORD n_batch);
20-
}
18+
// extern "C" {
19+
// void cuda_blake2s_hash_batch(BYTE* key, WORD keylen, BYTE* in, WORD inlen, BYTE* out, WORD n_outbit, WORD n_batch);
20+
// }
2121

2222
void print_hash(BYTE* hash, WORD len)
2323
{
@@ -93,7 +93,7 @@ int main(int argc, char** argv)
9393

9494
// Perform the hashing
9595
START_TIMER(blake_timer)
96-
mcm_cuda_blake2s_hash_batch(key, keylen, input, inlen, output, outlen, n_batch);
96+
cuda_blake2s_hash_batch(key, keylen, input, inlen, output, outlen, n_batch);
9797
END_TIMER(blake_timer, "Blake Timer")
9898
// Convert the output to hex string
9999
std::string computed_hash = byte_to_hex(output, outlen);

0 commit comments

Comments
 (0)