Operating System - HP-UX
1832502 Members
4815 Online
110043 Solutions
New Discussion

HPUX c compiler (restrict keywork)

 
tiyyagura sunil reddy
Occasional Contributor

HPUX c compiler (restrict keywork)

hello, I have been working on code optimization with HP C compilers on Itanium architecture. I have used the keyword "restrict" with intel compiler and had seen some performance improvement. I am using the compiler flag +Optrs_strongly_typed at the moment for the HP compiler. Does HP compiler support restrict keyword? I have read a few compiler manuals and could not find an alternative to restrict. Also is there a similar compiler flag as -alias so that pointer aliasing can be stopped?
1 REPLY 1
Mike Stroyan
Honored Contributor

Re: HPUX c compiler (restrict keywork)

The current HP C compiler for Itanium will accept a __restrict attribute on either parameters or variables, but it will ignore
the attribute unless it is for a parameter.
The following accum_restrict function will run faster because the compiler knows that writing to 'a' will not change the values in 'b'.

void accum_restrict(double * __restrict a, double *b, int num)
{
int i;
for (i=0; i a[i] += b[i];
}
}

The following accum_restrict_nonparm function will not run any faster with the __restrict attribute on a local variable. It could help some later compiler version.

void accum_restrict_nonparm(double *a, double *b, int num)
{
int i;
double * __restrict p;
p = a;
for (i=0; i p[i] += b[i];
}
}