NDDEM
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
Multiproc< d > Class Template Reference

Manual multiprocessor handling for OpenMP, for max efficiency & avoiding bugs & race conditions, hopefully. More...

#include <Multiproc.h>

Public Member Functions

void initialise (int NN, int PP, Parameters< d > &Param)
 
void disp_share ()
 Display the # of particle on each thread. More...
 
bool ismine (int ID, int j)
 Check if a particle j belongs to the thread ID. More...
 
void delaying (int ID, int j, Action< d > &act)
 Record the action to be added later to the relevent atom in sequencial settings, avoid potential race condition if an action was added to an atom that is not owned by the thread. This is for a particle-particle contact. More...
 
void delayed_clean ()
 Clean the record list. More...
 
void delayingwall (int ID, int j, Action< d > &act)
 Record the action on the wall. Only usefull if the force on the wall needs to be calculated. More...
 
void delayedwall_clean ()
 Clean the record of the force on the wal. More...
 
void load_balance (ContactStrategies contactstrategy)
 Modify the atom share between threads to achieve better load balance between the threads based on the current speed of each one during the previous iterations. More...
 
void merge_newcontacts ()
 
int merge_oldnew_contacts (int ID)
 
void splitcells (int C)
 
auto contacts2array (ExportData exp, cv2d &X, Parameters< d > &P)
 pack the contact data in a 2d array More...
 
template<class Archive >
void serialize (Archive &ar)
 

Public Attributes

vector< ContactList< d > > CLp
 ContactList particle-particle for each processor. More...
 
vector< ContactList< d > > CLp_new
 New particle-particle contacts for each processor. More...
 
vector< ContactList< d > > CLw
 ContactList particle-wall for each processor. More...
 
vector< ContactListMesh< d > > CLm
 ContactList particle-mesh for each processor. More...
 
vector< Contacts< d > > C
 Dummy Contacts for independent calculation per processor. More...
 
vector< int > share
 Particle share between threads. A thread ID own particles with index between share[ID] and share[ID+1]. size(share)=P+1. More...
 
vector< int > sharecell
 Cell share between threads (for contact detection based on cells). A thread ID own cells with index between share[ID] and share[ID+1]. size(share)=P+1. More...
 
vector< double > timing_contacts
 
vector< double > timing_forces
 Used to record the time spent by each thread. More...
 
int num_time
 Number of sample of time spent. Resets when load_balance() is called. More...
 
CLp_it_t< dCLp_it
 Iterator list for fast access to particle contacts. More...
 
vector< vector< Action< d > > > delayed
 Records the delayed Action. More...
 
vector< vector< int > > delayedj
 Records the j id of the particle in the associated delayed action. More...
 
vector< uintdelayed_size
 Max length of the delayed vector for each thread. Can grow as needed on call to delaying() More...
 
vector< vector< Action< d > > > delayedwall
 Records the delayed Action. More...
 
vector< vector< int > > delayedwallj
 Records the j id of the wall in the associated delayed action. More...
 
vector< uintdelayedwall_size
 Max length of the delayed wall vector for each thread. Can grow as needed on call to delaying() More...
 
int P
 Number of threads. More...
 

Private Member Functions

void split (int N, int P)
 Function to allocate the grains to threads taking into account the load balance in the contact detection. load_balance() takes over after a few iteration have run, and is usually more efficient. More...
 

Private Attributes

v2d fullcontactinfo
 
int N
 Number of grains. More...
 

Detailed Description

template<int d>
class Multiproc< d >

Manual multiprocessor handling for OpenMP, for max efficiency & avoiding bugs & race conditions, hopefully.

Member Function Documentation

◆ initialise()

template<int d>
void Multiproc< d >::initialise ( int  NN,
int  PP,
Parameters< d > &  Param 
)
inline

◆ ismine()

template<int d>
bool Multiproc< d >::ismine ( int  ID,
int  j 
)
inline

Check if a particle j belongs to the thread ID.

◆ merge_newcontacts()

template<int d>
void Multiproc< d >::merge_newcontacts ( )
inline

◆ merge_oldnew_contacts()

template<int d>
int Multiproc< d >::merge_oldnew_contacts ( int  ID)
inline

◆ serialize()

template<int d>
template<class Archive >
void Multiproc< d >::serialize ( Archive &  ar)
inline

Member Data Documentation

◆ C

template<int d>
vector<Contacts<d> > Multiproc< d >::C

Dummy Contacts for independent calculation per processor.

◆ CLm

template<int d>
vector<ContactListMesh<d> > Multiproc< d >::CLm

ContactList particle-mesh for each processor.

◆ CLp

template<int d>
vector<ContactList<d> > Multiproc< d >::CLp

ContactList particle-particle for each processor.

◆ CLp_it

template<int d>
CLp_it_t<d> Multiproc< d >::CLp_it

Iterator list for fast access to particle contacts.

◆ CLp_new

template<int d>
vector<ContactList<d> > Multiproc< d >::CLp_new

New particle-particle contacts for each processor.

◆ CLw

template<int d>
vector<ContactList<d> > Multiproc< d >::CLw

ContactList particle-wall for each processor.

◆ delayed

template<int d>
vector<vector <Action<d> > > Multiproc< d >::delayed

Records the delayed Action.

◆ delayed_size

template<int d>
vector<uint> Multiproc< d >::delayed_size

Max length of the delayed vector for each thread. Can grow as needed on call to delaying()

◆ delayedj

template<int d>
vector<vector <int> > Multiproc< d >::delayedj

Records the j id of the particle in the associated delayed action.

◆ delayedwall

template<int d>
vector<vector <Action<d> > > Multiproc< d >::delayedwall

Records the delayed Action.

◆ delayedwall_size

template<int d>
vector<uint> Multiproc< d >::delayedwall_size

Max length of the delayed wall vector for each thread. Can grow as needed on call to delaying()

◆ delayedwallj

template<int d>
vector<vector <int> > Multiproc< d >::delayedwallj

Records the j id of the wall in the associated delayed action.

◆ fullcontactinfo

template<int d>
v2d Multiproc< d >::fullcontactinfo
private

◆ N

template<int d>
int Multiproc< d >::N
private

Number of grains.

◆ num_time

template<int d>
int Multiproc< d >::num_time

Number of sample of time spent. Resets when load_balance() is called.

◆ P

template<int d>
int Multiproc< d >::P

Number of threads.

◆ share

template<int d>
vector<int> Multiproc< d >::share

Particle share between threads. A thread ID own particles with index between share[ID] and share[ID+1]. size(share)=P+1.

◆ sharecell

template<int d>
vector<int> Multiproc< d >::sharecell

Cell share between threads (for contact detection based on cells). A thread ID own cells with index between share[ID] and share[ID+1]. size(share)=P+1.

◆ timing_contacts

template<int d>
vector<double> Multiproc< d >::timing_contacts

◆ timing_forces

template<int d>
vector<double> Multiproc< d >::timing_forces

Used to record the time spent by each thread.


The documentation for this class was generated from the following file: