Tinker9 70bd052 (Thu Nov 9 12:11:35 2023 -0800)
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Enumerations | Functions | Variables
Resource: Pointer, Allocation, Deallocation, Queue

Classes

class  tinker::darray
 Device array. More...
 
class  tinker::GenericUnit< T, VERSION >
 Resource handle. Analogous to Fortran i/o unit represented by a signed integer. More...
 
struct  tinker::v1::EnableEnumBitMask< E >
 Direct mathematical calculation of enum class is prohibited in C++. More...
 
class  tinker::ResourceManagement
 Resource management. Allocates resources in the object constructor and deallocates resources in the object destructor. More...
 
struct  tinker::calc
 Bitmasks for MD. More...
 

Macros

#define TINKER_ENABLE_ENUM_BITMASK(x)
 Explicitly enables mathematical calculation by casting enum class to integer. More...
 

Typedefs

using tinker::RcOp = ResourceOperation
 
using tinker::RcMan = ResourceManagement
 Type alias. More...
 

Enumerations

enum class  tinker::ResourceOperation { tinker::ResourceOperation::DEALLOC = 0x001 , tinker::ResourceOperation::ALLOC = 0x002 , tinker::ResourceOperation::INIT = 0x004 }
 

Functions

void tinker::waitFor (int queue)
 Similar to OpenACC wait and CUDA stream synchronize. More...
 
void tinker::deviceMemoryCopyinBytesAsync (void *dst, const void *src, size_t nbytes, int queue)
 Similar to OpenACC async copyin, copies data from host to device. More...
 
void tinker::deviceMemoryCopyoutBytesAsync (void *dst, const void *src, size_t nbytes, int queue)
 Similar to OpenACC async copyout, copies data from device to host. More...
 
void tinker::deviceMemoryCopyBytesAsync (void *dst, const void *src, size_t nbytes, int queue)
 Copies data between two pointers on device. More...
 
void tinker::deviceMemoryZeroBytesAsync (void *dst, size_t nbytes, int queue)
 Writes zero bytes on device. More...
 
void tinker::deviceMemoryDeallocate (void *ptr)
 Deallocates device pointer. More...
 
void tinker::deviceMemoryAllocateBytes (void **pptr, size_t nbytes)
 Allocates device pointer. More...
 
template<class T >
void tinker::v1::deviceMemoryCheckType ()
 Sanity check. More...
 
template<class DT , class ST >
void tinker::v1::deviceMemoryCopyin1dArray (DT *dst, const ST *src, size_t nelem, int q)
 Copies data to 1D array, host to device. More...
 
template<class DT , class ST >
void tinker::v1::deviceMemoryCopyout1dArray (DT *dst, const ST *src, size_t nelem, int q)
 Copies data to 1D array, device to host. More...
 
template<class E >
constexpr std::enable_if< EnableEnumBitMask< E >::value, E >::type tinker::operator| (E lhs, E rhs)
 
template<class E >
constexpr bool tinker::operator& (E lhs, E rhs)
 
void tinker::deviceData (RcOp)
 Set up and clean up device environment. More...
 

Variables

int tinker::rc_flag
 Global bitmask. More...
 

Detailed Description


Class Documentation

◆ tinker::darray

class tinker::darray

Device array.

Static Public Member Functions

template<class PTR >
static void allocate (size_t nelem, PTR *pp)
 
template<class PTR , class... PTRS>
static void allocate (size_t nelem, PTR *pp, PTRS... pps)
 
template<class PTR >
static void deallocate (PTR p)
 
template<class PTR , class... PTRS>
static void deallocate (PTR p, PTRS... ps)
 
template<class PTR >
static void zero (int q, size_t nelem, PTR p)
 
template<class PTR , class... PTRS>
static void zero (int q, size_t nelem, PTR p, PTRS... ps)
 
template<class PTR , class U >
static void copyin (int q, size_t nelem, PTR dst, const U *src)
 
template<class U , class PTR >
static void copyout (int q, size_t nelem, U *dst, const PTR src)
 
template<class PTR , class U >
static void copy (int q, size_t nelem, PTR dst, const U *src)
 Copies data across two device memory pointers. More...
 
template<class PTR , class PTR2 >
static PtrTrait< PTR >::type dotThenReturn (int q, size_t nelem, const PTR ptr, const PTR2 b)
 Calculates the dot product and returns the answer to the host. More...
 
template<class ANS , class PTR , class PTR2 >
static void dot (int q, size_t nelem, ANS ans, const PTR ptr, const PTR2 ptr2)
 Calculates the dot product and saves the answer to pointer ans. More...
 
