shibatch / sleef

SIMD Library for Evaluating Elementary Functions, vectorized libm and DFT
https://sleef.org
Boost Software License 1.0
666 stars 133 forks source link

[SVE] Remove all instances of sizeless structures #309

Closed shibatch closed 12 months ago

shibatch commented 4 years ago

We are going to modify the code base so that it will comply with the latest ACLE SVE specification. Since the sizeless structures are removed from the ACLE, we need to change the way certain data structures (e.g. vdouble2) are handled. We are going to use setter and getter fuctions to substitute and refer to those variables.

As for vdouble2 data type, we are going to add 5 setter/getter functions like the following.

typedef struct {
  vdouble x, y;
} vdouble2;

static vdouble  vd2getx_vd_vd2(vdouble2 v) { return v.x; }
static vdouble  vd2gety_vd_vd2(vdouble2 v) { return v.y; }
static vdouble2 vd2setxy_vd2_vd_vd(vdouble x, vdouble y)  {
  vdouble2 v; v.x = x; v.y = y; return v;
}
static vdouble2 vd2setx_vd2_vd2_vd(vdouble2 v, vdouble d) { v.x = d; return v; }
static vdouble2 vd2sety_vd2_vd2_vd(vdouble2 v, vdouble d) { v.y = d; return v; }

The SVE version of the above functions is as follows.

typedef svfloat64x2_t vdouble2;
static vdouble  vd2getx_vd_vd2(vdouble2 v) { return svget2_f64(v, 0); }
static vdouble  vd2gety_vd_vd2(vdouble2 v) { return svget2_f64(v, 1); }
static vdouble2 vd2setxy_vd2_vd_vd(vdouble x, vdouble y)  { return svcreate2_f64(x, y); }
static vdouble2 vd2setx_vd2_vd2_vd(vdouble2 v, vdouble d) { return svset2_f64(v, 0, d); }
static vdouble2 vd2sety_vd2_vd2_vd(vdouble2 v, vdouble d) { return svset2_f64(v, 1, d); }

We will change the handling of the following data types as well.

fpetrogalli commented 4 years ago

Hi @shibatch ,

thank you for working on this.

Your proposal makes sense to me and is in line with what I was thinking was needed.

I have a question about:

we are going to add 5 setter/getter functions like the following

Am I correct thinking that with what you propose, adding the getters and setters is needed for all the helper header files, and not just the SVE one?

Francesco

shibatch commented 4 years ago

We can implement the setter and getter functions inside the helper file for SVE only. As for the other vector extensions, we can write them in the current position where the structs are defined.

fpetrogalli commented 4 years ago

oh, I see. So that you override the common getter and setter with conditional compilation when compiling for SVE. Makes sense! Thanks you. I am looking forward for the PR! :)

Francesco

blapie commented 12 months ago

This was solved by #310