X-Git-Url: https://git.auder.net/assets/icon_infos.svg?a=blobdiff_plain;f=old_C_code%2Fstage1%2Ftest%2FMPI_Communication%2Ft.pack.c;fp=old_C_code%2Fstage1%2Ftest%2FMPI_Communication%2Ft.pack.c;h=6692af5970e0a48a483e3bc14f127d12ea584d19;hb=7709d507dfab9256a401f2c77ced7bc70d90fec3;hp=0000000000000000000000000000000000000000;hpb=38aef1cbef037257bf03dd1e65fbb682a32e3f2c;p=epclust.git diff --git a/old_C_code/stage1/test/MPI_Communication/t.pack.c b/old_C_code/stage1/test/MPI_Communication/t.pack.c new file mode 100644 index 0000000..6692af5 --- /dev/null +++ b/old_C_code/stage1/test/MPI_Communication/t.pack.c @@ -0,0 +1,106 @@ +#include "lut.h" +#include +#include "MPI_Communication/pack.h" +#include "Util/types.h" +#include +#include "Util/utils.h" + +// Work_t +void t_pack1() +{ + Work_t* work = (Work_t*)malloc(sizeof(Work_t)); + work->inputFileName = "../tdata/inputTest.bin"; + work->nbSeries = 5; + uint32_t ranks[] = + { + 0, + 12*65536 + 3*256+11, + 32*16777216 + 2*65536 + 17*256 + 42, + 123, + 51*16777216 + 77*65536 + 0*256 + 10 + }; + work->ranks = ranks; + work->nbClusters = 15; + work->clustOnMedoids = 0; + work->p_for_dissims = 1; + + // Hard-coded expected packed work + unsigned char expectedPackedWork[] = + { + // --> ../tdata/inputTest.bin + 46,46,47,100,97,116,97,47,105,110,112,117,116,84,101,115,116,46,98,105,110, + // continue with 256 - strlen("../tdata/inputTest.bin") zeros... + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + // --> 5, {ranks}+0,0, 15, 0 on 4-bytes integers little-endian + 5,0,0,0, 0,0,0,0, 11,3,12,0, 42,17,2,32, 123,0,0,0, 10,0,77,51, 0,0,0,0, 0,0,0,0, + 15,0,0,0, 0,0,0,0, 1,0,0,0 + }; + + uint32_t nbSeriesInChunk = 7; + uint32_t work_message_length = get_packedWork_length(nbSeriesInChunk); + unsigned char packedWork[work_message_length]; + pack_work(work, nbSeriesInChunk, packedWork); + + for (uint32_t i=0; inbClusters = 5; + uint32_t medoids_ID[] = + { + 15*65536 + 13*256+11, + 11, + 17*16777216 + 0*65536 + 14*256 + 42, + 123*65536 + 0*256 + 7, + 51*16777216 + 0*65536 + 0*256 + 10 + }; + result->medoids_ID = medoids_ID; + uint32_t medoids_ranks[] = + { + 5*65536 + 32, + 11*256 + 4, + 23*16777216 + 42, + 35*65536 + 5*256 + 77, + 1*16777216 + 1*65536 + 1*256 + 10 + }; + result->medoids_ranks = medoids_ranks; + + // Hard-coded expected result + unsigned char expectedPackedResult[] = + { + // 5, {medoids_ID}, {medoids_ranks} + 5,0,0,0, + 11,13,15,0, 11,0,0,0, 42,14,0,17, 7,0,123,0, 10,0,0,51, + 32,0,5,0, 4,11,0,0, 42,0,0,23, 77,5,35,0, 10,1,1,1 + }; + + uint32_t result_message_length = get_packedResult_length(nbClusters); + unsigned char packedResult[result_message_length]; + pack_result(result, packedResult); + + for (uint32_t i=0; i