template<class FLT , class PTR >
static void scale (int q, size_t nelem, FLT scal, PTR ptr)
 
template<class FLT , class PTR , class... PTRS>
static void scale (int q, size_t nelem, FLT scal, PTR ptr, PTRS... ptrs)
 

Member Function Documentation

◆ allocate() [1/2]

template<class PTR >
static void tinker::darray::allocate ( size_t  nelem,
PTR *  pp 
)
inlinestatic

◆ allocate() [2/2]

template<class PTR , class... PTRS>
static void tinker::darray::allocate ( size_t  nelem,
PTR *  pp,
PTRS...  pps 
)
inlinestatic

◆ copy()

template<class PTR , class U >
static void tinker::darray::copy ( int  q,
size_t  nelem,
PTR  dst,
const U *  src 
)
inlinestatic

Copies data across two device memory pointers.

◆ copyin()

template<class PTR , class U >
static void tinker::darray::copyin ( int  q,
size_t  nelem,
PTR  dst,
const U *  src 
)
inlinestatic

◆ copyout()

template<class U , class PTR >
static void tinker::darray::copyout ( int  q,
size_t  nelem,
U *  dst,
const PTR  src 
)
inlinestatic

◆ deallocate() [1/2]

template<class PTR >
static void tinker::darray::deallocate ( PTR  p)
inlinestatic

◆ deallocate() [2/2]

template<class PTR , class... PTRS>
static void tinker::darray::deallocate ( PTR  p,
PTRS...  ps 
)
inlinestatic

◆ dot()

template<class ANS , class PTR , class PTR2 >
static void tinker::darray::dot ( int  q,
size_t  nelem,
ANS  ans,
const PTR  ptr,
const PTR2  ptr2 
)
inlinestatic

Calculates the dot product and saves the answer to pointer ans.

◆ dotThenReturn()

template<class PTR , class PTR2 >
static PtrTrait< PTR >::type tinker::darray::dotThenReturn ( int  q,
size_t  nelem,
const PTR  ptr,
const PTR2  b 
)
inlinestatic

Calculates the dot product and returns the answer to the host.

◆ scale() [1/2]

template<class FLT , class PTR >
static void tinker::darray::scale ( int  q,
size_t  nelem,
FLT  scal,
PTR  ptr 
)
inlinestatic

◆ scale() [2/2]

template<class FLT , class PTR , class... PTRS>
static void tinker::darray::scale ( int  q,
size_t  nelem,
FLT  scal,
PTR  ptr,
PTRS...  ptrs 
)
inlinestatic

◆ zero() [1/2]

template<class PTR >
static void tinker::darray::zero ( int  q,
size_t  nelem,
PTR  p 
)
inlinestatic

◆ zero() [2/2]

template<class PTR , class... PTRS>
static void tinker::darray::zero ( int  q,
size_t  nelem,
PTR  p,
PTRS...  ps 
)
inlinestatic

◆ tinker::GenericUnit

class tinker::GenericUnit
template<class T, GenericUnitVersion VERSION = GenericUnitVersion::DISABLE_ON_DEVICE>
class tinker::GenericUnit< T, VERSION >

Resource handle. Analogous to Fortran i/o unit represented by a signed integer.

Public Member Functions

 GenericUnit ()
 
 GenericUnit (int u)
 
 operator int () const
 
bool valid () const
 Whether the current unit is open. More...
 
void close ()
 Closes the current unit. More...
 
void deviceptrUpdate (const T &hobj, int queue)
 Updates the object on device by an object on host. More...
 
const T & operator* () const
 Gets the (const) reference to the object on host. More...
 
T & operator* ()
 Gets the (const) reference to the object on host. More...
 
const T * operator-> () const
 Gets the (const) pointer to the object on host. More...
 
T * operator-> ()
 Gets the (const) pointer to the object on host. More...
 
const T * deviceptr () const
 Gets (const) device pointer to the object. More...
 
T * deviceptr ()
 Gets (const) device pointer to the object. More...
 

Static Public Member Functions

static int size ()
 Gets the number of open units. More...
 
static void clear ()
 Releases all of the resources and reset size() to 0. More...
 
template<class DT = T>
static void resize (int s)
 Resizes the capacity for the objects on host. More...
 
static GenericUnit open ()
 Returns a new unit, similar to opening a new Fortran i/o unit. More...
 

Constructor & Destructor Documentation

