Renesas GR-PEACH OpenCV Development / gr-peach-opencv-project-sd-card_update

Fork of gr-peach-opencv-project-sd-card by the do

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers warp_shuffle.hpp Source File

warp_shuffle.hpp

Go to the documentation of this file.
00001 /*M///////////////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
00004 //
00005 //  By downloading, copying, installing or using the software you agree to this license.
00006 //  If you do not agree to this license, do not download, install,
00007 //  copy or use the software.
00008 //
00009 //
00010 //                           License Agreement
00011 //                For Open Source Computer Vision Library
00012 //
00013 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
00014 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
00015 // Third party copyrights are property of their respective owners.
00016 //
00017 // Redistribution and use in source and binary forms, with or without modification,
00018 // are permitted provided that the following conditions are met:
00019 //
00020 //   * Redistribution's of source code must retain the above copyright notice,
00021 //     this list of conditions and the following disclaimer.
00022 //
00023 //   * Redistribution's in binary form must reproduce the above copyright notice,
00024 //     this list of conditions and the following disclaimer in the documentation
00025 //     and/or other materials provided with the distribution.
00026 //
00027 //   * The name of the copyright holders may not be used to endorse or promote products
00028 //     derived from this software without specific prior written permission.
00029 //
00030 // This software is provided by the copyright holders and contributors "as is" and
00031 // any express or implied warranties, including, but not limited to, the implied
00032 // warranties of merchantability and fitness for a particular purpose are disclaimed.
00033 // In no event shall the Intel Corporation or contributors be liable for any direct,
00034 // indirect, incidental, special, exemplary, or consequential damages
00035 // (including, but not limited to, procurement of substitute goods or services;
00036 // loss of use, data, or profits; or business interruption) however caused
00037 // and on any theory of liability, whether in contract, strict liability,
00038 // or tort (including negligence or otherwise) arising in any way out of
00039 // the use of this software, even if advised of the possibility of such damage.
00040 //
00041 //M*/
00042 
00043 #ifndef __OPENCV_CUDA_WARP_SHUFFLE_HPP__
00044 #define __OPENCV_CUDA_WARP_SHUFFLE_HPP__
00045 
00046 /** @file
00047  * @deprecated Use @ref cudev instead.
00048  */
00049 
00050 //! @cond IGNORED
00051 
00052 namespace cv { namespace cuda { namespace device
00053 {
00054     template <typename T>
00055     __device__ __forceinline__ T shfl(T val, int srcLane, int width = warpSize)
00056     {
00057     #if __CUDA_ARCH__ >= 300
00058         return __shfl(val, srcLane, width);
00059     #else
00060         return T();
00061     #endif
00062     }
00063     __device__ __forceinline__ unsigned int shfl(unsigned int val, int srcLane, int width = warpSize)
00064     {
00065     #if __CUDA_ARCH__ >= 300
00066         return (unsigned int) __shfl((int) val, srcLane, width);
00067     #else
00068         return 0;
00069     #endif
00070     }
00071     __device__ __forceinline__ double shfl(double val, int srcLane, int width = warpSize)
00072     {
00073     #if __CUDA_ARCH__ >= 300
00074         int lo = __double2loint(val);
00075         int hi = __double2hiint(val);
00076 
00077         lo = __shfl(lo, srcLane, width);
00078         hi = __shfl(hi, srcLane, width);
00079 
00080         return __hiloint2double(hi, lo);
00081     #else
00082         return 0.0;
00083     #endif
00084     }
00085 
00086     template <typename T>
00087     __device__ __forceinline__ T shfl_down(T val, unsigned int delta, int width = warpSize)
00088     {
00089     #if __CUDA_ARCH__ >= 300
00090         return __shfl_down(val, delta, width);
00091     #else
00092         return T();
00093     #endif
00094     }
00095     __device__ __forceinline__ unsigned int shfl_down(unsigned int val, unsigned int delta, int width = warpSize)
00096     {
00097     #if __CUDA_ARCH__ >= 300
00098         return (unsigned int) __shfl_down((int) val, delta, width);
00099     #else
00100         return 0;
00101     #endif
00102     }
00103     __device__ __forceinline__ double shfl_down(double val, unsigned int delta, int width = warpSize)
00104     {
00105     #if __CUDA_ARCH__ >= 300
00106         int lo = __double2loint(val);
00107         int hi = __double2hiint(val);
00108 
00109         lo = __shfl_down(lo, delta, width);
00110         hi = __shfl_down(hi, delta, width);
00111 
00112         return __hiloint2double(hi, lo);
00113     #else
00114         return 0.0;
00115     #endif
00116     }
00117 
00118     template <typename T>
00119     __device__ __forceinline__ T shfl_up(T val, unsigned int delta, int width = warpSize)
00120     {
00121     #if __CUDA_ARCH__ >= 300
00122         return __shfl_up(val, delta, width);
00123     #else
00124         return T();
00125     #endif
00126     }
00127     __device__ __forceinline__ unsigned int shfl_up(unsigned int val, unsigned int delta, int width = warpSize)
00128     {
00129     #if __CUDA_ARCH__ >= 300
00130         return (unsigned int) __shfl_up((int) val, delta, width);
00131     #else
00132         return 0;
00133     #endif
00134     }
00135     __device__ __forceinline__ double shfl_up(double val, unsigned int delta, int width = warpSize)
00136     {
00137     #if __CUDA_ARCH__ >= 300
00138         int lo = __double2loint(val);
00139         int hi = __double2hiint(val);
00140 
00141         lo = __shfl_up(lo, delta, width);
00142         hi = __shfl_up(hi, delta, width);
00143 
00144         return __hiloint2double(hi, lo);
00145     #else
00146         return 0.0;
00147     #endif
00148     }
00149 }}}
00150 
00151 //! @endcond
00152 
00153 #endif // __OPENCV_CUDA_WARP_SHUFFLE_HPP__
00154