You are not logged in.
Pages: 1
Hi,
I am currently working on a firewire video camera project and while comparing some functions that convert raw Bayer to RGB, I found that those who use the following construct:
void Bayer_to_RGB8( video_buffer_t *source, video_buffer_t *display )
{
unsigned char *restrict bayer = source->buffer;
unsigned char *restrict rgb = display->buffer;
......
are faster by about 15%+ than those that use source->buffer and display->buffer directly in the code. I looked up the keyword in google but only found some patchy explanations on the use of __restrict.
I would appreciate any info/links to a more detailed explanation on the proper way and place to use it to speed up code.
My thanks in advance.
Regards
Neoklis ... Ham Radio Call: 5B4AZ
Offline
From what I understand, it makes a guarantee that bayer and rgb don't point to the same memory, so the compiler doesn't have to load rgb every time bayer is stored (modified).
-Joe
Last edited by joe (2008-09-12 03:52:37)
Offline
Like the `register`modifier, `restrict` is an optimization hint for the compiler. As such, the caompiler can choose to ignore it. It is used to tell the compiler that a particular pointer is the only reference (either direct or indirect) to the value it points to throughout its scope. That is, the same value is not referenced by any other pointer or variable within that scope.
Offline
Hi,
I would appreciate any info/links to a more detailed explanation on the proper way and place to use it to speed up code.
My thanks in advance.
Ahh, my thanks for the replies, I can now possibly use this feature in one or two other programs I have written, to speed them up. Gaining 15-20% extra speed so simply sounds very nice! ;-)
Regards
Neoklis ... Ham Radio Call: 5B4AZ
Offline
Pages: 1