◆ GenericUnit() [1/2]

template<class T , GenericUnitVersion VERSION = GenericUnitVersion::DISABLE_ON_DEVICE>
tinker::GenericUnit< T, VERSION >::GenericUnit ( )
inline

◆ GenericUnit() [2/2]

template<class T , GenericUnitVersion VERSION = GenericUnitVersion::DISABLE_ON_DEVICE>
tinker::GenericUnit< T, VERSION >::GenericUnit ( int  u)
inline

Member Function Documentation

◆ clear()

template<class T , GenericUnitVersion VERSION = GenericUnitVersion::DISABLE_ON_DEVICE>
static void tinker::GenericUnit< T, VERSION >::clear ( )
inlinestatic

Releases all of the resources and reset size() to 0.

◆ close()

template<class T , GenericUnitVersion VERSION = GenericUnitVersion::DISABLE_ON_DEVICE>
void tinker::GenericUnit< T, VERSION >::close ( )
inline

Closes the current unit.

Note
The resource will not be released until clear() is called.

◆ deviceptr() [1/2]

template<class T , GenericUnitVersion VERSION = GenericUnitVersion::DISABLE_ON_DEVICE>
T * tinker::GenericUnit< T, VERSION >::deviceptr ( )
inline

Gets (const) device pointer to the object.

◆ deviceptr() [2/2]

template<class T , GenericUnitVersion VERSION = GenericUnitVersion::DISABLE_ON_DEVICE>
const T * tinker::GenericUnit< T, VERSION >::deviceptr ( ) const
inline

Gets (const) device pointer to the object.

◆ deviceptrUpdate()

template<class T , GenericUnitVersion VERSION = GenericUnitVersion::DISABLE_ON_DEVICE>
void tinker::GenericUnit< T, VERSION >::deviceptrUpdate ( const T &  hobj,
int  queue 
)
inline

Updates the object on device by an object on host.

Parameters
hobjReference to the object on host that can be accessed by the same unit number.
queueDevice queue for the update.

◆ open()

template<class T , GenericUnitVersion VERSION = GenericUnitVersion::DISABLE_ON_DEVICE>
static GenericUnit tinker::GenericUnit< T, VERSION >::open ( )
inlinestatic

Returns a new unit, similar to opening a new Fortran i/o unit.

◆ operator int()

template<class T , GenericUnitVersion VERSION = GenericUnitVersion::DISABLE_ON_DEVICE>
tinker::GenericUnit< T, VERSION >::operator int ( ) const
inline

◆ operator*() [1/2]

template<class T , GenericUnitVersion VERSION = GenericUnitVersion::DISABLE_ON_DEVICE>
T & tinker::GenericUnit< T, VERSION >::operator* ( )
inline

Gets the (const) reference to the object on host.

◆ operator*() [2/2]

template<class T , GenericUnitVersion VERSION = GenericUnitVersion::DISABLE_ON_DEVICE>
const T & tinker::GenericUnit< T, VERSION >::operator* ( ) const
inline

Gets the (const) reference to the object on host.

◆ operator->() [1/2]

template<class T , GenericUnitVersion VERSION = GenericUnitVersion::DISABLE_ON_DEVICE>
T * tinker::GenericUnit< T, VERSION >::operator-> ( )
inline

Gets the (const) pointer to the object on host.

◆ operator->() [2/2]

template<class T , GenericUnitVersion VERSION = GenericUnitVersion::DISABLE_ON_DEVICE>
const T * tinker::GenericUnit< T, VERSION >::operator-> ( ) const
inline

Gets the (const) pointer to the object on host.

◆ resize()

template<class T , GenericUnitVersion VERSION = GenericUnitVersion::DISABLE_ON_DEVICE>
template<class DT = T>
static void tinker::GenericUnit< T, VERSION >::resize ( int  s)
inlinestatic

Resizes the capacity for the objects on host.

Note
Cannot be called if device pointers are used.

◆ size()

template<class T , GenericUnitVersion VERSION = GenericUnitVersion::DISABLE_ON_DEVICE>
static int tinker::GenericUnit< T, VERSION >::size ( )
inlinestatic

Gets the number of open units.

◆ valid()

template<class T , GenericUnitVersion VERSION = GenericUnitVersion::DISABLE_ON_DEVICE>
bool tinker::GenericUnit< T, VERSION >::valid ( ) const
inline

Whether the current unit is open.

◆ tinker::v1::EnableEnumBitMask

struct tinker::v1::EnableEnumBitMask
template<class E>
struct tinker::v1::EnableEnumBitMask< E >

