sse.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (Simplified BSD License)
00003  *
00004  * Point Cloud Library (PCL) - www.pointclouds.org
00005  * Copyright (c) 2013-, Open Perception, Inc.
00006  * Copyright (c) 2012, Piotr Dollar & Ron Appel.[pdollar-at-caltech.edu]
00007  *
00008  * All rights reserved.
00009  *
00010  * Redistribution and use in source and binary forms, with or without
00011  * modification, are permitted provided that the following conditions are met: 
00012  *
00013  * 1. Redistributions of source code must retain the above copyright notice, this
00014  *list of conditions and the following disclaimer.
00015  *
00016  * 2. Redistributions in binary form must reproduce the above copyright notice,
00017  *this list of conditions and the following disclaimer in the documentation
00018  *and/or other materials provided with the distribution. 
00019  * 
00020  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00021  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00022  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00023  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
00024  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00025  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00026  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00027  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00028  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00029  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030  *
00031  * The views and conclusions contained in the software and documentation are those
00032  * of the authors and should not be interpreted as representing official policies,
00033  * either expressed or implied, of the FreeBSD Project.
00034  *
00035  * Taken from Piotr Dollar's MATLAB Image&Video ToolboxVersion 3.00.
00036  *
00037  */
00038 
00039 #ifndef PCL_SSE_H_
00040 #define PCL_SSE_H_
00041 #if defined(__SSE2__)
00042 #include <emmintrin.h> // SSE2:<e*.h>, SSE3:<p*.h>, SSE4:<s*.h>
00043 
00044 #define RETf inline __m128
00045 #define RETi inline __m128i
00046 
00047 namespace pcl {
00048 
00049 // set, load and store values
00050 RETf sse_set( const float &x ) { return _mm_set1_ps(x); }
00051 RETf sse_set( float x, float y, float z, float w ) { return _mm_set_ps(x,y,z,w); }
00052 RETi sse_set( const int &x ) { return _mm_set1_epi32(x); }
00053 RETf sse_ld( const float &x ) { return _mm_load_ps(&x); }
00054 RETf sse_ldu( const float &x ) { return _mm_loadu_ps(&x); }
00055 RETf sse_str( float &x, const __m128 y ) { _mm_store_ps(&x,y); return y; }
00056 RETf sse_str1( float &x, const __m128 y ) { _mm_store_ss(&x,y); return y; }
00057 RETf sse_stru( float &x, const __m128 y ) { _mm_storeu_ps(&x,y); return y; }
00058 RETf sse_str( float &x, const float y ) { return sse_str(x,sse_set(y)); }
00059 
00060 // arithmetic operators
00061 RETi sse_add( const __m128i x, const __m128i y ) { return _mm_add_epi32(x,y); }
00062 RETf sse_add( const __m128 x, const __m128 y ) { return _mm_add_ps(x,y); }
00063 RETf sse_add( const __m128 x, const __m128 y, const __m128 z ) {
00064   return sse_add(sse_add(x,y),z); }
00065 RETf sse_add( const __m128 a, const __m128 b, const __m128 c, const __m128 &d ) {
00066   return sse_add(sse_add(sse_add(a,b),c),d); }
00067 RETf sse_sub( const __m128 x, const __m128 y ) { return _mm_sub_ps(x,y); }
00068 RETf sse_mul( const __m128 x, const __m128 y ) { return _mm_mul_ps(x,y); }
00069 RETf sse_mul( const __m128 x, const float y ) { return sse_mul(x,sse_set(y)); }
00070 RETf sse_mul( const float x, const __m128 y ) { return sse_mul(sse_set(x),y); }
00071 RETf sse_inc( __m128 &x, const __m128 y ) { return x = sse_add(x,y); }
00072 RETf sse_inc( float &x, const __m128 y ) { __m128 t=sse_add(sse_ld(x),y); return sse_str(x,t); }
00073 RETf sse_dec( __m128 &x, const __m128 y ) { return x = sse_sub(x,y); }
00074 RETf sse_dec( float &x, const __m128 y ) { __m128 t=sse_sub(sse_ld(x),y); return sse_str(x,t); }
00075 RETf sse_min( const __m128 x, const __m128 y ) { return _mm_min_ps(x,y); }
00076 RETf sse_rcp( const __m128 x ) { return _mm_rcp_ps(x); }
00077 RETf sse_rcpsqrt( const __m128 x ) { return _mm_rsqrt_ps(x); }
00078 
00079 // logical operators
00080 RETf sse_and( const __m128 x, const __m128 y ) { return _mm_and_ps(x,y); }
00081 RETi sse_and( const __m128i x, const __m128i y ) { return _mm_and_si128(x,y); }
00082 RETf sse_andnot( const __m128 x, const __m128 y ) { return _mm_andnot_ps(x,y); }
00083 RETf sse_or( const __m128 x, const __m128 y ) { return _mm_or_ps(x,y); }
00084 RETf sse_xor( const __m128 x, const __m128 y ) { return _mm_xor_ps(x,y); }
00085 
00086 // comparison operators
00087 RETf sse_cmpgt( const __m128 x, const __m128 y ) { return _mm_cmpgt_ps(x,y); }
00088 RETi sse_cmpgt( const __m128i x, const __m128i y ) { return _mm_cmpgt_epi32(x,y); }
00089 
00090 // conversion operators
00091 RETf sse_cvt( const __m128i x ) { return _mm_cvtepi32_ps(x); }
00092 RETi sse_cvt( const __m128 x ) { return _mm_cvttps_epi32(x); }
00093 
00094 } // namespace pcl
00095 
00096 #undef RETf
00097 #undef RETi
00098 #endif /* defined(__SSE2__) */
00099 #endif /* PCL_SSE_H_ */


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:33:43