Skip to content

Commit e6bad66

Browse files
authored
Merge pull request #818 from jngrad/clang-tidy
Address Clang-Tidy diagnostics
2 parents 39e7bb8 + 4ee4dbb commit e6bad66

File tree

6 files changed

+71
-71
lines changed

6 files changed

+71
-71
lines changed

core/src/Cabana_CommunicationPlan.hpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -664,10 +664,10 @@ class CommunicationPlan
664664
throw std::logic_error( "Failed MPI Communication" );
665665

666666
// Get the total number of imports/exports.
667-
_total_num_export =
668-
std::accumulate( _num_export.begin(), _num_export.end(), 0 );
669-
_total_num_import =
670-
std::accumulate( _num_import.begin(), _num_import.end(), 0 );
667+
_total_num_export = std::accumulate(
668+
_num_export.begin(), _num_export.end(), std::size_t{ 0u } );
669+
_total_num_import = std::accumulate(
670+
_num_import.begin(), _num_import.end(), std::size_t{ 0u } );
671671

672672
// Barrier before continuing to ensure synchronization.
673673
MPI_Barrier( comm() );
@@ -1281,12 +1281,14 @@ class CommunicationData
12811281
setData( particles );
12821282

12831283
auto send_capacity = sendCapacity();
1284-
std::size_t new_send_size = total_send * _overallocation;
1284+
auto new_send_size = static_cast<std::size_t>(
1285+
static_cast<double>( total_send ) * _overallocation );
12851286
if ( new_send_size > send_capacity )
12861287
_comm_data.reallocateSend( new_send_size );
12871288

12881289
auto recv_capacity = receiveCapacity();
1289-
std::size_t new_recv_size = total_recv * _overallocation;
1290+
auto new_recv_size = static_cast<std::size_t>(
1291+
static_cast<double>( total_recv ) * _overallocation );
12901292
if ( new_recv_size > recv_capacity )
12911293
_comm_data.reallocateReceive( new_recv_size );
12921294

