ThreadedStorage
full name: tenpy.tools.cache.ThreadedStorage
parent module:
tenpy.tools.cache
type: class
Inheritance Diagram
Methods
|
|
Close opened files, free memory and clean up temporary files/directories. |
|
Interface for cleaning up a previously saved data from disk in subclasses. |
|
|
Interface for loading data from disk in subclasses. |
|
Setup and start a |
Interface for preloading data into the given dictionary into. |
|
|
Interface for saving data to disk in subclasses. |
Create another instance of the same class saving in a subdirectory/subgroup. |
Class Attributes and Properties
Whether the storage is actually kept in memory, instead of saving to disk. |
- class tenpy.tools.cache.ThreadedStorage(worker, disk_storage)[source]
Bases:
Storage
Wrapper around a
Storage
(or subclass) with thread-parallelization.Use thread-based parallelism to avoid delays from disk input/output when caching.
Note
If you’re running TeNPy on a cluster, you should probably adjust the number of OMP threads, e.g.
export OMP_NUM_THREADS=3
in your cluster submission scripts to one less thread, since this class adds an extra thread waiting for disk I/O.- Parameters:
worker (
Group
) – The hdf5 group in which data will be saved usingsave_to_hdf5()
under the specified keys.disk_storage (
Storage
) – Instance of one of the other storage classes to wrap around.
- trivial = True
Whether the storage is actually kept in memory, instead of saving to disk.
- classmethod open(disk_storage, max_queue_size=2)[source]
Setup and start a
Worker
subthread.- Parameters:
disk_storage (
Storage
) – Instance with methods for the actual disk I/O handling.
- subcontainer(name)[source]
Create another instance of the same class saving in a subdirectory/subgroup.
This method allows multiple
DictCache
instance re-using open resources. Subcontainers will explicitly be closed when any of the parent containers (on which subcontainer() was called) is closed.
- preload(key)[source]
Interface for preloading data into the given dictionary into.
Only overridden in
ThreadedStorage
for thread-parallelized pre-loading; in other cases it does nothing.