g++ and MSVC support for __restrict 'ing array parameters (e.g. int arr[restrict 10])
Asked Answered
F

1

4

I'm in the process of updating performance critical libraries to use restrict, as implemented in C++11 by g++ and MSVC with the keyword __restrict.

There are a lot of routines and functions that look something like:

void f(float a[],float b[]);

In the above example, f is a routine whose arguments should be restricted. Unfortunately, as far as I can tell, this is impossible while maintaining that syntax. Now, clearly this can be rewritten using pointers as:

void f(float* __restrict a, float* __restrict b);

What got lost here is the semantic fact that a and b are arrays (I prefer using pointer notation for single-value pointers and array notation for array pointers). Descriptive argument names (omitted above) help, but only so much.

I would like to confirm that declaring restrict'ed parameters using array syntax is impossible for these compilers at this time.

Forewent answered 19/9, 2014 at 8:4 Comment(2)
You may still use using float_array = float[]; and then void f(float_array __restrict a, float_array __restrict b);Mantel
@Mantel thanks for that; too unwieldy for my taste, unfortunately.Forewent
C
1

This has been filed as GCC bug 97477. Users may wish to express their interest/support in that being implemented.

Chemoprophylaxis answered 4/9 at 15:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.