core/src/Cabana_DeepCopy.hpp

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ template <class Space, class SrcAoSoA>
3737
inline AoSoA<typename SrcAoSoA::member_types, Space, SrcAoSoA::vector_length>
3838
create_mirror(
3939
const Space&, const SrcAoSoA& src,
40-
typename std::enable_if<
41-
( !std::is_same<typename SrcAoSoA::memory_space,
42-
typename Space::memory_space>::value )>::type* = 0 )
40+
std::enable_if_t<( !std::is_same_v<typename SrcAoSoA::memory_space,
41+
typename Space::memory_space> )>* =
42+
nullptr )
4343
{
4444
static_assert( is_aosoa<SrcAoSoA>::value,
4545
"create_mirror() requires an AoSoA" );
@@ -61,9 +61,9 @@ create_mirror(
6161
template <class Space, class SrcAoSoA>
6262
inline SrcAoSoA create_mirror_view(
6363
const Space&, const SrcAoSoA& src,
64-
typename std::enable_if<
65-
( std::is_same<typename SrcAoSoA::memory_space,
66-
typename Space::memory_space>::value )>::type* = 0 )
64+
std::enable_if_t<( std::is_same_v<typename SrcAoSoA::memory_space,
65+
typename Space::memory_space> )>* =
66+
nullptr )
6767
{
6868
static_assert( is_aosoa<SrcAoSoA>::value,
6969
"create_mirror_view() requires an AoSoA" );
@@ -84,9 +84,9 @@ template <class Space, class SrcAoSoA>
8484
inline AoSoA<typename SrcAoSoA::member_types, Space, SrcAoSoA::vector_length>
8585
create_mirror_view(
8686
const Space& space, const SrcAoSoA& src,
87-
typename std::enable_if<
88-
( !std::is_same<typename SrcAoSoA::memory_space,
89-
typename Space::memory_space>::value )>::type* = 0 )
87+
std::enable_if_t<( !std::is_same_v<typename SrcAoSoA::memory_space,
88+
typename Space::memory_space> )>* =
89+
nullptr )
9090
{
9191
static_assert( is_aosoa<SrcAoSoA>::value,
9292
"create_mirror_view() requires an AoSoA" );
@@ -107,10 +107,9 @@ create_mirror_view(
107107
template <class Space, class SrcAoSoA>
108108
inline SrcAoSoA create_mirror_view_and_copy(
109109
const Space&, const SrcAoSoA& src,
110-
typename std::enable_if<
111-
( std::is_same<typename SrcAoSoA::memory_space,
112-
typename Space::memory_space>::value &&
113-
is_aosoa<SrcAoSoA>::value )>::type* = 0 )
110+
std::enable_if_t<( std::is_same_v<typename SrcAoSoA::memory_space,
111+
typename Space::memory_space> &&
112+
is_aosoa<SrcAoSoA>::value )>* = nullptr )
114113
{
115114
return src;
116115
}
@@ -130,10 +129,9 @@ template <class Space, class SrcAoSoA>
130129
inline AoSoA<typename SrcAoSoA::member_types, Space, SrcAoSoA::vector_length>
131130
create_mirror_view_and_copy(
132131
const Space& space, const SrcAoSoA& src,
133-
typename std::enable_if<
134-
( !std::is_same<typename SrcAoSoA::memory_space,
135-
typename Space::memory_space>::value &&
136-
is_aosoa<SrcAoSoA>::value )>::type* = 0 )
132+
std::enable_if_t<( !std::is_same_v<typename SrcAoSoA::memory_space,
133+
typename Space::memory_space> &&
134+
is_aosoa<SrcAoSoA>::value )>* = nullptr )
137135
{
138136
auto dst = create_mirror( space, src );
139137

@@ -156,8 +154,8 @@ create_mirror_view_and_copy(
156154
template <class DstAoSoA, class SrcAoSoA>
157155
inline void
158156
deep_copy( DstAoSoA& dst, const SrcAoSoA& src,
159-
typename std::enable_if<( is_aosoa<DstAoSoA>::value &&
160-
is_aosoa<SrcAoSoA>::value )>::type* = 0 )
157+
std::enable_if_t<( is_aosoa<DstAoSoA>::value &&
158+
is_aosoa<SrcAoSoA>::value )>* = nullptr )
161159
{
162160
using dst_type = DstAoSoA;
163161
using src_type = SrcAoSoA;
@@ -168,8 +166,8 @@ deep_copy( DstAoSoA& dst, const SrcAoSoA& src,
168166

169167
// Check that the data types are the same.
170168
static_assert(
171-
std::is_same<typename dst_type::member_types,
172-
typename src_type::member_types>::value,
169+
std::is_same_v<typename dst_type::member_types,
170+
typename src_type::member_types>,
173171
"Attempted to deep copy AoSoA objects of different member types" );
174172

175173
// Check for the same number of values.
@@ -202,7 +200,7 @@ deep_copy( DstAoSoA& dst, const SrcAoSoA& src,
202200

203201
// If the inner array size is the same and both AoSoAs have the same number
204202
// of values then we can do a byte-wise copy directly.
205-
if ( std::is_same<dst_soa_type, src_soa_type>::value )
203+
if ( std::is_same_v<dst_soa_type, src_soa_type> )
206204
{
207205
Kokkos::deep_copy( Kokkos::View<char*, dst_memory_space>(
208206
reinterpret_cast<char*>( dst.data() ),
@@ -288,16 +286,16 @@ inline void deep_copy( AoSoA_t& aosoa,
288286
template <class DstSlice, class SrcSlice>
289287
inline void
290288
deep_copy( DstSlice& dst, const SrcSlice& src,
291-
typename std::enable_if<( is_slice<DstSlice>::value &&
292-
is_slice<SrcSlice>::value )>::type* = 0 )
289+
std::enable_if_t<( is_slice<DstSlice>::value &&
290+
is_slice<SrcSlice>::value )>* = nullptr )
293291
{
294292
using dst_type = DstSlice;
295293
using src_type = SrcSlice;
296294

297295
// Check that the data types are the same.
298296
static_assert(
299-
std::is_same<typename dst_type::value_type,
300-
typename src_type::value_type>::value,
297+
std::is_same_v<typename dst_type::value_type,
298+
typename src_type::value_type>,
301299
"Attempted to deep copy Slice objects of different value types" );
302300

303301
// Check that the element dimensions are the same.
@@ -417,8 +415,8 @@ template <class DstMemorySpace, class SrcMemorySpace, int VectorLength,
417415
auto create_mirror_view_and_copy(
418416
DstMemorySpace,
419417
ParticleList<SrcMemorySpace, VectorLength, FieldTags...> plist_src,
420-
typename std::enable_if<
421-
std::is_same<SrcMemorySpace, DstMemorySpace>::value>::type* = 0 )
418+
std::enable_if_t<std::is_same_v<SrcMemorySpace, DstMemorySpace>>* =
419+
nullptr )
422420
{
423421
return plist_src;
424422
}
@@ -435,8 +433,8 @@ template <class DstMemorySpace, class SrcMemorySpace, int VectorLength,
435433
auto create_mirror_view_and_copy(
436434
DstMemorySpace,
437435
ParticleList<SrcMemorySpace, VectorLength, FieldTags...> plist_src,
438-
typename std::enable_if<
439-
!std::is_same<SrcMemorySpace, DstMemorySpace>::value>::type* = 0 )
436+
std::enable_if_t<!std::is_same_v<SrcMemorySpace, DstMemorySpace>>* =
437+
nullptr )
440438
{
441439
// Extract the original AoSoA.
442440
auto aosoa_src = plist_src.aosoa();

core/src/Cabana_HDF5ParticleOutput.hpp

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -287,18 +287,18 @@ void writeFields(
287287
hid_t type_id =
288288
HDF5Traits<typename SliceType::value_type>::type( &dtype, &precision );
289289

290-
filespace_id = H5Screate_simple( 1, dimsf, NULL );
290+
filespace_id = H5Screate_simple( 1, dimsf, nullptr );
291291

292292
dcpl_id = H5Pcreate( H5P_DATASET_CREATE );
293293
H5Pset_fill_time( dcpl_id, H5D_FILL_TIME_NEVER );
294294

295295
dset_id = H5Dcreate( file_id, slice.label().c_str(), type_id, filespace_id,
296296
H5P_DEFAULT, dcpl_id, H5P_DEFAULT );
297297

298-
H5Sselect_hyperslab( filespace_id, H5S_SELECT_SET, offset, NULL, count,
299-
NULL );
298+
H5Sselect_hyperslab( filespace_id, H5S_SELECT_SET, offset, nullptr, count,
299+
nullptr );
300300

301-
memspace_id = H5Screate_simple( 1, count, NULL );
301+
memspace_id = H5Screate_simple( 1, count, nullptr );
302302

303303
plist_id = H5Pcreate( H5P_DATASET_XFER );
304304
// Default IO in HDF5 is independent
@@ -371,18 +371,18 @@ void writeFields(
371371
hid_t type_id =
372372
HDF5Traits<typename SliceType::value_type>::type( &dtype, &precision );
373373

374-
filespace_id = H5Screate_simple( 2, dimsf, NULL );
374+
filespace_id = H5Screate_simple( 2, dimsf, nullptr );
375375

376376
dcpl_id = H5Pcreate( H5P_DATASET_CREATE );
377377
H5Pset_fill_time( dcpl_id, H5D_FILL_TIME_NEVER );
378378

379379
dset_id = H5Dcreate( file_id, slice.label().c_str(), type_id, filespace_id,
380380
H5P_DEFAULT, dcpl_id, H5P_DEFAULT );
381381

382-
H5Sselect_hyperslab( filespace_id, H5S_SELECT_SET, offset, NULL, count,
383-
NULL );
382+
H5Sselect_hyperslab( filespace_id, H5S_SELECT_SET, offset, nullptr, count,
383+
nullptr );
384384

385-
memspace_id = H5Screate_simple( 2, dimsm, NULL );
385+
memspace_id = H5Screate_simple( 2, dimsm, nullptr );
386386
plist_id = H5Pcreate( H5P_DATASET_XFER );
387387
// Default IO in HDF5 is independent
388388
if ( h5_config.collective )
@@ -458,18 +458,18 @@ void writeFields(
458458
hid_t type_id =
459459
HDF5Traits<typename SliceType::value_type>::type( &dtype, &precision );
460460

461-
filespace_id = H5Screate_simple( 3, dimsf, NULL );
461+
filespace_id = H5Screate_simple( 3, dimsf, nullptr );
462462

463463
dcpl_id = H5Pcreate( H5P_DATASET_CREATE );
464464
H5Pset_fill_time( dcpl_id, H5D_FILL_TIME_NEVER );
465465

466466
dset_id = H5Dcreate( file_id, slice.label().c_str(), type_id, filespace_id,
467467
H5P_DEFAULT, dcpl_id, H5P_DEFAULT );
468468

469-
H5Sselect_hyperslab( filespace_id, H5S_SELECT_SET, offset, NULL, count,
470-
NULL );
469+
H5Sselect_hyperslab( filespace_id, H5S_SELECT_SET, offset, nullptr, count,
470+
nullptr );
471471

472-
memspace_id = H5Screate_simple( 3, dimsm, NULL );
472+
memspace_id = H5Screate_simple( 3, dimsm, nullptr );
473473
plist_id = H5Pcreate( H5P_DATASET_XFER );
474474
// Default IO in HDF5 is independent
475475
if ( h5_config.collective )
@@ -575,15 +575,15 @@ void writeTimeStep( HDF5Config h5_config, const std::string& prefix,
575575
#if H5_VERSION_GE( 1, 10, 1 )
576576
if ( h5_config.evict_on_close )
577577
{
578-
H5Pset_evict_on_close( plist_id, (hbool_t)1 );
578+
H5Pset_evict_on_close( plist_id, true );
579579
}
580580
#endif
581581

582582
#if H5_VERSION_GE( 1, 10, 0 )
583583
if ( h5_config.collective )
584584
{
585-
H5Pset_all_coll_metadata_ops( plist_id, 1 );
586-
H5Pset_coll_metadata_write( plist_id, 1 );
585+
H5Pset_all_coll_metadata_ops( plist_id, true );
586+
H5Pset_coll_metadata_write( plist_id, true );
587587
}
588588
#endif
589589

@@ -596,8 +596,8 @@ void writeTimeStep( HDF5Config h5_config, const std::string& prefix,
596596
H5FD_subfiling_config_t subfiling_config;
597597
H5FD_ioc_config_t ioc_config;
598598

599-
H5FD_subfiling_config_t* subfiling_ptr = NULL;
600-
H5FD_ioc_config_t* ioc_ptr = NULL;
599+
H5FD_subfiling_config_t* subfiling_ptr = nullptr;
600+
H5FD_ioc_config_t* ioc_ptr = nullptr;
601601

602602
// Get the default subfiling configuration parameters
603603
hid_t fapl_id = H5I_INVALID_HID;
@@ -610,38 +610,38 @@ void writeTimeStep( HDF5Config h5_config, const std::string& prefix,
610610
{
611611
subfiling_config.shared_cfg.stripe_size =
612612
h5_config.subfiling_stripe_size;
613-
if ( subfiling_ptr == NULL )
613+
if ( subfiling_ptr == nullptr )
614614
subfiling_ptr = &subfiling_config;
615615
}
616616
if ( h5_config.subfiling_stripe_count !=
617617
subfiling_config.shared_cfg.stripe_count )
618618
{
619619
subfiling_config.shared_cfg.stripe_count =
620620
h5_config.subfiling_stripe_count;
621-
if ( subfiling_ptr == NULL )
621+
if ( subfiling_ptr == nullptr )
622622
subfiling_ptr = &subfiling_config;
623623
}
624624
if ( h5_config.subfiling_ioc_selection !=
625625
(int)subfiling_config.shared_cfg.ioc_selection )
626626
{
627627
subfiling_config.shared_cfg.ioc_selection =
628628
(H5FD_subfiling_ioc_select_t)h5_config.subfiling_ioc_selection;
629-
if ( subfiling_ptr == NULL )
629+
if ( subfiling_ptr == nullptr )
630630
subfiling_ptr = &subfiling_config;
631631
}
632632
if ( h5_config.subfiling_thread_pool_size !=
633633
H5FD_IOC_DEFAULT_THREAD_POOL_SIZE )
634634
{
635635
H5Pget_fapl_ioc( fapl_id, &ioc_config );
636636
ioc_config.thread_pool_size = h5_config.subfiling_thread_pool_size;
637-
if ( ioc_ptr == NULL )
637+
if ( ioc_ptr == nullptr )
638638
ioc_ptr = &ioc_config;
639639
}
640640
H5Pclose( fapl_id );
641641

642642
H5Pset_mpi_params( plist_id, comm, MPI_INFO_NULL );
643643

644-
if ( ioc_ptr != NULL )
644+
if ( ioc_ptr != nullptr )
645645
H5Pset_fapl_ioc( subfiling_config.ioc_fapl_id, ioc_ptr );
646646

647647
H5Pset_fapl_subfiling( plist_id, subfiling_ptr );
@@ -705,12 +705,12 @@ void writeTimeStep( HDF5Config h5_config, const std::string& prefix,
705705
dimsf[0] = n_global;
706706
dimsf[1] = 3;
707707

708-
filespace_id = H5Screate_simple( 2, dimsf, NULL );
708+
filespace_id = H5Screate_simple( 2, dimsf, nullptr );
709709

710710
count[0] = n_local;
711711
count[1] = 3;
712712

713-
memspace_id = H5Screate_simple( 2, count, NULL );
713+
memspace_id = H5Screate_simple( 2, count, nullptr );
714714

715715
plist_id = H5Pcreate( H5P_DATASET_XFER );
716716

@@ -729,8 +729,8 @@ void writeTimeStep( HDF5Config h5_config, const std::string& prefix,
729729
dset_id = H5Dcreate( file_id, coords_slice.label().c_str(), type_id,
730730
filespace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT );
731731

732-
H5Sselect_hyperslab( filespace_id, H5S_SELECT_SET, offset, NULL, count,
733-
NULL );
732+
H5Sselect_hyperslab( filespace_id, H5S_SELECT_SET, offset, nullptr, count,
733+
nullptr );
734734

735735
H5Dwrite( dset_id, type_id, memspace_id, filespace_id, plist_id,
736736
host_coords.data() );
@@ -876,7 +876,7 @@ void readTimeStep( HDF5Config h5_config, const std::string& prefix,
876876
#if H5_VERSION_GE( 1, 10, 0 )
877877
if ( h5_config.collective )
878878
{
879-
H5Pset_all_coll_metadata_ops( plist_id, 1 );
879+
H5Pset_all_coll_metadata_ops( plist_id, true );
880880
}
881881
#endif
882882

@@ -902,7 +902,7 @@ void readTimeStep( HDF5Config h5_config, const std::string& prefix,
902902
ndims = H5Sget_simple_extent_ndims( filespace_id );
903903

904904
// Get the extents of the file dataspace.
905-
H5Sget_simple_extent_dims( filespace_id, dimsf, NULL );
905+
H5Sget_simple_extent_dims( filespace_id, dimsf, nullptr );
906906

907907
std::vector<int> all_offsets( comm_size );
908908
all_offsets[comm_rank] = n_local;
@@ -923,16 +923,16 @@ void readTimeStep( HDF5Config h5_config, const std::string& prefix,
923923
count[1] = dimsf[1];
924924
count[2] = dimsf[2];
925925

926-
memspace_id = H5Screate_simple( ndims, count, NULL );
926+
memspace_id = H5Screate_simple( ndims, count, nullptr );
927927

928928
plist_id = H5Pcreate( H5P_DATASET_XFER );
929929

930930
// Default IO in HDF5 is independent
931931
if ( h5_config.collective )
932932
H5Pset_dxpl_mpio( plist_id, H5FD_MPIO_COLLECTIVE );
933933

934-
H5Sselect_hyperslab( filespace_id, H5S_SELECT_SET, offset, NULL, count,
935-
NULL );
934+
H5Sselect_hyperslab( filespace_id, H5S_SELECT_SET, offset, nullptr, count,
935+
nullptr );
936936

937937
readField( dset_id, dtype_id, memspace_id, filespace_id, plist_id, n_local,
938938
field );

core/src/Cabana_LinkedCellList.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct LinkedCellStencil
4646
int cell_range;
4747

4848
//! Default Constructor
49-
LinkedCellStencil() {}
49+
LinkedCellStencil() = default;
5050

5151
//! Constructor
5252
LinkedCellStencil( const Scalar neighborhood_radius,
@@ -120,7 +120,7 @@ class LinkedCellList
120120
/*!
121121
\brief Default constructor.
122122
*/
123-
LinkedCellList() {}
123+
LinkedCellList() = default;
124124

125125
/*!
126126
\brief Simple constructor

0 commit comments

Comments
 (0)