First build version.
This commit is contained in:
commit
503a66009d
|
@ -0,0 +1,5 @@
|
|||
#include <ngi.h>
|
||||
|
||||
void server_reduce(FILE * file, size_t off, size_t size){
|
||||
|
||||
}
|
|
@ -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
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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
|
Loading…
Reference in New Issue