mirror of https://github.com/ecmwf/eccodes.git
SUP-3134: Code contribution to improve performance of ecCodes on NEC
This commit is contained in:
commit
d3d2c94448
|
@ -10,16 +10,15 @@
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Enrico Fucile - 19.06.2007 *
|
* Enrico Fucile - 19.06.2007 *
|
||||||
* EXPERIMENTAL CODE - NOT FULLY TESTED *
|
* *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
int grib_decode_long_array(const unsigned char* p, long* bitp, long bitsPerValue,
|
int grib_decode_long_array(const unsigned char* p, long* bitp, long bitsPerValue,
|
||||||
size_t n_vals, long* val)
|
size_t n_vals, long* val)
|
||||||
{
|
{
|
||||||
long i = 0;
|
long i = 0;
|
||||||
unsigned long lvalue = 0;
|
unsigned long lvalue = 0;
|
||||||
|
|
||||||
/* SUP-3196: Thanks to Daniel Tameling */
|
/* if (bitsPerValue % 8) { */
|
||||||
if (bitsPerValue % 8 || (*bitp & 7)) {
|
if (bitsPerValue % 8 || (*bitp & 7)) {
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for (i = 0; i < n_vals; i++) {
|
for (i = 0; i < n_vals; i++) {
|
||||||
|
@ -55,6 +54,7 @@ int grib_decode_long_array(const unsigned char* p, long* bitp, long bitsPerValue
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int grib_decode_double_array(const unsigned char* p, long* bitp, long bitsPerValue,
|
int grib_decode_double_array(const unsigned char* p, long* bitp, long bitsPerValue,
|
||||||
double reference_value, double s, double d,
|
double reference_value, double s, double d,
|
||||||
size_t n_vals, double* val)
|
size_t n_vals, double* val)
|
||||||
|
@ -96,14 +96,12 @@ int grib_decode_double_array(const unsigned char* p, long* bitp, long bitsPerVal
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int grib_decode_double_array_complex(const unsigned char* p, long* bitp, long nbits, double reference_value,
|
int grib_decode_double_array_complex(const unsigned char* p, long* bitp, long nbits, double reference_value, double s, double* d, size_t size, double* val)
|
||||||
double s, double* d, size_t size, double* val)
|
|
||||||
{
|
{
|
||||||
return GRIB_NOT_IMPLEMENTED;
|
return GRIB_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
int grib_encode_double_array(size_t n_vals, const double* val, long bits_per_value, double reference_value,
|
int grib_encode_double_array(size_t n_vals, const double* val, long bits_per_value, double reference_value, double d, double divisor, unsigned char* p, long* off)
|
||||||
double d, double divisor, unsigned char* p, long* off)
|
|
||||||
{
|
{
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
unsigned long unsigned_val = 0;
|
unsigned long unsigned_val = 0;
|
||||||
|
@ -115,17 +113,50 @@ int grib_encode_double_array(size_t n_vals, const double* val, long bits_per_val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (i = 0; i < n_vals; i++) {
|
if (bits_per_value == 16 && !((uint64_t)p&3)) {
|
||||||
int blen = 0;
|
uint32_t *encoded4byte = (uint32_t *) p;
|
||||||
blen = bits_per_value;
|
uint32_t tmp;
|
||||||
unsigned_val = (unsigned long)((((val[i] * d) - reference_value) * divisor) + 0.5);
|
unsigned long unsigned_val2 = 0;
|
||||||
while (blen >= 8) {
|
for(i = 0; i < n_vals - 1; i+=2){
|
||||||
blen -= 8;
|
unsigned_val = (unsigned long)((((val[i]*d)-reference_value)*divisor)+0.5);
|
||||||
*encoded = (unsigned_val >> blen);
|
unsigned_val2 = (unsigned long)((((val[i+1]*d)-reference_value)*divisor)+0.5);
|
||||||
encoded++;
|
tmp = (unsigned_val2 & 0xff);
|
||||||
*off += 8;
|
tmp = (tmp << 8) + (unsigned_val2 >> 8 & 0xff);
|
||||||
}
|
tmp = (tmp << 8) + (unsigned_val & 0xff);
|
||||||
|
tmp = (tmp << 8) + ((unsigned_val >> 8) & 0xff);
|
||||||
|
*encoded4byte = tmp;
|
||||||
|
encoded4byte++;
|
||||||
|
*off+=32;
|
||||||
}
|
}
|
||||||
|
/* remainder */
|
||||||
|
if (n_vals % 2) {
|
||||||
|
int blen = 0;
|
||||||
|
i = n_vals-1;
|
||||||
|
encoded = (unsigned char *) encoded4byte;
|
||||||
|
blen = bits_per_value;
|
||||||
|
unsigned_val = (unsigned long)((((val[i]*d)-reference_value)*divisor)+0.5);
|
||||||
|
while(blen >= 8)
|
||||||
|
{
|
||||||
|
blen -= 8;
|
||||||
|
*encoded = (unsigned_val >> blen);
|
||||||
|
encoded++;
|
||||||
|
*off+=8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (i = 0; i < n_vals; i++) {
|
||||||
|
int blen = 0;
|
||||||
|
blen = bits_per_value;
|
||||||
|
unsigned_val = (unsigned long)((((val[i] * d) - reference_value) * divisor) + 0.5);
|
||||||
|
while (blen >= 8) {
|
||||||
|
blen -= 8;
|
||||||
|
*encoded = (unsigned_val >> blen);
|
||||||
|
encoded++;
|
||||||
|
*off += 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return GRIB_SUCCESS;
|
return GRIB_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue