views:

356

answers:

1

I am writing a graphics library in C and I would like to utilize SSE instructions to speed up some of the functions. How would I go about doing this? I am using the GCC compiler so I can rely on compiler intrinsics. I would also like to know whether I should change the way I am storing the image data (currently I am just using an array of floats) - do I need to use an array of type float __attribute__ ((vector_size (16))) ?

EDIT: the type of image manipulation/processing I am interested in include affine transformations, geometry, and frequency domain filtering (Fourier analysis)

Any references or tips on how I should go about using SSE for image manipulation in C would be much appreciated.

thanks

+1  A: 

I've been working on some image processing with SSE on Microsoft Visual C++. I've found it's easiest to align all image data (in Visual C++ that's done with _aligned_malloc and _aligned_free) right from the start. Alignment is a real pain though, that's why I only used SSE for arithmetic operations (add, subtract, dot product, those kinds of things). If I had to do more complicated things I generally just used pointers.

Ray Hidayat
heya thanks for your answer! :)However i'd like a bit more info on how you went about it:)Do you have any example code illustrating a simple operation on an image using SSE? Any tips or pitfalls i should be aware of? Were you relying on inline asm or compiler intrisics? etc :)thanks
banister
Great. I used compiler intrinsics. No obvious pitfalls, make sure everything is aligned, that's all. It's difficult for me to show you example code because I made everything with C++ templates, so there are many levels of abstraction behind even a simple addition operation. I learnt off examples from CodeProject.com though, check there for some good examples.
Ray Hidayat