ECC-604: Add more operations in threads

This commit is contained in:
Shahram Najm 2018-05-11 11:48:23 +01:00
parent 2a16a080c0
commit 9006a680c3
4 changed files with 43 additions and 20 deletions

View File

@ -7,8 +7,9 @@
#include "grib_api.h"
static size_t NUM_THREADS = 8;
static size_t FILES_PER_ITERATION = 300;
/* These are passed in via argv */
static size_t NUM_THREADS = 0;
static size_t FILES_PER_ITERATION = 0;
static char* INPUT_FILE = NULL;
static int encode_file(char *template_file, char *output_file)
@ -29,6 +30,7 @@ static int encode_file(char *template_file, char *output_file)
long count;
double d,e;
size_t values_len = 0;
size_t str_len = 20;
grib_handle *clone_handle = grib_handle_clone(source_handle);
assert(clone_handle);
@ -44,9 +46,13 @@ static int encode_file(char *template_file, char *output_file)
if (count>100) {e*=10; count=1;}
values[i]=d;
d+=e;
if (d > 10000) d = 0;
count++;
}
GRIB_CHECK(grib_set_string(clone_handle,"stepUnits", "s", &str_len),0);
GRIB_CHECK(grib_set_long(clone_handle, "startStep", 43200), 0);
GRIB_CHECK(grib_set_long(clone_handle, "endStep", 86400), 0);
GRIB_CHECK(grib_set_long(clone_handle, "bitsPerValue", 16),0);
/* set data values */

View File

@ -9,8 +9,9 @@
#include "grib_api.h"
static size_t NUM_THREADS = 8;
static size_t FILES_PER_ITERATION = 300;
/* These are passed in via argv */
static size_t NUM_THREADS = 0;
static size_t FILES_PER_ITERATION = 0;
static char* INPUT_FILE = NULL;
static int encode_file(char *template_file, char *output_file)
@ -31,6 +32,7 @@ static int encode_file(char *template_file, char *output_file)
long count;
double d,e;
size_t values_len = 0;
size_t str_len = 20;
/*GRIB_CHECK(grib_set_long(source_handle, "centre", 250),0);*/
GRIB_CHECK(grib_get_size(source_handle, "values", &values_len),0);
@ -43,9 +45,13 @@ static int encode_file(char *template_file, char *output_file)
if (count>100) {e*=10; count=1;}
values[i]=d;
d+=e;
if (d > 10000) d = 0;
count++;
}
GRIB_CHECK(grib_set_string(source_handle,"stepUnits", "s", &str_len),0);
GRIB_CHECK(grib_set_long(source_handle, "startStep", 43200), 0);
GRIB_CHECK(grib_set_long(source_handle, "endStep", 86400), 0);
GRIB_CHECK(grib_set_long(source_handle, "bitsPerValue", 16),0);
/* set data values */

View File

@ -8,8 +8,9 @@
#include "grib_api.h"
static size_t NUM_THREADS = 8;
static size_t FILES_PER_ITERATION = 300;
/* These are passed in via argv */
static size_t NUM_THREADS = 0;
static size_t FILES_PER_ITERATION = 0;
static char* INPUT_FILE = NULL;
static int decode_file(char *template_file)
@ -29,6 +30,7 @@ static int decode_file(char *template_file)
long count;
double d,e;
size_t values_len = 0;
size_t str_len = 20;
grib_handle *clone_handle = grib_handle_clone(source_handle);
assert(clone_handle);
@ -44,9 +46,13 @@ static int decode_file(char *template_file)
if (count>100) {e*=10; count=1;}
values[i]=d;
d+=e;
if (d > 10000) d = 0;
count++;
}
GRIB_CHECK(grib_set_string(clone_handle,"stepUnits", "s", &str_len),0);
GRIB_CHECK(grib_set_long(clone_handle, "startStep", 43200), 0);
GRIB_CHECK(grib_set_long(clone_handle, "endStep", 86400), 0);
GRIB_CHECK(grib_set_long(clone_handle, "bitsPerValue", 16),0);
/* set data values */

View File

@ -16,22 +16,27 @@ temp_dir=tempdir.${label}
validate()
{
echo "Checking every output file is identical..."
# Get checksum of first file
ck1=`cksum $OUTPUT/output_file_0-0.grib | awk '{print $1}'`
set +x
# Get checksum of all of them and sort unique
res=`cksum $OUTPUT/output_file_* | awk '{print $1}' | sort -u`
set -x
[ "$res" = "2572910830" ]
# Should be the same as the first
[ "$res" = "$ck1" ]
}
NUM_THREADS=8
NUM_ITER=300
NUM_THREADS=6
NUM_ITER=200
OUTPUT=output
input=$ECCODES_SAMPLES_PATH/gg_sfc_grib2.tmpl
# input=$ECCODES_SAMPLES_PATH/gg_sfc_grib1.tmpl
rm -fr $temp_dir
mkdir -p $temp_dir
cd $temp_dir
# Test 01: clone + output
# Test 01: Clone + output
# ------------------------
mkdir -p $OUTPUT
time ${test_dir}/grib_ecc-604-1 par $input $NUM_THREADS $NUM_ITER
@ -44,7 +49,7 @@ mkdir -p $OUTPUT
time ${test_dir}/grib_ecc-604-2 par $input $NUM_THREADS $NUM_ITER
validate
# Test 03: clone + no output
# Test 03: Clone + no output
# ---------------------------
rm -fr $OUTPUT
time ${test_dir}/grib_ecc-604-3 par $input $NUM_THREADS $NUM_ITER