|
OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
|
#include <FieldArray.h>
Public Member Functions | |
| FieldArray ()=default | |
| ~FieldArray () | |
| FieldArray (const FieldArray &)=delete | |
| FieldArray & | operator= (const FieldArray &)=delete |
| std::size_t | size () const |
| Number of samples. Zero for an array that has not been filled. | |
| bool | empty () const |
| double | operator[] (std::size_t i) const |
| const double * | data () const |
| bool | anyNonZero (std::size_t begin, std::size_t end) const |
| bool | isMapped () const |
| void | allocate (std::size_t n) |
| double * | mutableData () |
| bool | tryMap (const std::string &filename, const std::string &dataset, std::size_t expectedSamples, std::string &why) |
| void | reset () |
| Release the buffer or the mapping. | |
Private Attributes | |
| const double * | data_m = nullptr |
| what operator[] reads; into owned_m or the mapping | |
| std::size_t | size_m = 0 |
| samples, not bytes | |
| std::vector< double > | owned_m |
| used when not mapped | |
| void * | mapping_m = nullptr |
| page-aligned mmap base, null when not mapped | |
| std::size_t | mapBytes_m = 0 |
| length passed to mmap, for munmap | |
Definition at line 38 of file FieldArray.h.
|
default |
|
inline |
Definition at line 41 of file FieldArray.h.
References reset().

|
delete |
| void FieldArray::allocate | ( | std::size_t | n | ) |
Allocate a writable buffer of n samples, zero filled. Releases any previous contents, including a mapping.
Definition at line 37 of file FieldArray.cpp.
References data_m, owned_m, reset(), and size_m.
Referenced by _FM3DH5Block::readMap(), _FM3DH5Block_nonscale::readMap(), and _FM3DMagnetoStaticH5Block::readMap().

| bool FieldArray::anyNonZero | ( | std::size_t | begin, |
| std::size_t | end | ||
| ) | const |
True if any sample in [begin, end) is nonzero; NaN counts as nonzero. For a mapped array the range is read with sequential readahead: this is a one-off pass, not the random gather of tracking.
Definition at line 138 of file FieldArray.cpp.
References begin(), data_m, end(), mapping_m, and size_m.
Referenced by _FM3DH5BlockBase::anyNonZero().

|
inline |
Definition at line 54 of file FieldArray.h.
References data_m.
|
inline |
Definition at line 48 of file FieldArray.h.
References size_m.
Referenced by _FM3DH5Block_nonscale::freeMap(), _FM3DMagnetoStaticH5Block::freeMap(), _FM3DH5Block_nonscale::readMap(), and _FM3DMagnetoStaticH5Block::readMap().
|
inline |
True when the samples are a view of a mapped file rather than our own buffer. Callers that modify the samples in place must check this.
Definition at line 63 of file FieldArray.h.
References mapping_m.
|
inline |
Writable pointer, for handing to a reader. Null when the array is mapped; a mapped array is read-only by construction.
Definition at line 71 of file FieldArray.h.
References owned_m.
Referenced by _FM3DH5Block::readMap(), _FM3DH5Block_nonscale::readMap(), and _FM3DMagnetoStaticH5Block::readMap().
|
delete |
|
inline |
Read access. This is the hot path: one load through a pointer the caller already has, exactly as indexing a vector was.
Definition at line 52 of file FieldArray.h.
References data_m.
| void FieldArray::reset | ( | ) |
Release the buffer or the mapping.
Definition at line 44 of file FieldArray.cpp.
References data_m, mapBytes_m, mapping_m, owned_m, and size_m.
Referenced by allocate(), _FM3DH5Block::freeMap(), _FM3DH5Block_nonscale::freeMap(), _FM3DMagnetoStaticH5Block::freeMap(), _FM3DH5Block::readMap(), _FM3DMagnetoStaticH5Block::readMap(), tryMap(), _FM3DH5BlockBase::tryMapComponents(), and ~FieldArray().
|
inline |
Number of samples. Zero for an array that has not been filled.
Definition at line 47 of file FieldArray.h.
References size_m.
Referenced by _FM3DH5BlockBase::anyNonZero().
| bool FieldArray::tryMap | ( | const std::string & | filename, |
| const std::string & | dataset, | ||
| std::size_t | expectedSamples, | ||
| std::string & | why | ||
| ) |
Try to back this array by a read-only mapping of one dataset of an HDF5 file. Returns false, leaving the array untouched, if the file cannot be opened, the dataset is absent, or its layout is not one we can map directly. why receives a short reason on failure, for the log.
Definition at line 55 of file FieldArray.cpp.
References data_m, mapBytes_m, mapping_m, reset(), and size_m.

|
private |
what operator[] reads; into owned_m or the mapping
Definition at line 86 of file FieldArray.h.
Referenced by allocate(), anyNonZero(), data(), operator[](), reset(), and tryMap().
|
private |
length passed to mmap, for munmap
Definition at line 90 of file FieldArray.h.
|
private |
page-aligned mmap base, null when not mapped
Definition at line 89 of file FieldArray.h.
Referenced by anyNonZero(), isMapped(), reset(), and tryMap().
|
private |
used when not mapped
Definition at line 88 of file FieldArray.h.
Referenced by allocate(), mutableData(), and reset().
|
private |
samples, not bytes
Definition at line 87 of file FieldArray.h.
Referenced by allocate(), anyNonZero(), empty(), reset(), size(), and tryMap().