Utilities
Helper functions and utilities
Functions
| Name | Description |
|---|---|
| balanced3 | Factorizes an integer into a balanced 3D lattice (a <= b <= c). |
| load_device_vector_from_file | Reads a device vector from a binary stream. |
| print_device_vector | Prints basic information about a device vector. |
| print_nested_progress | Renders two-level nested progress bars in-place. |
| print_progress | Renders a single-line progress bar. |
| save_device_vector_to_file | Writes a device vector to a binary stream. |
Function Details
balanced3
inline std::tuple<int, int, int> balanced3(int N)
Factorizes an integer into a balanced 3D lattice (a <= b <= c).
-
N - Number of elements to distribute.
- Return
- Tuple of three factors whose product equals N.
load_device_vector_from_file
bool load_device_vector_from_file(std::fstream& fs, thrust::device_vector<float>& vec)
Reads a device vector from a binary stream.
-
fs - Input file stream.
-
vec - Destination vector populated from disk.
- Return
- true on success.
print_device_vector
void print_device_vector(const thrust::device_vector<float>& vec, const string& name)
Prints basic information about a device vector.
-
vec - Vector to inspect.
-
name - Label used in the output.
print_nested_progress
inline void print_nested_progress( int i_current, int i_total, int j_current, int j_total, int width = 30, const std::string& outer_text = "Overall", const std::string& inner_text = "Batch" )
Renders two-level nested progress bars in-place.
-
i_current - Outer loop current iteration.
-
i_total - Outer loop total iterations.
-
j_current - Inner loop current iteration.
-
j_total - Inner loop total iterations.
-
width - Width of each bar in characters.
-
outer_text - Label for the outer bar.
-
inner_text - Label for the inner bar.
print_progress
inline void print_progress(int current, int total, int width = 50)
Renders a single-line progress bar.
-
current - Current progress count.
-
total - Total count representing 100%.
-
width - Width of the bar in characters.
save_device_vector_to_file
bool save_device_vector_to_file(std::fstream& fs, const thrust::device_vector<float>& vec)
Writes a device vector to a binary stream.
-
fs - Output file stream.
-
vec - Vector to serialize.
- Return
- true on success.