mirror of https://github.com/ecmwf/eccodes.git
ECC-604: Add more operations in threads
This commit is contained in:
parent
2a16a080c0
commit
9006a680c3
|
@ -7,9 +7,10 @@
|
|||
|
||||
#include "grib_api.h"
|
||||
|
||||
static size_t NUM_THREADS = 8;
|
||||
static size_t FILES_PER_ITERATION = 300;
|
||||
static char* INPUT_FILE = NULL;
|
||||
/* 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)
|
||||
{
|
||||
|
@ -28,7 +29,8 @@ static int encode_file(char *template_file, char *output_file)
|
|||
int i;
|
||||
long count;
|
||||
double d,e;
|
||||
size_t values_len= 0;
|
||||
size_t values_len = 0;
|
||||
size_t str_len = 20;
|
||||
|
||||
grib_handle *clone_handle = grib_handle_clone(source_handle);
|
||||
assert(clone_handle);
|
||||
|
@ -44,10 +46,14 @@ 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_long(clone_handle,"bitsPerValue",16),0);
|
||||
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 */
|
||||
GRIB_CHECK(grib_set_double_array(clone_handle,"values",values,values_len),0);
|
||||
|
|
|
@ -9,9 +9,10 @@
|
|||
|
||||
#include "grib_api.h"
|
||||
|
||||
static size_t NUM_THREADS = 8;
|
||||
static size_t FILES_PER_ITERATION = 300;
|
||||
static char* INPUT_FILE = NULL;
|
||||
/* 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)
|
||||
{
|
||||
|
@ -30,7 +31,8 @@ static int encode_file(char *template_file, char *output_file)
|
|||
int i;
|
||||
long count;
|
||||
double d,e;
|
||||
size_t values_len= 0;
|
||||
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,10 +45,14 @@ 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_long(source_handle,"bitsPerValue",16),0);
|
||||
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 */
|
||||
GRIB_CHECK(grib_set_double_array(source_handle,"values",values,values_len),0);
|
||||
|
|
|
@ -8,9 +8,10 @@
|
|||
|
||||
#include "grib_api.h"
|
||||
|
||||
static size_t NUM_THREADS = 8;
|
||||
static size_t FILES_PER_ITERATION = 300;
|
||||
static char* INPUT_FILE = NULL;
|
||||
/* 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)
|
||||
{
|
||||
|
@ -28,7 +29,8 @@ static int decode_file(char *template_file)
|
|||
int i;
|
||||
long count;
|
||||
double d,e;
|
||||
size_t values_len= 0;
|
||||
size_t values_len = 0;
|
||||
size_t str_len = 20;
|
||||
|
||||
grib_handle *clone_handle = grib_handle_clone(source_handle);
|
||||
assert(clone_handle);
|
||||
|
@ -44,10 +46,14 @@ 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_long(clone_handle,"bitsPerValue",16),0);
|
||||
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 */
|
||||
GRIB_CHECK(grib_set_double_array(clone_handle,"values",values,values_len),0);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue