fix accent (TODO: fix gitweb...)
[ppam-mpi.git] / code / src / MPI_Communication / pack.c
... / ...
CommitLineData
1#include <stdlib.h>
2#include "Util/types.h"
3#include "Util/utils.h"
4
5// serialize a Work_t object into a bytes string
6void pack_work(Work_t* work, uint32_t nbSeriesInChunk, Byte* packedWork)
7{
8 uint32_t index = 0;
9
10 while (work->inputFileName[index] != 0)
11 {
12 packedWork[index] = work->inputFileName[index];
13 index++;
14 }
15 // complete with zeros
16 while (index < NCHAR_FNAME)
17 packedWork[index++] = 0;
18
19 write_int(work->nbSeries, 4, packedWork + index);
20 index += 4;
21
22 for (uint32_t i = 0; i < work->nbSeries; i++)
23 {
24 write_int(work->ranks[i], 4, packedWork + index);
25 index += 4;
26 }
27 // complete with zeros
28 for (uint32_t i = 0; i < nbSeriesInChunk - work->nbSeries; i++)
29 {
30 write_int(0, 4, packedWork + index);
31 index += 4;
32 }
33
34 write_int(work->nbClusters, 4, packedWork + index);
35 index += 4;
36 write_int(work->clustOnMedoids, 4, packedWork + index);
37 index += 4;
38 write_int(work->p_for_dissims, 4, packedWork + index);
39}
40
41// serialize a Result_t object into a bytes string
42void pack_result(Result_t* result, Byte* packedResult)
43{
44 uint32_t index = 0;
45
46 write_int(result->nbClusters, 4, packedResult);
47 index += 4;
48
49 for (uint32_t i = 0; i < result->nbClusters; i++)
50 {
51 write_int(result->medoids_ID[i], 4, packedResult + index);
52 index += 4;
53 }
54
55 for (uint32_t i = 0; i < result->nbClusters; i++)
56 {
57 write_int(result->medoids_ranks[i], 4, packedResult + index);
58 index += 4;
59 }
60}