Skip to content

Commit 8552ab6

Browse files
committed
Support binning on GPU
1 parent dc8545b commit 8552ab6

15 files changed

+614
-138
lines changed

src/BinningOperation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include "hoomd/HOOMDMath.h"
99

10-
#ifndef __HIPCC__
10+
#ifdef __HIPCC__
1111
#define HOSTDEVICE __host__ __device__
1212
#else
1313
#define HOSTDEVICE

src/CMakeLists.txt

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ set(COMPONENT_NAME azplugins)
44
# TODO: List all host C++ source code files in _${COMPONENT_NAME}_sources.
55
set(_${COMPONENT_NAME}_sources
66
ConstantFlow.cc
7-
CylindricalVelocityFieldCompute.cc
87
GroupVelocityCompute.cc
98
module.cc
109
ParabolicFlow.cc
1110
)
1211

1312
# TODO: List all GPU C++ source code files in _${COMPONENT_NAME}_cu_sources.
1413
set(_${COMPONENT_NAME}_cu_sources
14+
VelocityFieldComputeGPU.cu
1515
)
1616

1717
# TODO: List all Python modules in python_files.
@@ -123,6 +123,28 @@ foreach(_evaluator ${_aniso_pair_evaluators})
123123
endif()
124124
endforeach()
125125

126+
# process velocity field geometries
127+
set(_binning_geometries
128+
Cylindrical
129+
)
130+
foreach(_geometry ${_binning_geometries})
131+
configure_file(export_VelocityFieldCompute.cc.inc
132+
export_${_geometry}VelocityFieldCompute.cc
133+
@ONLY)
134+
set(_${COMPONENT_NAME}_sources ${_${COMPONENT_NAME}_sources} export_${_geometry}VelocityFieldCompute.cc)
135+
136+
if (ENABLE_HIP)
137+
configure_file(export_VelocityFieldComputeGPU.cc.inc
138+
export_${_geometry}VelocityFieldComputeGPU.cc
139+
@ONLY)
140+
configure_file(VelocityFieldComputeGPUKernel.cu.inc
141+
${_geometry}VelocityFieldComputeGPUKernel.cu
142+
@ONLY)
143+
set(_${COMPONENT_NAME}_sources ${_${COMPONENT_NAME}_sources} export_${_geometry}VelocityFieldComputeGPU.cc)
144+
set(_${COMPONENT_NAME}_cu_sources ${_${COMPONENT_NAME}_cu_sources} ${_geometry}VelocityFieldComputeGPUKernel.cu)
145+
endif()
146+
endforeach()
147+
126148
if (ENABLE_HIP)
127149
set(_cuda_sources ${_${COMPONENT_NAME}_cu_sources})
128150
endif (ENABLE_HIP)

src/CylindricalBinningOperation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include "BinningOperation.h"
99

10-
#ifndef __HIPCC__
10+
#ifdef __HIPCC__
1111
#define HOSTDEVICE __host__ __device__
1212
#else
1313
#define HOSTDEVICE

src/CylindricalVelocityFieldCompute.cc

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/ParticleDataLoader.h

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Copyright (c) 2018-2020, Michael P. Howard
2+
// Copyright (c) 2021-2024, Auburn University
3+
// Part of azplugins, released under the BSD 3-Clause License.
4+
5+
#ifndef AZPLUGINS_PARTICLE_DATA_LOADER_H_
6+
#define AZPLUGINS_PARTICLE_DATA_LOADER_H_
7+
8+
#include "hoomd/HOOMDMath.h"
9+
10+
#ifdef __HIPCC__
11+
#define HOSTDEVICE __host__ __device__
12+
#else
13+
#define HOSTDEVICE
14+
#endif // __HIPCC__
15+
16+
namespace hoomd
17+
{
18+
namespace azplugins
19+
{
20+
namespace detail
21+
{
22+
23+
//! Load HOOMD particle in a group from an index
24+
class LoadHOOMDGroupPositionVelocityMass
25+
{
26+
public:
27+
HOSTDEVICE
28+
LoadHOOMDGroupPositionVelocityMass(Scalar4* positions,
29+
Scalar4* velocities,
30+
const unsigned int* indexes)
31+
: m_positions(positions), m_velocities(velocities), m_indexes(indexes)
32+
{
33+
}
34+
35+
HOSTDEVICE void
36+
operator()(Scalar3& position, Scalar3& velocity, Scalar& mass, unsigned int idx) const
37+
{
38+
const unsigned int pidx = m_indexes[idx];
39+
const Scalar4 postype = m_positions[pidx];
40+
position = make_scalar3(postype.x, postype.y, postype.z);
41+
42+
const Scalar4 velmass = m_velocities[pidx];
43+
velocity = make_scalar3(velmass.x, velmass.y, velmass.z);
44+
mass = velmass.w;
45+
}
46+
47+
private:
48+
Scalar4* const m_positions;
49+
Scalar4* const m_velocities;
50+
const unsigned int* const m_indexes;
51+
};
52+
53+
//! Load MPCD particle from an index
54+
class LoadMPCDPositionVelocityMass
55+
{
56+
public:
57+
HOSTDEVICE
58+
LoadMPCDPositionVelocityMass(Scalar4* positions, Scalar4* velocities, const Scalar mass)
59+
: m_positions(positions), m_velocities(velocities), m_mass(mass)
60+
{
61+
}
62+
63+
HOSTDEVICE void
64+
operator()(Scalar3& position, Scalar3& velocity, Scalar& mass, unsigned int idx) const
65+
{
66+
const Scalar4 postype = m_positions[idx];
67+
position = make_scalar3(postype.x, postype.y, postype.z);
68+
69+
const Scalar4 velcell = m_velocities[idx];
70+
velocity = make_scalar3(velcell.x, velcell.y, velcell.z);
71+
mass = m_mass;
72+
}
73+
74+
private:
75+
Scalar4* const m_positions;
76+
Scalar4* const m_velocities;
77+
const Scalar m_mass;
78+
};
79+
80+
} // end namespace detail
81+
} // end namespace azplugins
82+
} // end namespace hoomd
83+
84+
#undef HOSTDEVICE
85+
86+
#endif // AZPLUGINS_PARTICLE_DATA_LOADER_H_

0 commit comments

Comments
 (0)