Vlasiator ebf0dd394 on dev (v5.4.0 + 1054 commits)
Loading...
Searching...
No Matches
compression.h
Go to the documentation of this file.
1#pragma once
2/*
3 * This file is part of Vlasiator.
4 * Copyright 2010-2024 Finnish Meteorological Institute
5 *
6 * For details of usage, see the COPYING file and read the "Rules of the Road"
7 * at http://www.physics.helsinki.fi/vlasiator/
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 */
23
24#include "../definitions.h"
25#include "../logger.h"
26#include "../mpiconversion.h"
27#include "../object_wrapper.h"
28#include "../parameters.h"
29#include "../readparameters.h"
30#include "compression_tools.h"
32#include <cstdint>
33
34// External API for Vlasiator
35namespace ASTERIX {
36
37/*
38 Compresses and reconstructs the VDFs using an Asterix Method. The original
39 VDFs are overwritten.
40
41 mpiGrid: Grid with all local spatial cells
42 number_of_spatial_cells:
43 Used to reduce the global comrpession achieved
44 update_weights:
45 If the flag is set to true the method will create a feedback loop where
46 the weights of the MLP are stored and then re used for the next training
47 session. This will? lead to faster convergence down the road. If the flag is
48 set to false then every training session starts from randomized weights. I
49 think this is what ML people call transfer learning (together with freezing
50 and adding extra neuron which we do not do here).
51*/
52void compress_vdfs(dccrg::Dccrg<SpatialCell, dccrg::Cartesian_Geometry>& mpiGrid, const std::vector<CellID>& local_cells,
53 P::ASTERIX_COMPRESSION_METHODS method, bool update_weights,std::vector<std::vector<char>>&mpl_bytes,uint32_t downsampling_factor=1);
54
55/*
56 Compresses the VDFs using an Asterix Method but does not overwrite them. This
57 method is used to update the weights of the MLP at regular intervals without
58 actually modifying the VDFs.
59
60 mpiGrid: Grid with all local spatial cells
61
62*/
63void compress_vdfs_transfer_learning(dccrg::Dccrg<SpatialCell, dccrg::Cartesian_Geometry>& mpiGrid);
64
65std::size_t probe_network_size_in_bytes(dccrg::Dccrg<SpatialCell, dccrg::Cartesian_Geometry>& mpiGrid,
66 size_t number_of_spatial_cells);
67
68// Function to decompress a compressed array of doubles using ZFP
69std::vector<double> decompressArrayDouble(char* compressedData, size_t compressedSize, size_t arraySize, double tol);
70
71// Function to decompress a compressed array of floats using ZFP
72std::vector<float> decompressArrayFloat(char* compressedData, size_t compressedSize, size_t arraySize, float tol);
73
74} // namespace ASTERIX
std::vector< double > decompressArrayDouble(char *compressedData, size_t compressedSize, size_t arraySize, double tol)
std::vector< float > decompressArrayFloat(char *compressedData, size_t compressedSize, size_t arraySize, float tol)
void compress_vdfs_transfer_learning(dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid)
std::size_t probe_network_size_in_bytes(dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, size_t number_of_spatial_cells)
void compress_vdfs(dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const std::vector< CellID > &local_cells, P::ASTERIX_COMPRESSION_METHODS method, bool update_weights, std::vector< std::vector< char > > &mpl_bytes, uint32_t downsampling_factor=1)
ASTERIX_COMPRESSION_METHODS
Definition parameters.h:249