Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F84640786
pair_win_sort.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Sep 24, 02:08
Size
2 KB
Mime Type
text/x-c
Expires
Thu, Sep 26, 02:08 (2 d)
Engine
blob
Format
Raw Data
Handle
21064165
Attached To
rLAMMPS lammps
pair_win_sort.cpp
View Options
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
Contributing authors: Mike Brown (ORNL), brownw@ornl.gov
------------------------------------------------------------------------- */
#ifndef USE_OPENCL
#include "cudpp.h"
#endif
class PairWinSort {
public:
inline PairWinSort() : _allocated(false) {
#ifndef USE_OPENCL
sort_config.op = CUDPP_ADD;
sort_config.datatype = CUDPP_UINT;
sort_config.algorithm = CUDPP_SORT_RADIX;
sort_config.options = CUDPP_OPTION_KEY_VALUE_PAIRS;
#endif
}
inline ~PairWinSort() { clear(); }
/// Free all memory on host and device
inline void clear() {
#ifndef USE_OPENCL
if (_allocated) { cudppDestroyPlan(sort_plan); _allocated=false; }
#endif
}
inline bool alloc(const int max_atoms) {
#ifndef USE_OPENCL
clear();
CUDPPResult result = cudppPlan(&sort_plan, sort_config, max_atoms, 1, 0);
if (CUDPP_SUCCESS != result)
return false;
#endif
return true;
}
/// Sort arrays for neighbor list calculation
void sort_neighbor(const int num_atoms, unsigned *cell_begin, int *particle_begin) {
#ifndef USE_OPENCL
CUDPPResult result = cudppSort(sort_plan, cell_begin, particle_begin,
8*sizeof(unsigned), num_atoms);
if (CUDPP_SUCCESS != result) {
printf("Error in cudppSort\n");
assert(1==0);
}
#endif
}
private:
bool allocated;
#ifndef USE_OPENCL
CUDPPConfiguration sort_config;
CUDPPHandle sort_plan;
#endif
};
static PairWinSort win_sort;
extern "C" __declspec(dllexport) bool _win_sort_alloc(const int max_atoms) {
win_sort.alloc(max_atoms);
}
extern "C" __declspec(dllexport) bool _win_sort(const int max_atoms, unsigned *cell_begin,
int *particle_begin) {
win_sort.sort(num_atoms,cell_begin,particle_begin);
}
Event Timeline
Log In to Comment