Skip to content

Commit

Permalink
Update NVCC SHA256 testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mborland committed Jan 9, 2025
1 parent db43491 commit 2e0888f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion test/nvcc_jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ project : requirements

run test_sha1_nvcc.cu ;
run test_sha224_nvcc.cu ;
#run test_sha256_nvcc.cu ;
run test_sha256_nvcc.cu ;
#run test_sha384_nvcc.cu ;
#run test_sha512_nvcc.cu ;
#run test_sha512_224_nvcc.cu ;
Expand Down
16 changes: 9 additions & 7 deletions test/test_sha256_nvcc.cu
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <boost/crypt/hash/sha256.hpp>
#include <cuda_runtime.h>
#include <boost/crypt2/hash/sha256.hpp>
#include "cuda_managed_ptr.hpp"
#include "stopwatch.hpp"
#include "generate_random_strings.hpp"
#include <iostream>
#include <iomanip>
#include <exception>
#include <memory>
#include <span>

#include <cuda_runtime.h>

using digest_type = boost::crypt::sha256_hasher::return_type;
using digest_type = cuda::std::array<cuda::std::byte, 32>;

// The kernel function
__global__ void cuda_test(char** in, digest_type* out, int numElements)
Expand All @@ -23,7 +23,8 @@ __global__ void cuda_test(char** in, digest_type* out, int numElements)

if (i < numElements)
{
out[i] = boost::crypt::sha256(in[i]);
auto in_span {cuda::std::span(in[i], 64)};
out[i] = boost::crypt::sha256(in_span);
}
}

Expand Down Expand Up @@ -59,7 +60,7 @@ int main()

// Launch the Vector Add CUDA Kernel
int threadsPerBlock = 256;
int blocksPerGrid =(numElements + threadsPerBlock - 1) / threadsPerBlock;
int blocksPerGrid = (numElements + threadsPerBlock - 1) / threadsPerBlock;
std::cout << "CUDA kernel launch with " << blocksPerGrid << " blocks of " << threadsPerBlock << " threads" << std::endl;

watch w;
Expand All @@ -80,7 +81,8 @@ int main()
w.reset();
for(int i = 0; i < numElements; ++i)
{
results.emplace_back(boost::crypt::sha256(input_vector1[i]));
std::span<char> in(input_vector1[i], elementSize);
results.emplace_back(boost::crypt::sha256(in));
}
double t = w.elapsed();

Expand Down

0 comments on commit 2e0888f

Please sign in to comment.