Direct mathematical calculation of enum class is prohibited in C++.

Static Public Attributes

static constexpr bool value = false
 

Member Data Documentation

◆ value

template<class E >
constexpr bool tinker::v1::EnableEnumBitMask< E >::value = false
staticconstexpr

◆ tinker::ResourceManagement

class tinker::ResourceManagement

Resource management. Allocates resources in the object constructor and deallocates resources in the object destructor.

To deallocate resource in reverse order of allocation, use named objects.

RcMan foo42{fooData, op};
RcMan bar42{barData, op};
Resource management. Allocates resources in the object constructor and deallocates resources in the o...
Definition: rcman.h:72

To deallocate resource in the same order of allocation, use unnamed objects.

RcMan {fooData, op};
RcMan {barData, op};

Public Member Functions

 ResourceManagement (void(*f)(RcOp), RcOp op)
 
 ~ResourceManagement ()
 

Constructor & Destructor Documentation

◆ ResourceManagement()

tinker::ResourceManagement::ResourceManagement ( void(*)(RcOp f,
RcOp  op 
)
Parameters
fFunction to (de)allocate and/or initialize resource.
opResource operation flag.

◆ ~ResourceManagement()

tinker::ResourceManagement::~ResourceManagement ( )

◆ tinker::calc

struct tinker::calc

Bitmasks for MD.

Public Types

using V0 = Eng
 
using V1 = EngGradVir
 
using V3 = EngAlyz
 
using V4 = EngGrad
 
using V5 = Grad
 
using V6 = GradVir
 

Static Public Attributes

static constexpr int xyz = 0x001
 Use coordinates. More...
 
static constexpr int vel = 0x002
 Use velocities. More...
 
static constexpr int mass = 0x004
 Use mass. More...
 
static constexpr int traj = 0x008
 Use multi-frame trajectory. More...
 
static constexpr int energy = 0x010
 Evaluate energy. More...
 
static constexpr int grad = 0x020
 Evaluate energy gradient. More...
 
static constexpr int virial = 0x040
 Evaluate virial tensor. More...
 
static constexpr int analyz = 0x080
 Evaluate number of interactions. More...
 
static constexpr int md = 0x100
 Run MD simulation. More...
 
static constexpr int vmask = energy + grad + virial + analyz
 Bits mask to clear energy-irrelevant flags. More...
 
static constexpr int v0 = energy
 Similar to Tinker energy routines. Energy only. More...
 
static constexpr int v1 = energy + grad + virial
 
static constexpr int v3 = energy + analyz
 
static constexpr int v4 = energy + grad
 Energy and gradient. More...
 
static constexpr int v5 = grad
 Gradient only. More...
 
static constexpr int v6 = grad + virial
 Gradient and virial. More...
 

Member Typedef Documentation

◆ V0

◆ V1

◆ V3

◆ V4

◆ V5

◆ V6

Member Data Documentation

◆ analyz

constexpr int tinker::calc::analyz = 0x080
staticconstexpr

Evaluate number of interactions.

◆ energy

constexpr int tinker::calc::energy = 0x010
staticconstexpr

Evaluate energy.

◆ grad

constexpr int tinker::calc::grad = 0x020
staticconstexpr

Evaluate energy gradient.

◆ mass

constexpr int tinker::calc::mass = 0x004
staticconstexpr

Use mass.

◆ md

constexpr int tinker::calc::md = 0x100
staticconstexpr

Run MD simulation.

◆ traj

constexpr int tinker::calc::traj = 0x008
staticconstexpr

Use multi-frame trajectory.

◆ v0

constexpr int tinker::calc::v0 = energy
staticconstexpr

Similar to Tinker energy routines. Energy only.

◆ v1

constexpr int tinker::calc::v1 = energy + grad + virial
staticconstexpr

Similar to version 1 Tinker energy routines. Energy, gradient, and virial.

◆ v3

constexpr int tinker::calc::v3 = energy + analyz
staticconstexpr

Similar to version 3 Tinker energy routines. Energy and number of interactions.

◆ v4

constexpr int tinker::calc::v4 = energy + grad
staticconstexpr

Energy and gradient.

◆ v5

constexpr int tinker::calc::v5 = grad
staticconstexpr

Gradient only.

◆ v6

constexpr int tinker::calc::v6 = grad + virial
staticconstexpr

Gradient and virial.

◆ vel

constexpr int tinker::calc::vel = 0x002
staticconstexpr

Use velocities.

◆ virial

constexpr int tinker::calc::virial = 0x040
staticconstexpr

Evaluate virial tensor.

◆ vmask

constexpr int tinker::calc::vmask = energy + grad + virial + analyz
staticconstexpr

Bits mask to clear energy-irrelevant flags.

◆ xyz

constexpr int tinker::calc::xyz = 0x001
staticconstexpr

Use coordinates.

Macro Definition Documentation

◆ TINKER_ENABLE_ENUM_BITMASK

#define TINKER_ENABLE_ENUM_BITMASK (   x)
Value:
template <> \
struct EnableEnumBitMask<x> \
{ \
static constexpr bool value = true; \
}

Explicitly enables mathematical calculation by casting enum class to integer.

Typedef Documentation

◆ RcMan

Type alias.

◆ RcOp

Type alias.

Enumeration Type Documentation

◆ ResourceOperation

enum class tinker::ResourceOperation
strong
Enumerator
DEALLOC 

Deallocates resource.

ALLOC 

Allocates resource.

INIT 

Initializes resource.

Function Documentation

◆ deviceData()

void tinker::deviceData ( RcOp  )

Set up and clean up device environment.

◆ deviceMemoryAllocateBytes()

void tinker::deviceMemoryAllocateBytes ( void **  pptr,
size_t  nbytes 
)

Allocates device pointer.

Parameters
pptrPointer to the device pointer.
nbytesNumber of bytes.

◆ deviceMemoryCheckType()

template<class T >
void tinker::v1::deviceMemoryCheckType ( )

Sanity check.

◆ deviceMemoryCopyBytesAsync()

void tinker::deviceMemoryCopyBytesAsync ( void *  dst,
const void *  src,
size_t  nbytes,
int  queue 
)

Copies data between two pointers on device.

Note
Different from OpenACC copy.
Parameters
dstDestination device pointer.
srcSource device pointer.
nbytesNumber of bytes.
queueOpenACC queue.

◆ deviceMemoryCopyin1dArray()

template<class DT , class ST >
void tinker::v1::deviceMemoryCopyin1dArray ( DT *  dst,
const ST *  src,
size_t  nelem,
int  q 
)

Copies data to 1D array, host to device.

Parameters
dstDestination address.
srcSource address.
nelemNumber of elements to copy to the 1D device array.
qOpenACC queue.

◆ deviceMemoryCopyinBytesAsync()

void tinker::deviceMemoryCopyinBytesAsync ( void *  dst,
const void *  src,
size_t  nbytes,
int  queue 
)

Similar to OpenACC async copyin, copies data from host to device.

Parameters
dstDevice pointer.
srcHost pointer.
nbytesNumber of bytes.
queueOpenACC queue.

◆ deviceMemoryCopyout1dArray()

template<class DT , class ST >
void tinker::v1::deviceMemoryCopyout1dArray ( DT *  dst,
const ST *  src,
size_t  nelem,
int  q 
)

Copies data to 1D array, device to host.

Parameters
dstDestination address.
srcSource address.
nelemNumber of elements to copy to the 1D host array.
qOpenACC queue.

◆ deviceMemoryCopyoutBytesAsync()

void tinker::deviceMemoryCopyoutBytesAsync ( void *  dst,
const void *  src,
size_t  nbytes,
int  queue 
)

Similar to OpenACC async copyout, copies data from device to host.

Parameters
dstHost pointer.
srcDevice pointer.
nbytesNumber of bytes.
queueOpenACC queue.

◆ deviceMemoryDeallocate()

void tinker::deviceMemoryDeallocate ( void *  ptr)

Deallocates device pointer.

Parameters
ptrDevice pointer.

◆ deviceMemoryZeroBytesAsync()

void tinker::deviceMemoryZeroBytesAsync ( void *  dst,
size_t  nbytes,
int  queue 
)

Writes zero bytes on device.

Parameters
dstDevice pointer.
nbytesNumber of bytes.
queueOpenACC queue.

◆ operator&()

template<class E >
constexpr bool tinker::operator& ( lhs,
rhs 
)
constexpr

◆ operator|()

template<class E >
constexpr std::enable_if< EnableEnumBitMask< E >::value, E >::type tinker::operator| ( lhs,
rhs 
)
constexpr

◆ waitFor()

void tinker::waitFor ( int  queue)

Similar to OpenACC wait and CUDA stream synchronize.

Parameters
queueOpenACC queue.

Variable Documentation

◆ rc_flag

int tinker::rc_flag
extern

Global bitmask.