Add a kernel_config to calculate blocks and threads for launching kernels
Some checks failed
Build and Test / build-and-test (push) Failing after 5m3s
Some checks failed
Build and Test / build-and-test (push) Failing after 5m3s
This commit is contained in:
parent
130b613a7c
commit
8ba5714648
5 changed files with 169 additions and 9 deletions
|
@ -5,14 +5,12 @@
|
|||
|
||||
// Include your header files
|
||||
#include "forces.cuh"
|
||||
#include "kernel_config.cuh"
|
||||
#include "potentials/pair_potentials.cuh"
|
||||
#include "precision.hpp"
|
||||
|
||||
class CudaForceKernelTest : public ::testing::Test {
|
||||
protected:
|
||||
const int GRID_SIZE = 1;
|
||||
const int BLOCK_SIZE = 4;
|
||||
|
||||
void SetUp() override {
|
||||
// Set up CUDA device
|
||||
cudaError_t err = cudaSetDevice(0);
|
||||
|
@ -61,13 +59,15 @@ protected:
|
|||
std::vector<float4> force_energies(n_particles,
|
||||
make_float4(0.0, 0.0, 0.0, 0.0));
|
||||
|
||||
KernelConfig kernel_config = get_launch_config(n_particles);
|
||||
float4 *d_positions = allocateAndCopyToGPU(positions);
|
||||
float4 *d_force_energies = allocateAndCopyToGPU(force_energies);
|
||||
real *d_box_len = allocateAndCopyToGPU(box_dimensions);
|
||||
|
||||
std::vector<PairPotentials> potentials = {LennardJones(1.0, 1.0, 3.0)};
|
||||
CAC::launch_force_kernels(d_positions, d_force_energies, n_particles,
|
||||
d_box_len, potentials, GRID_SIZE, BLOCK_SIZE);
|
||||
d_box_len, potentials, kernel_config.blocks,
|
||||
kernel_config.threads);
|
||||
|
||||
checkCudaError(cudaGetLastError(), "kernel launch");
|
||||
checkCudaError(cudaDeviceSynchronize(), "kernel execution");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue