use plain "restrict"

configure changes this to __restrict__ for us, if the compiler supports
it
This commit is contained in:
John Cupitt 2013-12-03 08:53:36 +00:00
parent 0f7e938aef
commit 0bb052414a
20 changed files with 142 additions and 132 deletions

22
TODO
View File

@ -1,12 +1,26 @@
- do morph quickly as simple wrappers over the vips7 operations
- do restrict on some more packages, we've just done arithmetic so far
- do some more packages, we've just done arithmetic so far
how about avg? do we need -ffast-math to vec that? how about avg? do we need -ffast-math to vec that?
yes we do, though it doesn't seem any faster yes we do, though it doesn't seem any faster
perhaps because it only vecs the innermost loop across bands and it's
too short to trigger the vec code
try swapping the loops over ... inner loop across width, outer across
bands
but then we'd have an unknown stride
need to special-case 1 band and 3 band images
or use orc to gen code at operator build
does this mean we should revert the removal of orc from arithmetic?
not seen more than x2 from auto-vec of abs(), perhaps the bool ops? not seen more than x2 from auto-vec of abs(), perhaps the bool ops?
@ -25,14 +39,10 @@
maybe precision is a dumb thing maybe precision is a dumb thing
- do morph quickly as simple wrappers over the vips7 operations
- support --strip for other writers - support --strip for other writers
- vipsthumbnail could shrink-on-load openslide and pyr tiff as well? - vipsthumbnail could shrink-on-load openslide and pyr tiff as well?
- look again at gcc auto-vectorisation, what would we need to do to use this?
- how about - how about
top -d 0.01 | grep vips > log top -d 0.01 | grep vips > log

View File

@ -93,8 +93,8 @@ vips_abs_build( VipsObject *object )
/* Integer abs operation: just test and negate. /* Integer abs operation: just test and negate.
*/ */
#define ABS_INT( TYPE ) { \ #define ABS_INT( TYPE ) { \
TYPE * __restrict__ p = (TYPE *) in[0]; \ TYPE * restrict p = (TYPE *) in[0]; \
TYPE * __restrict__ q = (TYPE *) out; \ TYPE * restrict q = (TYPE *) out; \
int x; \ int x; \
\ \
for( x = 0; x < sz; x++ ) \ for( x = 0; x < sz; x++ ) \
@ -104,8 +104,8 @@ vips_abs_build( VipsObject *object )
/* Float abs operation: call fabs(). /* Float abs operation: call fabs().
*/ */
#define ABS_FLOAT( TYPE ) { \ #define ABS_FLOAT( TYPE ) { \
TYPE * __restrict__ p = (TYPE *) in[0]; \ TYPE * restrict p = (TYPE *) in[0]; \
TYPE * __restrict__ q = (TYPE *) out; \ TYPE * restrict q = (TYPE *) out; \
int x; \ int x; \
\ \
for( x = 0; x < sz; x++ ) \ for( x = 0; x < sz; x++ ) \
@ -118,8 +118,8 @@ vips_abs_build( VipsObject *object )
#ifdef HAVE_HYPOT #ifdef HAVE_HYPOT
#define ABS_COMPLEX( TYPE ) { \ #define ABS_COMPLEX( TYPE ) { \
TYPE * __restrict__ p = (TYPE *) in[0]; \ TYPE * restrict p = (TYPE *) in[0]; \
TYPE * __restrict__ q = (TYPE *) out; \ TYPE * restrict q = (TYPE *) out; \
int x; \ int x; \
\ \
for( x = 0; x < sz; x++ ) { \ for( x = 0; x < sz; x++ ) { \
@ -131,8 +131,8 @@ vips_abs_build( VipsObject *object )
#else /*HAVE_HYPOT*/ #else /*HAVE_HYPOT*/
#define ABS_COMPLEX( TYPE ) { \ #define ABS_COMPLEX( TYPE ) { \
TYPE * __restrict__ p = (TYPE *) in[0]; \ TYPE * restrict p = (TYPE *) in[0]; \
TYPE * __restrict__ q = (TYPE *) out; \ TYPE * restrict q = (TYPE *) out; \
int x; \ int x; \
\ \
for( x = 0; x < sz; x++ ) { \ for( x = 0; x < sz; x++ ) { \

View File

@ -90,9 +90,9 @@ typedef VipsBinaryClass VipsAddClass;
G_DEFINE_TYPE( VipsAdd, vips_add, VIPS_TYPE_BINARY ); G_DEFINE_TYPE( VipsAdd, vips_add, VIPS_TYPE_BINARY );
#define LOOP( IN, OUT ) { \ #define LOOP( IN, OUT ) { \
IN * __restrict__ left = (IN *) in[0]; \ IN * restrict left = (IN *) in[0]; \
IN * __restrict__ right = (IN *) in[1]; \ IN * restrict right = (IN *) in[1]; \
OUT * __restrict__ q = (OUT *) out; \ OUT * restrict q = (OUT *) out; \
\ \
for( x = 0; x < sz; x++ ) \ for( x = 0; x < sz; x++ ) \
q[x] = left[x] + right[x]; \ q[x] = left[x] + right[x]; \

View File

@ -108,18 +108,18 @@ vips_boolean_build( VipsObject *object )
} }
#define LOOP( TYPE, OP ) { \ #define LOOP( TYPE, OP ) { \
TYPE * __restrict__ left = (TYPE *) in[0]; \ TYPE * restrict left = (TYPE *) in[0]; \
TYPE * __restrict__ right = (TYPE *) in[1]; \ TYPE * restrict right = (TYPE *) in[1]; \
TYPE * __restrict__ q = (TYPE *) out; \ TYPE * restrict q = (TYPE *) out; \
\ \
for( x = 0; x < sz; x++ ) \ for( x = 0; x < sz; x++ ) \
q[x] = left[x] OP right[x]; \ q[x] = left[x] OP right[x]; \
} }
#define FLOOP( TYPE, OP ) { \ #define FLOOP( TYPE, OP ) { \
TYPE * __restrict__ left = (TYPE *) in[0]; \ TYPE * restrict left = (TYPE *) in[0]; \
TYPE * __restrict__ right = (TYPE *) in[1]; \ TYPE * restrict right = (TYPE *) in[1]; \
int * __restrict__ q = (int *) out; \ int * restrict q = (int *) out; \
\ \
for( x = 0; x < sz; x++ ) \ for( x = 0; x < sz; x++ ) \
q[x] = ((int) left[x]) OP ((int) right[x]); \ q[x] = ((int) left[x]) OP ((int) right[x]); \

View File

@ -80,8 +80,8 @@ typedef VipsUnaryClass VipsComplexClass;
G_DEFINE_TYPE( VipsComplex, vips_complex, VIPS_TYPE_UNARY ); G_DEFINE_TYPE( VipsComplex, vips_complex, VIPS_TYPE_UNARY );
#define LOOP( IN, OUT, OP ) { \ #define LOOP( IN, OUT, OP ) { \
IN * __restrict__ p = (IN *) in[0]; \ IN * restrict p = (IN *) in[0]; \
OUT * __restrict__ q = (OUT *) out; \ OUT * restrict q = (OUT *) out; \
\ \
for( x = 0; x < sz; x++ ) { \ for( x = 0; x < sz; x++ ) { \
OP( q, p[x], 0.0 ); \ OP( q, p[x], 0.0 ); \
@ -91,8 +91,8 @@ G_DEFINE_TYPE( VipsComplex, vips_complex, VIPS_TYPE_UNARY );
} }
#define CLOOP( IN, OUT, OP ) { \ #define CLOOP( IN, OUT, OP ) { \
IN * __restrict__ p = (IN *) in[0]; \ IN * restrict p = (IN *) in[0]; \
OUT * __restrict__ q = (OUT *) out; \ OUT * restrict q = (OUT *) out; \
\ \
for( x = 0; x < sz; x++ ) { \ for( x = 0; x < sz; x++ ) { \
OP( q, p[0], p[1] ); \ OP( q, p[0], p[1] ); \

View File

@ -90,9 +90,9 @@ G_DEFINE_TYPE( VipsDivide, vips_divide, VIPS_TYPE_BINARY );
/* This is going to be much slower */ /* This is going to be much slower */
#define CLOOP( TYPE ) { \ #define CLOOP( TYPE ) { \
TYPE * __restrict__ left = (TYPE *) in[0]; \ TYPE * restrict left = (TYPE *) in[0]; \
TYPE * __restrict__ right = (TYPE *) in[1]; \ TYPE * restrict right = (TYPE *) in[1]; \
TYPE * __restrict__ q = (TYPE *) out; \ TYPE * restrict q = (TYPE *) out; \
int i; \ int i; \
\ \
for( i = 0; i < sz; i++ ) { \ for( i = 0; i < sz; i++ ) { \
@ -120,9 +120,9 @@ G_DEFINE_TYPE( VipsDivide, vips_divide, VIPS_TYPE_BINARY );
#else /* USE_MODARG_DIV */ #else /* USE_MODARG_DIV */
#define CLOOP( TYPE ) { \ #define CLOOP( TYPE ) { \
TYPE * __restrict__ left = (TYPE *) in[0]; \ TYPE * restrict left = (TYPE *) in[0]; \
TYPE * __restrict__ right = (TYPE *) in[1]; \ TYPE * restrict right = (TYPE *) in[1]; \
TYPE * __restrict__ q = (TYPE *) out; \ TYPE * restrict q = (TYPE *) out; \
int i; \ int i; \
\ \
for( i = 0; i < sz; i++ ) { \ for( i = 0; i < sz; i++ ) { \
@ -157,9 +157,9 @@ G_DEFINE_TYPE( VipsDivide, vips_divide, VIPS_TYPE_BINARY );
/* Real divide. Cast in to OUT before divide so we work for float output. /* Real divide. Cast in to OUT before divide so we work for float output.
*/ */
#define RLOOP( IN, OUT ) { \ #define RLOOP( IN, OUT ) { \
IN * __restrict__ left = (IN *) in[0]; \ IN * restrict left = (IN *) in[0]; \
IN * __restrict__ right = (IN *) in[1]; \ IN * restrict right = (IN *) in[1]; \
OUT * __restrict__ q = (OUT *) out; \ OUT * restrict q = (OUT *) out; \
\ \
for( x = 0; x < sz; x++ ) \ for( x = 0; x < sz; x++ ) \
q[x] = right[x] == 0 ? q[x] : (OUT) left[x] / (OUT) right[x]; \ q[x] = right[x] == 0 ? q[x] : (OUT) left[x] / (OUT) right[x]; \

View File

@ -69,24 +69,24 @@ typedef VipsUnaryClass VipsInvertClass;
G_DEFINE_TYPE( VipsInvert, vips_invert, VIPS_TYPE_UNARY ); G_DEFINE_TYPE( VipsInvert, vips_invert, VIPS_TYPE_UNARY );
#define LOOP( TYPE, L ) { \ #define LOOP( TYPE, L ) { \
TYPE * __restrict__ p = (TYPE *) in[0]; \ TYPE * restrict p = (TYPE *) in[0]; \
TYPE * __restrict__ q = (TYPE *) out; \ TYPE * restrict q = (TYPE *) out; \
\ \
for( x = 0; x < sz; x++ ) \ for( x = 0; x < sz; x++ ) \
q[x] = (L) - p[x]; \ q[x] = (L) - p[x]; \
} }
#define LOOPN( TYPE ) { \ #define LOOPN( TYPE ) { \
TYPE * __restrict__ p = (TYPE *) in[0]; \ TYPE * restrict p = (TYPE *) in[0]; \
TYPE * __restrict__ q = (TYPE *) out; \ TYPE * restrict q = (TYPE *) out; \
\ \
for( x = 0; x < sz; x++ ) \ for( x = 0; x < sz; x++ ) \
q[x] = -1 * p[x]; \ q[x] = -1 * p[x]; \
} }
#define LOOPC( TYPE ) { \ #define LOOPC( TYPE ) { \
TYPE * __restrict__ p = (TYPE *) in[0]; \ TYPE * restrict p = (TYPE *) in[0]; \
TYPE * __restrict__ q = (TYPE *) out; \ TYPE * restrict q = (TYPE *) out; \
\ \
for( x = 0; x < sz; x++ ) { \ for( x = 0; x < sz; x++ ) { \
q[0] = -1 * p[0]; \ q[0] = -1 * p[0]; \

View File

@ -165,8 +165,8 @@ vips_linear_build( VipsObject *object )
/* Non-complex input, any output, all bands of the constant equal. /* Non-complex input, any output, all bands of the constant equal.
*/ */
#define LOOP1( IN, OUT ) { \ #define LOOP1( IN, OUT ) { \
IN * __restrict__ p = (IN *) in[0]; \ IN * restrict p = (IN *) in[0]; \
OUT * __restrict__ q = (OUT *) out; \ OUT * restrict q = (OUT *) out; \
OUT a1 = a[0]; \ OUT a1 = a[0]; \
OUT b1 = b[0]; \ OUT b1 = b[0]; \
int sz = width * nb; \ int sz = width * nb; \
@ -178,8 +178,8 @@ vips_linear_build( VipsObject *object )
/* Non-complex input, any output. /* Non-complex input, any output.
*/ */
#define LOOPN( IN, OUT ) { \ #define LOOPN( IN, OUT ) { \
IN * __restrict__ p = (IN *) in[0]; \ IN * restrict p = (IN *) in[0]; \
OUT * __restrict__ q = (OUT *) out; \ OUT * restrict q = (OUT *) out; \
\ \
for( i = 0, x = 0; x < width; x++ ) \ for( i = 0, x = 0; x < width; x++ ) \
for( k = 0; k < nb; k++, i++ ) \ for( k = 0; k < nb; k++, i++ ) \
@ -199,8 +199,8 @@ vips_linear_build( VipsObject *object )
/* Complex input, complex output. /* Complex input, complex output.
*/ */
#define LOOPCMPLXN( IN, OUT ) { \ #define LOOPCMPLXN( IN, OUT ) { \
IN * __restrict__ p = (IN *) in[0]; \ IN * restrict p = (IN *) in[0]; \
OUT * __restrict__ q = (OUT *) out; \ OUT * restrict q = (OUT *) out; \
\ \
for( x = 0; x < width; x++ ) \ for( x = 0; x < width; x++ ) \
for( k = 0; k < nb; k++ ) { \ for( k = 0; k < nb; k++ ) { \
@ -219,8 +219,8 @@ vips_linear_buffer( VipsArithmetic *arithmetic,
{ {
VipsImage *im = arithmetic->ready[0]; VipsImage *im = arithmetic->ready[0];
VipsLinear *linear = (VipsLinear *) arithmetic; VipsLinear *linear = (VipsLinear *) arithmetic;
double * __restrict__ a = linear->a_ready; double * restrict a = linear->a_ready;
double * __restrict__ b = linear->b_ready; double * restrict b = linear->b_ready;
int nb = im->Bands; int nb = im->Bands;
int i, x, k; int i, x, k;

View File

@ -97,8 +97,8 @@ vips_math_build( VipsObject *object )
} }
#define LOOP( IN, OUT, OP ) { \ #define LOOP( IN, OUT, OP ) { \
IN * __restrict__ p = (IN *) in[0]; \ IN * restrict p = (IN *) in[0]; \
OUT * __restrict__ q = (OUT *) out; \ OUT * restrict q = (OUT *) out; \
\ \
for( x = 0; x < sz; x++ ) \ for( x = 0; x < sz; x++ ) \
q[x] = OP( p[x] ); \ q[x] = OP( p[x] ); \

View File

@ -102,9 +102,9 @@ vips_math2_build( VipsObject *object )
} }
#define LOOP( IN, OUT, OP ) { \ #define LOOP( IN, OUT, OP ) { \
IN * __restrict__ p1 = (IN *) in[0]; \ IN * restrict p1 = (IN *) in[0]; \
IN * __restrict__ p2 = (IN *) in[1]; \ IN * restrict p2 = (IN *) in[1]; \
OUT * __restrict__ q = (OUT *) out; \ OUT * restrict q = (OUT *) out; \
\ \
for( x = 0; x < sz; x++ ) \ for( x = 0; x < sz; x++ ) \
OP( q[x], p1[x], p2[x] ); \ OP( q[x], p1[x], p2[x] ); \
@ -351,9 +351,9 @@ vips_math2_const_build( VipsObject *object )
} }
#define LOOPC( IN, OUT, OP ) { \ #define LOOPC( IN, OUT, OP ) { \
IN * __restrict__ p = (IN *) in[0]; \ IN * restrict p = (IN *) in[0]; \
OUT * __restrict__ q = (OUT *) out; \ OUT * restrict q = (OUT *) out; \
double * __restrict__ c = (double *) uconst->c_ready; \ double * restrict c = (double *) uconst->c_ready; \
\ \
for( i = 0, x = 0; x < width; x++ ) \ for( i = 0, x = 0; x < width; x++ ) \
for( b = 0; b < bands; b++, i++ ) \ for( b = 0; b < bands; b++, i++ ) \

View File

@ -81,9 +81,9 @@ G_DEFINE_TYPE( VipsMultiply, vips_multiply, VIPS_TYPE_BINARY );
/* Complex multiply. /* Complex multiply.
*/ */
#define CLOOP( TYPE ) { \ #define CLOOP( TYPE ) { \
TYPE * __restrict__ left = (TYPE *) in[0]; \ TYPE * restrict left = (TYPE *) in[0]; \
TYPE * __restrict__ right = (TYPE *) in[1]; \ TYPE * restrict right = (TYPE *) in[1]; \
TYPE * __restrict__ q = (TYPE *) out; \ TYPE * restrict q = (TYPE *) out; \
\ \
for( x = 0; x < sz; x++ ) { \ for( x = 0; x < sz; x++ ) { \
double x1 = left[0]; \ double x1 = left[0]; \
@ -104,9 +104,9 @@ G_DEFINE_TYPE( VipsMultiply, vips_multiply, VIPS_TYPE_BINARY );
/* Real multiply. /* Real multiply.
*/ */
#define RLOOP( IN, OUT ) { \ #define RLOOP( IN, OUT ) { \
IN * __restrict__ left = (IN *) in[0]; \ IN * restrict left = (IN *) in[0]; \
IN * __restrict__ right = (IN *) in[1]; \ IN * restrict right = (IN *) in[1]; \
OUT * __restrict__ q = (OUT *) out; \ OUT * restrict q = (OUT *) out; \
\ \
for( x = 0; x < sz; x++ ) \ for( x = 0; x < sz; x++ ) \
q[x] = left[x] * right[x]; \ q[x] = left[x] * right[x]; \

View File

@ -110,18 +110,18 @@ vips_relational_build( VipsObject *object )
} }
#define RLOOP( TYPE, ROP ) { \ #define RLOOP( TYPE, ROP ) { \
TYPE * __restrict__ left = (TYPE *) in[0]; \ TYPE * restrict left = (TYPE *) in[0]; \
TYPE * __restrict__ right = (TYPE *) in[1]; \ TYPE * restrict right = (TYPE *) in[1]; \
VipsPel * __restrict__ q = (VipsPel *) out; \ VipsPel * restrict q = (VipsPel *) out; \
\ \
for( x = 0; x < sz; x++ ) \ for( x = 0; x < sz; x++ ) \
q[x] = (left[x] ROP right[x]) ? 255 : 0; \ q[x] = (left[x] ROP right[x]) ? 255 : 0; \
} }
#define CLOOP( TYPE, COP ) { \ #define CLOOP( TYPE, COP ) { \
TYPE * __restrict__ left = (TYPE *) in[0]; \ TYPE * restrict left = (TYPE *) in[0]; \
TYPE * __restrict__ right = (TYPE *) in[1]; \ TYPE * restrict right = (TYPE *) in[1]; \
VipsPel * __restrict__ q = (VipsPel *) out; \ VipsPel * restrict q = (VipsPel *) out; \
\ \
for( x = 0; x < sz; x++ ) { \ for( x = 0; x < sz; x++ ) { \
q[x] = COP( left[0], left[1], right[0], right[1]) ? 255 : 0; \ q[x] = COP( left[0], left[1], right[0], right[1]) ? 255 : 0; \
@ -477,8 +477,8 @@ vips_relational_const_build( VipsObject *object )
} }
#define RLOOPC( TYPE, OP ) { \ #define RLOOPC( TYPE, OP ) { \
TYPE * __restrict__ p = (TYPE *) in[0]; \ TYPE * restrict p = (TYPE *) in[0]; \
TYPE * __restrict__ c = (TYPE *) uconst->c_ready; \ TYPE * restrict c = (TYPE *) uconst->c_ready; \
\ \
for( i = 0, x = 0; x < width; x++ ) \ for( i = 0, x = 0; x < width; x++ ) \
for( b = 0; b < bands; b++, i++ ) \ for( b = 0; b < bands; b++, i++ ) \
@ -486,10 +486,10 @@ vips_relational_const_build( VipsObject *object )
} }
#define CLOOPC( TYPE, OP ) { \ #define CLOOPC( TYPE, OP ) { \
TYPE * __restrict__ p = (TYPE *) in[0]; \ TYPE * restrict p = (TYPE *) in[0]; \
\ \
for( i = 0, x = 0; x < width; x++ ) { \ for( i = 0, x = 0; x < width; x++ ) { \
TYPE * __restrict__ c = (TYPE *) uconst->c_ready; \ TYPE * restrict c = (TYPE *) uconst->c_ready; \
\ \
for( b = 0; b < bands; b++, i++ ) { \ for( b = 0; b < bands; b++, i++ ) { \
out[i] = OP( p[0], p[1], c[0], c[1]) ? 255 : 0; \ out[i] = OP( p[0], p[1], c[0], c[1]) ? 255 : 0; \

View File

@ -92,9 +92,9 @@ vips_remainder_build( VipsObject *object )
/* Integer remainder-after-division. /* Integer remainder-after-division.
*/ */
#define IREMAINDER( TYPE ) { \ #define IREMAINDER( TYPE ) { \
TYPE * __restrict__ p1 = (TYPE *) in[0]; \ TYPE * restrict p1 = (TYPE *) in[0]; \
TYPE * __restrict__ p2 = (TYPE *) in[1]; \ TYPE * restrict p2 = (TYPE *) in[1]; \
TYPE * __restrict__ q = (TYPE *) out; \ TYPE * restrict q = (TYPE *) out; \
\ \
for( x = 0; x < sz; x++ ) \ for( x = 0; x < sz; x++ ) \
q[x] = p2[x] ? p1[x] % p2[x] : -1; \ q[x] = p2[x] ? p1[x] % p2[x] : -1; \
@ -103,9 +103,9 @@ vips_remainder_build( VipsObject *object )
/* Float remainder-after-division. /* Float remainder-after-division.
*/ */
#define FREMAINDER( TYPE ) { \ #define FREMAINDER( TYPE ) { \
TYPE * __restrict__ p1 = (TYPE *) in[0]; \ TYPE * restrict p1 = (TYPE *) in[0]; \
TYPE * __restrict__ p2 = (TYPE *) in[1]; \ TYPE * restrict p2 = (TYPE *) in[1]; \
TYPE * __restrict__ q = (TYPE *) out; \ TYPE * restrict q = (TYPE *) out; \
\ \
for( x = 0; x < sz; x++ ) { \ for( x = 0; x < sz; x++ ) { \
double a = p1[x]; \ double a = p1[x]; \
@ -255,9 +255,9 @@ vips_remainder_const_build( VipsObject *object )
/* Integer remainder-after-divide, per-band constant. /* Integer remainder-after-divide, per-band constant.
*/ */
#define IREMAINDERCONST( TYPE ) { \ #define IREMAINDERCONST( TYPE ) { \
TYPE * __restrict__ p = (TYPE *) in[0]; \ TYPE * restrict p = (TYPE *) in[0]; \
TYPE * __restrict__ q = (TYPE *) out; \ TYPE * restrict q = (TYPE *) out; \
TYPE * __restrict__ c = (TYPE *) uconst->c_ready; \ TYPE * restrict c = (TYPE *) uconst->c_ready; \
\ \
for( i = 0, x = 0; x < width; x++ ) \ for( i = 0, x = 0; x < width; x++ ) \
for( b = 0; b < bands; b++, i++ ) \ for( b = 0; b < bands; b++, i++ ) \
@ -267,9 +267,9 @@ vips_remainder_const_build( VipsObject *object )
/* Float remainder-after-divide, per-band constant. /* Float remainder-after-divide, per-band constant.
*/ */
#define FREMAINDERCONST( TYPE ) { \ #define FREMAINDERCONST( TYPE ) { \
TYPE * __restrict__ p = (TYPE *) in[0]; \ TYPE * restrict p = (TYPE *) in[0]; \
TYPE * __restrict__ q = (TYPE *) out; \ TYPE * restrict q = (TYPE *) out; \
TYPE * __restrict__ c = (TYPE *) uconst->c_ready; \ TYPE * restrict c = (TYPE *) uconst->c_ready; \
\ \
for( i = 0, x = 0; x < width; x++ ) \ for( i = 0, x = 0; x < width; x++ ) \
for( b = 0; b < bands; b++, i++ ) { \ for( b = 0; b < bands; b++, i++ ) { \

View File

@ -85,8 +85,8 @@ vips_round_build( VipsObject *object )
} }
#define LOOP( TYPE, OP ) { \ #define LOOP( TYPE, OP ) { \
TYPE * __restrict__ p = (TYPE *) in[0]; \ TYPE * restrict p = (TYPE *) in[0]; \
TYPE * __restrict__ q = (TYPE *) out; \ TYPE * restrict q = (TYPE *) out; \
\ \
for( x = 0; x < sz; x++ ) \ for( x = 0; x < sz; x++ ) \
q[x] = OP( p[x] ); \ q[x] = OP( p[x] ); \

View File

@ -58,8 +58,8 @@ typedef VipsUnaryClass VipsSignClass;
G_DEFINE_TYPE( VipsSign, vips_sign, VIPS_TYPE_UNARY ); G_DEFINE_TYPE( VipsSign, vips_sign, VIPS_TYPE_UNARY );
#define CSIGN( TYPE ) { \ #define CSIGN( TYPE ) { \
TYPE * __restrict__ p = (TYPE *) in[0]; \ TYPE * restrict p = (TYPE *) in[0]; \
TYPE * __restrict__ q = (TYPE *) out; \ TYPE * restrict q = (TYPE *) out; \
int x; \ int x; \
\ \
for( x = 0; x < sz; x++ ) { \ for( x = 0; x < sz; x++ ) { \
@ -83,8 +83,8 @@ G_DEFINE_TYPE( VipsSign, vips_sign, VIPS_TYPE_UNARY );
} }
#define SIGN( TYPE ) { \ #define SIGN( TYPE ) { \
TYPE * __restrict__ p = (TYPE *) in[0]; \ TYPE * restrict p = (TYPE *) in[0]; \
signed char * __restrict__ q = (signed char *) out; \ signed char * restrict q = (signed char *) out; \
int x; \ int x; \
\ \
for( x = 0; x < sz; x++ ) { \ for( x = 0; x < sz; x++ ) { \

View File

@ -83,9 +83,9 @@ typedef VipsBinaryClass VipsSubtractClass;
G_DEFINE_TYPE( VipsSubtract, vips_subtract, VIPS_TYPE_BINARY ); G_DEFINE_TYPE( VipsSubtract, vips_subtract, VIPS_TYPE_BINARY );
#define LOOP( IN, OUT ) { \ #define LOOP( IN, OUT ) { \
IN * __restrict__ left = (IN *) in[0]; \ IN * restrict left = (IN *) in[0]; \
IN * __restrict__ right = (IN *) in[1]; \ IN * restrict right = (IN *) in[1]; \
OUT * __restrict__ q = (OUT *) out; \ OUT * restrict q = (OUT *) out; \
\ \
for( x = 0; x < sz; x++ ) \ for( x = 0; x < sz; x++ ) \
q[x] = left[x] - right[x]; \ q[x] = left[x] - right[x]; \

View File

@ -52,7 +52,7 @@ G_DEFINE_ABSTRACT_TYPE( VipsUnaryConst, vips_unary_const, VIPS_TYPE_UNARY );
/* Cast a vector of double to a vector of TYPE, clipping to a range. /* Cast a vector of double to a vector of TYPE, clipping to a range.
*/ */
#define CAST_CLIP( TYPE, N, X ) { \ #define CAST_CLIP( TYPE, N, X ) { \
TYPE * __restrict__ tq = (TYPE *) q; \ TYPE * restrict tq = (TYPE *) q; \
\ \
for( i = 0; i < m; i++ ) { \ for( i = 0; i < m; i++ ) { \
double v = p[VIPS_MIN( n - 1, i )]; \ double v = p[VIPS_MIN( n - 1, i )]; \
@ -64,7 +64,7 @@ G_DEFINE_ABSTRACT_TYPE( VipsUnaryConst, vips_unary_const, VIPS_TYPE_UNARY );
/* Cast a vector of double to a vector of TYPE. /* Cast a vector of double to a vector of TYPE.
*/ */
#define CAST( TYPE ) { \ #define CAST( TYPE ) { \
TYPE * __restrict__ tq = (TYPE *) q; \ TYPE * restrict tq = (TYPE *) q; \
\ \
for( i = 0; i < m; i++ ) \ for( i = 0; i < m; i++ ) \
tq[i] = (TYPE) p[VIPS_MIN( n - 1, i )]; \ tq[i] = (TYPE) p[VIPS_MIN( n - 1, i )]; \
@ -73,7 +73,7 @@ G_DEFINE_ABSTRACT_TYPE( VipsUnaryConst, vips_unary_const, VIPS_TYPE_UNARY );
/* Cast a vector of double to a complex vector of TYPE. /* Cast a vector of double to a complex vector of TYPE.
*/ */
#define CASTC( TYPE ) { \ #define CASTC( TYPE ) { \
TYPE * __restrict__ tq = (TYPE *) q; \ TYPE * restrict tq = (TYPE *) q; \
\ \
for( i = 0; i < m; i++ ) { \ for( i = 0; i < m; i++ ) { \
tq[0] = (TYPE) p[VIPS_MIN( n - 1, i )]; \ tq[0] = (TYPE) p[VIPS_MIN( n - 1, i )]; \
@ -87,7 +87,7 @@ G_DEFINE_ABSTRACT_TYPE( VipsUnaryConst, vips_unary_const, VIPS_TYPE_UNARY );
*/ */
static VipsPel * static VipsPel *
make_pixel( VipsObject *obj, make_pixel( VipsObject *obj,
int m, VipsBandFmt fmt, int n, double * __restrict__ p ) int m, VipsBandFmt fmt, int n, double * restrict p )
{ {
VipsPel *q; VipsPel *q;
int i; int i;

View File

@ -182,8 +182,8 @@ vips_cast_start( VipsImage *out, void *a, void *b )
/* Cast int types to an int type. /* Cast int types to an int type.
*/ */
#define VIPS_CLIP_INT_INT( ITYPE, OTYPE, VIPS_CLIP ) { \ #define VIPS_CLIP_INT_INT( ITYPE, OTYPE, VIPS_CLIP ) { \
ITYPE *p = (ITYPE *) in; \ ITYPE * restrict p = (ITYPE *) in; \
OTYPE *q = (OTYPE *) out; \ OTYPE * restrict q = (OTYPE *) out; \
\ \
for( x = 0; x < sz; x++ ) { \ for( x = 0; x < sz; x++ ) { \
int t = p[x]; \ int t = p[x]; \
@ -197,8 +197,8 @@ vips_cast_start( VipsImage *out, void *a, void *b )
/* Cast float types to an int type. /* Cast float types to an int type.
*/ */
#define VIPS_CLIP_FLOAT_INT( ITYPE, OTYPE, VIPS_CLIP ) { \ #define VIPS_CLIP_FLOAT_INT( ITYPE, OTYPE, VIPS_CLIP ) { \
ITYPE *p = (ITYPE *) in; \ ITYPE * restrict p = (ITYPE *) in; \
OTYPE *q = (OTYPE *) out; \ OTYPE * restrict q = (OTYPE *) out; \
\ \
for( x = 0; x < sz; x++ ) { \ for( x = 0; x < sz; x++ ) { \
ITYPE v = floor( p[x] ); \ ITYPE v = floor( p[x] ); \
@ -212,8 +212,8 @@ vips_cast_start( VipsImage *out, void *a, void *b )
/* Cast complex types to an int type. Just take the real part. /* Cast complex types to an int type. Just take the real part.
*/ */
#define VIPS_CLIP_COMPLEX_INT( ITYPE, OTYPE, VIPS_CLIP ) { \ #define VIPS_CLIP_COMPLEX_INT( ITYPE, OTYPE, VIPS_CLIP ) { \
ITYPE *p = (ITYPE *) in; \ ITYPE * restrict p = (ITYPE *) in; \
OTYPE *q = (OTYPE *) out; \ OTYPE * restrict q = (OTYPE *) out; \
\ \
for( x = 0; x < sz; x++ ) { \ for( x = 0; x < sz; x++ ) { \
ITYPE v = floor( p[0] ); \ ITYPE v = floor( p[0] ); \
@ -228,8 +228,8 @@ vips_cast_start( VipsImage *out, void *a, void *b )
/* Cast non-complex types to a float type. /* Cast non-complex types to a float type.
*/ */
#define VIPS_CLIP_REAL_FLOAT( ITYPE, OTYPE ) { \ #define VIPS_CLIP_REAL_FLOAT( ITYPE, OTYPE ) { \
ITYPE *p = (ITYPE *) in; \ ITYPE * restrict p = (ITYPE *) in; \
OTYPE *q = (OTYPE *) out; \ OTYPE * restrict q = (OTYPE *) out; \
\ \
for( x = 0; x < sz; x++ ) \ for( x = 0; x < sz; x++ ) \
q[x] = p[x]; \ q[x] = p[x]; \
@ -238,8 +238,8 @@ vips_cast_start( VipsImage *out, void *a, void *b )
/* Cast complex types to a float type ... just take real. /* Cast complex types to a float type ... just take real.
*/ */
#define VIPS_CLIP_COMPLEX_FLOAT( ITYPE, OTYPE ) { \ #define VIPS_CLIP_COMPLEX_FLOAT( ITYPE, OTYPE ) { \
ITYPE *p = (ITYPE *) in; \ ITYPE * restrict p = (ITYPE *) in; \
OTYPE *q = (OTYPE *) out; \ OTYPE * restrict q = (OTYPE *) out; \
\ \
for( x = 0; x < sz; x++ ) { \ for( x = 0; x < sz; x++ ) { \
q[x] = p[0]; \ q[x] = p[0]; \
@ -250,8 +250,8 @@ vips_cast_start( VipsImage *out, void *a, void *b )
/* Cast any non-complex to a complex type ... set imaginary to zero. /* Cast any non-complex to a complex type ... set imaginary to zero.
*/ */
#define VIPS_CLIP_REAL_COMPLEX( ITYPE, OTYPE ) { \ #define VIPS_CLIP_REAL_COMPLEX( ITYPE, OTYPE ) { \
ITYPE *p = (ITYPE *) in; \ ITYPE * restrict p = (ITYPE *) in; \
OTYPE *q = (OTYPE *) out; \ OTYPE * restrict q = (OTYPE *) out; \
\ \
for( x = 0; x < sz; x++ ) { \ for( x = 0; x < sz; x++ ) { \
q[0] = p[x]; \ q[0] = p[x]; \
@ -263,8 +263,8 @@ vips_cast_start( VipsImage *out, void *a, void *b )
/* Cast any complex to a complex type. /* Cast any complex to a complex type.
*/ */
#define VIPS_CLIP_COMPLEX_COMPLEX( ITYPE, OTYPE ) { \ #define VIPS_CLIP_COMPLEX_COMPLEX( ITYPE, OTYPE ) { \
ITYPE *p = (ITYPE *) in; \ ITYPE * restrict p = (ITYPE *) in; \
OTYPE *q = (OTYPE *) out; \ OTYPE * restrict q = (OTYPE *) out; \
\ \
for( x = 0; x < sz; x++ ) { \ for( x = 0; x < sz; x++ ) { \
q[0] = p[0]; \ q[0] = p[0]; \

View File

@ -72,11 +72,11 @@ G_DEFINE_TYPE( VipsRecomb, vips_recomb, VIPS_TYPE_CONVERSION );
/* Inner loop. /* Inner loop.
*/ */
#define LOOP( IN, OUT ) { \ #define LOOP( IN, OUT ) { \
IN *p = (IN *) in; \ IN * restrict p = (IN *) in; \
OUT *q = (OUT *) out; \ OUT * restrict q = (OUT *) out; \
\ \
for( x = 0; x < or->valid.width; x++ ) { \ for( x = 0; x < or->valid.width; x++ ) { \
double *m = VIPS_MATRIX( recomb->coeff, 0, 0 ); \ double * restrict m = VIPS_MATRIX( recomb->coeff, 0, 0 ); \
\ \
for( v = 0; v < mheight; v++ ) { \ for( v = 0; v < mheight; v++ ) { \
double t; \ double t; \

View File

@ -337,8 +337,8 @@ vips_interpolate_nearest_interpolate( VipsInterpolate *interpolate,
const int xi = (int) x; const int xi = (int) x;
const int yi = (int) y; const int yi = (int) y;
const VipsPel *p = VIPS_REGION_ADDR( in, xi, yi ); const VipsPel * restrict p = VIPS_REGION_ADDR( in, xi, yi );
VipsPel *q = (VipsPel *) out; VipsPel * restrict q = (VipsPel *) out;
int z; int z;
@ -429,15 +429,15 @@ G_DEFINE_TYPE( VipsInterpolateBilinear, vips_interpolate_bilinear,
/* Fixed-point arithmetic, no tables. /* Fixed-point arithmetic, no tables.
*/ */
#define BILINEAR_INT( TYPE ) { \ #define BILINEAR_INT( TYPE ) { \
TYPE *tq = (TYPE *) out; \ TYPE * restrict tq = (TYPE *) out; \
\ \
const int X = (x - ix) * VIPS_INTERPOLATE_SCALE; \ const int X = (x - ix) * VIPS_INTERPOLATE_SCALE; \
const int Y = (iy - y) * VIPS_INTERPOLATE_SCALE; \ const int Y = (iy - y) * VIPS_INTERPOLATE_SCALE; \
\ \
const TYPE *tp1 = (TYPE *) p1; \ const TYPE * restrict tp1 = (TYPE *) p1; \
const TYPE *tp2 = (TYPE *) p2; \ const TYPE * restrict tp2 = (TYPE *) p2; \
const TYPE *tp3 = (TYPE *) p3; \ const TYPE * restrict tp3 = (TYPE *) p3; \
const TYPE *tp4 = (TYPE *) p4; \ const TYPE * restrict tp4 = (TYPE *) p4; \
\ \
for( z = 0; z < b; z++ ) { \ for( z = 0; z < b; z++ ) { \
const int top = tp1[z] + \ const int top = tp1[z] + \
@ -453,7 +453,7 @@ G_DEFINE_TYPE( VipsInterpolateBilinear, vips_interpolate_bilinear,
* arithmetic. * arithmetic.
*/ */
#define BILINEAR_FLOAT( TYPE ) { \ #define BILINEAR_FLOAT( TYPE ) { \
TYPE *tq = (TYPE *) out; \ TYPE * restrict tq = (TYPE *) out; \
\ \
float Y = y - iy; \ float Y = y - iy; \
float X = x - ix; \ float X = x - ix; \
@ -465,10 +465,10 @@ G_DEFINE_TYPE( VipsInterpolateBilinear, vips_interpolate_bilinear,
float c3 = Y - c4; \ float c3 = Y - c4; \
float c1 = Yd - c2; \ float c1 = Yd - c2; \
\ \
const TYPE *tp1 = (TYPE *) p1; \ const TYPE * restrict tp1 = (TYPE *) p1; \
const TYPE *tp2 = (TYPE *) p2; \ const TYPE * restrict tp2 = (TYPE *) p2; \
const TYPE *tp3 = (TYPE *) p3; \ const TYPE * restrict tp3 = (TYPE *) p3; \
const TYPE *tp4 = (TYPE *) p4; \ const TYPE * restrict tp4 = (TYPE *) p4; \
\ \
for( z = 0; z < b; z++ ) \ for( z = 0; z < b; z++ ) \
tq[z] = c1 * tp1[z] + c2 * tp2[z] + \ tq[z] = c1 * tp1[z] + c2 * tp2[z] + \
@ -506,10 +506,10 @@ vips_interpolate_bilinear_interpolate( VipsInterpolate *interpolate,
const int ix = (int) x; const int ix = (int) x;
const int iy = (int) y; const int iy = (int) y;
const VipsPel *p1 = VIPS_REGION_ADDR( in, ix, iy ); const VipsPel * restrict p1 = VIPS_REGION_ADDR( in, ix, iy );
const VipsPel *p2 = p1 + ps; const VipsPel * restrict p2 = p1 + ps;
const VipsPel *p3 = p1 + ls; const VipsPel * restrict p3 = p1 + ls;
const VipsPel *p4 = p3 + ps; const VipsPel * restrict p4 = p3 + ps;
int z; int z;