First build version.

master
Julian M. Kunkel 2019-08-20 15:54:18 +01:00
commit 503a66009d
6 changed files with 140 additions and 0 deletions

5
emulation/ngi.c 100644
View File

@ -0,0 +1,5 @@
#include <ngi.h>
void server_reduce(FILE * file, size_t off, size_t size){
}

9
emulation/ngi.h 100644
View File

@ -0,0 +1,9 @@
#ifndef NGI_H_
#define NGI_H_
#include <stdlib.h>
#include <stdio.h>
void server_reduce(FILE * file, size_t off, size_t size);
#endif

32
test/data-gen.c 100644
View File

@ -0,0 +1,32 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <stdint.h>
#include <stdbool.h>
#include <float.h>
/*
* Generate test data
*/
// generate some data such that we can reduce it later
void prepare_data(int size){
float * data = malloc(size * sizeof(float));
for(int i=0; i < size; i++){
data[i] = (float) i;
}
FILE * file = fopen("data.bin", "wb");
fwrite(data, size*sizeof(float), 1, file);
fclose(file);
free(data);
}
int main(){
int size = 100;
prepare_data(size);
return 0;
}

39
test/reduce-ngi.c 100644
View File

@ -0,0 +1,39 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <stdint.h>
#include <stdbool.h>
#include <float.h>
#include <ngi.h>
/*
* This application applies the reduce operation using the server-side compute using NGI
*/
// read the data and reduce it
void reduce_data(int size){
float * data = malloc(size * sizeof(float));
FILE * file = fopen("data.bin", "rb");
fread(data, size*sizeof(float), 1, file);
fclose(file);
server_reduce(file, 0, size*sizeof(float));
float mx = FLT_MIN;
for(int i=0; i < size; i++){
mx = data[i] > mx ? data[i]: mx;
}
free(data);
printf("Maximum: %f\n", mx);
}
int main(){
int size = 100;
reduce_data(size);
return 0;
}

View File

@ -0,0 +1,36 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <stdint.h>
#include <stdbool.h>
#include <float.h>
/*
* This application shows a traditional reduce operation
*/
// read the data and reduce it
void reduce_data(int size){
float * data = malloc(size * sizeof(float));
FILE * file = fopen("data.bin", "rb");
fread(data, size*sizeof(float), 1, file);
fclose(file);
float mx = FLT_MIN;
for(int i=0; i < size; i++){
mx = data[i] > mx ? data[i]: mx;
}
free(data);
printf("Maximum: %f\n", mx);
}
int main(){
int size = 100;
reduce_data(size);
return 0;
}

19
test/run.sh 100755
View File

@ -0,0 +1,19 @@
#!/bin/bash -e
gcc -Wall -Wextra data-gen.c -o data-gen -g3
gcc -Wall -Wextra reduce-traditional.c -o reduce-traditional -g3
# Build NGI lib
gcc -Wall -Wextra ../emulation/ngi.c -shared -fpic -o libngi.so -g3 -I../emulation/
# Build client application
gcc -Wall -Wextra reduce-ngi.c -o reduce-ngi -g3 -I../emulation/ -L. -l ngi -Wl,-rpath=$PWD
echo "Data generation"
./data-gen
echo "Executing traditional"
./reduce-traditional
echo "Executing NGI"
./reduce-ngi