├── README ├── LICENSE.txt ├── experiments ├── canny │ ├── CMakeLists.txt │ └── canny.idsl ├── blur │ ├── CMakeLists.txt │ ├── blur.idsl │ └── blur_gold.cpp ├── emboss │ ├── CMakeLists.txt │ ├── emboss.idsl │ └── emboss_gold.cpp ├── hdr_direct │ └── CMakeLists.txt ├── pyramid │ ├── CMakeLists.txt │ └── pyramid.idsl ├── hdr_pyramid │ └── CMakeLists.txt ├── pyramid_rgb │ └── CMakeLists.txt ├── pyramid_rgb_mirror │ └── CMakeLists.txt ├── try.sh ├── camera_pipe │ └── CMakeLists.txt └── pyramid_mirror │ ├── CMakeLists.txt │ └── pyramid_mirror.idsl ├── ctests ├── offset.idsl ├── sample.idsl ├── extrapolate.idsl ├── hello_world.idsl ├── hello_world3D.idsl ├── hello_world4D.idsl ├── unroll.idsl ├── bdy_wrap.idsl ├── bdy_clamped.idsl ├── bdy_mirror.idsl ├── stencil_sampling.idsl ├── sub_domain2.idsl ├── bdy_constant.idsl ├── subdomain_function.idsl ├── vectorfn_subdomain.idsl ├── j2d.idsl ├── sharp.idsl ├── getmax.idsl ├── try_struct.idsl ├── mixed_bdy_NW.idsl ├── simple_stencil.idsl ├── mixed_bdy_CM.idsl ├── ternary.idsl ├── struct_subdomain.idsl ├── mixed_bdy.idsl ├── blur.idsl ├── blur_int.idsl ├── blur_float.idsl ├── blur_double.idsl ├── blur_mirror.idsl ├── blur_wrap.idsl ├── blur_clamped.idsl ├── blur_int8.idsl ├── blur_int16.idsl ├── compose.idsl ├── upsample_mirror.idsl ├── j2d-1000x1000-100.idsl ├── downsample.idsl ├── downsample_mirror.idsl ├── sobel.idsl ├── upsample.idsl ├── canny_mirror.idsl ├── canny_float.idsl ├── canny.idsl └── hdr_direct.idsl ├── src ├── ASTVisitor │ └── CMakeLists.txt ├── CMakeLists.txt ├── CodeGen │ └── CMakeLists.txt └── AST │ ├── stencil_expr.cpp │ └── CMakeLists.txt ├── include ├── CMakeLists.txt ├── CodeGen │ ├── CMakeLists.txt │ ├── print_LLVM.hpp │ └── print_dot.hpp ├── ASTVisitor │ ├── CMakeLists.txt │ ├── convert_boundaries.hpp │ ├── copy_visitor.hpp │ └── stencil_visitor.hpp ├── AST │ ├── CMakeLists.txt │ └── local_scalars.hpp └── program_opts.hpp ├── cuda_header.cu └── llvm_helper.cpp /README: -------------------------------------------------------------------------------- 1 | Forma is a DSL for image processing developed in the CUDA Compiler Team, NVIDIA. 2 | 3 | Relevant Papers : 4 | 5 | "Forma: a DSL for image processing applications to target GPUs and multi-core 6 | CPUs", Ravishankar M., Holewinski J., and Grover V. Proceedings of the 8th 7 | Workshop on General Purpose Processing using GPUs (GPGPU-8). February 7th, 2015, 8 | San Fransisco, USA. 9 | 10 | Prerequisites: 11 | 12 | 1) Bison : Should be in PATH 13 | 2) Flex : Should be in PATH 14 | 3) CUDA >= 7.5 15 | 4) C/C++ Compiler 16 | 5) LLVM-3.8 (Optional) 17 | 18 | To Build Forma on Linux run the script build.sh 19 | 20 | To report issues please contact Mahesh Ravishankar (mravishankar@nvidia.com) 21 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | //*************************************************************************** 2 | Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of NVIDIA CORPORATION nor the names of its 13 | contributors may be used to endorse or promote products derived 14 | from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 17 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 24 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | //*************************************************************************** 28 | -------------------------------------------------------------------------------- /experiments/canny/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************# 2 | #* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *# 3 | #* *# 4 | #* Redistribution and use in source and binary forms, with or without *# 5 | #* modification, are permitted provided that the following conditions *# 6 | #* are met: *# 7 | #* * Redistributions of source code must retain the above copyright *# 8 | #* notice, this list of conditions and the following disclaimer. *# 9 | #* * Redistributions in binary form must reproduce the above copyright *# 10 | #* notice, this list of conditions and the following disclaimer in the *# 11 | #* documentation and/or other materials provided with the distribution. *# 12 | #* * Neither the name of NVIDIA CORPORATION nor the names of its *# 13 | #* contributors may be used to endorse or promote products derived *# 14 | #* from this software without specific prior written permission. *# 15 | #* *# 16 | #* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *# 17 | #* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *# 18 | #* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *# 19 | #* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *# 20 | #* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *# 21 | #* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *# 22 | #* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *# 23 | #* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *# 24 | #* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *# 25 | #* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *# 26 | #* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *# 27 | #****************************************************************************# 28 | set(BENCHMARK_NAME canny) 29 | add_all_tests(canny) 30 | -------------------------------------------------------------------------------- /experiments/blur/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************# 2 | #* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *# 3 | #* *# 4 | #* Redistribution and use in source and binary forms, with or without *# 5 | #* modification, are permitted provided that the following conditions *# 6 | #* are met: *# 7 | #* * Redistributions of source code must retain the above copyright *# 8 | #* notice, this list of conditions and the following disclaimer. *# 9 | #* * Redistributions in binary form must reproduce the above copyright *# 10 | #* notice, this list of conditions and the following disclaimer in the *# 11 | #* documentation and/or other materials provided with the distribution. *# 12 | #* * Neither the name of NVIDIA CORPORATION nor the names of its *# 13 | #* contributors may be used to endorse or promote products derived *# 14 | #* from this software without specific prior written permission. *# 15 | #* *# 16 | #* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *# 17 | #* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *# 18 | #* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *# 19 | #* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *# 20 | #* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *# 21 | #* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *# 22 | #* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *# 23 | #* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *# 24 | #* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *# 25 | #* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *# 26 | #* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *# 27 | #****************************************************************************# 28 | set(BENCHMARK_NAME blur) 29 | add_all_tests(${BENCHMARK_NAME}) 30 | -------------------------------------------------------------------------------- /experiments/emboss/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************# 2 | #* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *# 3 | #* *# 4 | #* Redistribution and use in source and binary forms, with or without *# 5 | #* modification, are permitted provided that the following conditions *# 6 | #* are met: *# 7 | #* * Redistributions of source code must retain the above copyright *# 8 | #* notice, this list of conditions and the following disclaimer. *# 9 | #* * Redistributions in binary form must reproduce the above copyright *# 10 | #* notice, this list of conditions and the following disclaimer in the *# 11 | #* documentation and/or other materials provided with the distribution. *# 12 | #* * Neither the name of NVIDIA CORPORATION nor the names of its *# 13 | #* contributors may be used to endorse or promote products derived *# 14 | #* from this software without specific prior written permission. *# 15 | #* *# 16 | #* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *# 17 | #* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *# 18 | #* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *# 19 | #* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *# 20 | #* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *# 21 | #* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *# 22 | #* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *# 23 | #* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *# 24 | #* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *# 25 | #* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *# 26 | #* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *# 27 | #****************************************************************************# 28 | set(BENCHMARK_NAME emboss) 29 | add_all_tests(${BENCHMARK_NAME}) 30 | -------------------------------------------------------------------------------- /experiments/hdr_direct/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************# 2 | #* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *# 3 | #* *# 4 | #* Redistribution and use in source and binary forms, with or without *# 5 | #* modification, are permitted provided that the following conditions *# 6 | #* are met: *# 7 | #* * Redistributions of source code must retain the above copyright *# 8 | #* notice, this list of conditions and the following disclaimer. *# 9 | #* * Redistributions in binary form must reproduce the above copyright *# 10 | #* notice, this list of conditions and the following disclaimer in the *# 11 | #* documentation and/or other materials provided with the distribution. *# 12 | #* * Neither the name of NVIDIA CORPORATION nor the names of its *# 13 | #* contributors may be used to endorse or promote products derived *# 14 | #* from this software without specific prior written permission. *# 15 | #* *# 16 | #* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *# 17 | #* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *# 18 | #* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *# 19 | #* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *# 20 | #* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *# 21 | #* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *# 22 | #* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *# 23 | #* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *# 24 | #* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *# 25 | #* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *# 26 | #* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *# 27 | #****************************************************************************# 28 | set(BENCHMARK_NAME hdr_direct) 29 | add_all_tests(hdr_direct) 30 | -------------------------------------------------------------------------------- /experiments/pyramid/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************# 2 | #* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *# 3 | #* *# 4 | #* Redistribution and use in source and binary forms, with or without *# 5 | #* modification, are permitted provided that the following conditions *# 6 | #* are met: *# 7 | #* * Redistributions of source code must retain the above copyright *# 8 | #* notice, this list of conditions and the following disclaimer. *# 9 | #* * Redistributions in binary form must reproduce the above copyright *# 10 | #* notice, this list of conditions and the following disclaimer in the *# 11 | #* documentation and/or other materials provided with the distribution. *# 12 | #* * Neither the name of NVIDIA CORPORATION nor the names of its *# 13 | #* contributors may be used to endorse or promote products derived *# 14 | #* from this software without specific prior written permission. *# 15 | #* *# 16 | #* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *# 17 | #* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *# 18 | #* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *# 19 | #* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *# 20 | #* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *# 21 | #* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *# 22 | #* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *# 23 | #* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *# 24 | #* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *# 25 | #* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *# 26 | #* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *# 27 | #****************************************************************************# 28 | set(BENCHMARK_NAME pyramid) 29 | add_all_tests(${BENCHMARK_NAME} NO_GOLD) 30 | -------------------------------------------------------------------------------- /experiments/hdr_pyramid/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************# 2 | #* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *# 3 | #* *# 4 | #* Redistribution and use in source and binary forms, with or without *# 5 | #* modification, are permitted provided that the following conditions *# 6 | #* are met: *# 7 | #* * Redistributions of source code must retain the above copyright *# 8 | #* notice, this list of conditions and the following disclaimer. *# 9 | #* * Redistributions in binary form must reproduce the above copyright *# 10 | #* notice, this list of conditions and the following disclaimer in the *# 11 | #* documentation and/or other materials provided with the distribution. *# 12 | #* * Neither the name of NVIDIA CORPORATION nor the names of its *# 13 | #* contributors may be used to endorse or promote products derived *# 14 | #* from this software without specific prior written permission. *# 15 | #* *# 16 | #* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *# 17 | #* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *# 18 | #* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *# 19 | #* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *# 20 | #* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *# 21 | #* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *# 22 | #* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *# 23 | #* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *# 24 | #* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *# 25 | #* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *# 26 | #* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *# 27 | #****************************************************************************# 28 | set(BENCHMARK_NAME hdr_pyramid) 29 | add_all_tests(${BENCHMARK_NAME} NO_GOLD) 30 | -------------------------------------------------------------------------------- /experiments/pyramid_rgb/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************# 2 | #* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *# 3 | #* *# 4 | #* Redistribution and use in source and binary forms, with or without *# 5 | #* modification, are permitted provided that the following conditions *# 6 | #* are met: *# 7 | #* * Redistributions of source code must retain the above copyright *# 8 | #* notice, this list of conditions and the following disclaimer. *# 9 | #* * Redistributions in binary form must reproduce the above copyright *# 10 | #* notice, this list of conditions and the following disclaimer in the *# 11 | #* documentation and/or other materials provided with the distribution. *# 12 | #* * Neither the name of NVIDIA CORPORATION nor the names of its *# 13 | #* contributors may be used to endorse or promote products derived *# 14 | #* from this software without specific prior written permission. *# 15 | #* *# 16 | #* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *# 17 | #* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *# 18 | #* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *# 19 | #* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *# 20 | #* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *# 21 | #* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *# 22 | #* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *# 23 | #* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *# 24 | #* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *# 25 | #* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *# 26 | #* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *# 27 | #****************************************************************************# 28 | set(BENCHMARK_NAME pyramid_rgb) 29 | add_all_tests(${BENCHMARK_NAME} NO_GOLD) 30 | -------------------------------------------------------------------------------- /experiments/pyramid_rgb_mirror/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************# 2 | #* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *# 3 | #* *# 4 | #* Redistribution and use in source and binary forms, with or without *# 5 | #* modification, are permitted provided that the following conditions *# 6 | #* are met: *# 7 | #* * Redistributions of source code must retain the above copyright *# 8 | #* notice, this list of conditions and the following disclaimer. *# 9 | #* * Redistributions in binary form must reproduce the above copyright *# 10 | #* notice, this list of conditions and the following disclaimer in the *# 11 | #* documentation and/or other materials provided with the distribution. *# 12 | #* * Neither the name of NVIDIA CORPORATION nor the names of its *# 13 | #* contributors may be used to endorse or promote products derived *# 14 | #* from this software without specific prior written permission. *# 15 | #* *# 16 | #* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *# 17 | #* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *# 18 | #* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *# 19 | #* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *# 20 | #* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *# 21 | #* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *# 22 | #* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *# 23 | #* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *# 24 | #* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *# 25 | #* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *# 26 | #* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *# 27 | #****************************************************************************# 28 | set(BENCHMARK_NAME pyramid_rgb_mirror) 29 | add_all_tests(${BENCHMARK_NAME} NO_GOLD) 30 | -------------------------------------------------------------------------------- /ctests/offset.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | parameter M,N; 29 | vector#2 float input[M,N]; 30 | output[1..,3..,5..] = input; 31 | return output; -------------------------------------------------------------------------------- /ctests/sample.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | parameter M,N; 29 | vector#2 double input[M,N]; 30 | output = input@[(-1,2),(5,3)]; 31 | return output; -------------------------------------------------------------------------------- /ctests/extrapolate.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | parameter M,N; 29 | vector#2 double input[M,N]; 30 | output@[(-7,3),(5,2)] = input; 31 | return output; -------------------------------------------------------------------------------- /ctests/hello_world.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | parameter M; 29 | parameter N; 30 | vector#2 float input[M,N]; 31 | output = input; 32 | return output; -------------------------------------------------------------------------------- /ctests/hello_world3D.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | parameter L; 29 | parameter M; 30 | parameter N; 31 | vector#3 float input[L,M,N]; 32 | output = input; 33 | return output; -------------------------------------------------------------------------------- /ctests/hello_world4D.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | parameter K; 29 | parameter L; 30 | parameter M; 31 | parameter N; 32 | vector#4 float input[K,L,M,N]; 33 | output = input; 34 | return output; -------------------------------------------------------------------------------- /ctests/unroll.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | parameter M,N; 29 | vector#2 float input[N,M]; 30 | output<0> = input; 31 | for i = 1..3 32 | output = output; 33 | endfor 34 | return output<3>; -------------------------------------------------------------------------------- /ctests/bdy_wrap.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil dx(vector#2 float X){ 29 | return X@[-2,2]; 30 | } 31 | parameter M,N; 32 | vector#2 float input[M,N]; 33 | output = dx(input:wrap); 34 | return output; -------------------------------------------------------------------------------- /ctests/bdy_clamped.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil dx(vector#2 float X){ 29 | return X@[-2,2]; 30 | } 31 | parameter M,N; 32 | vector#2 float input[M,N]; 33 | output = dx(input:clamped); 34 | return output; -------------------------------------------------------------------------------- /ctests/bdy_mirror.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil dx(vector#2 float X){ 29 | return X@[-2,2]; 30 | } 31 | parameter M,N; 32 | vector#2 float input[M,N]; 33 | output = dx(input:mirror); 34 | return output; -------------------------------------------------------------------------------- /ctests/stencil_sampling.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil do_sample(vector#2 double X){ 29 | return X@[(-1,2),(5,3)]; 30 | } 31 | parameter M,N; 32 | vector#2 double input[M,N]; 33 | return do_sample(input); -------------------------------------------------------------------------------- /ctests/sub_domain2.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | parameter M,N; 29 | vector#2 double input1[M,N]; 30 | vector#2 double input2[M,N]; 31 | output = ( [0..,..,..] = input1; [1..,..,..] = input2; ); 32 | return output; -------------------------------------------------------------------------------- /src/ASTVisitor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************# 2 | #* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *# 3 | #* *# 4 | #* Redistribution and use in source and binary forms, with or without *# 5 | #* modification, are permitted provided that the following conditions *# 6 | #* are met: *# 7 | #* * Redistributions of source code must retain the above copyright *# 8 | #* notice, this list of conditions and the following disclaimer. *# 9 | #* * Redistributions in binary form must reproduce the above copyright *# 10 | #* notice, this list of conditions and the following disclaimer in the *# 11 | #* documentation and/or other materials provided with the distribution. *# 12 | #* * Neither the name of NVIDIA CORPORATION nor the names of its *# 13 | #* contributors may be used to endorse or promote products derived *# 14 | #* from this software without specific prior written permission. *# 15 | #* *# 16 | #* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *# 17 | #* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *# 18 | #* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *# 19 | #* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *# 20 | #* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *# 21 | #* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *# 22 | #* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *# 23 | #* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *# 24 | #* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *# 25 | #* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *# 26 | #* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *# 27 | #****************************************************************************# 28 | set(AST_VISITOR_SRCS 29 | ${CMAKE_CURRENT_SOURCE_DIR}/convert_boundaries.cpp 30 | ${CMAKE_CURRENT_SOURCE_DIR}/copy_visitor.cpp 31 | ${CMAKE_CURRENT_SOURCE_DIR}/stencil_visitor.cpp 32 | PARENT_SCOPE) 33 | -------------------------------------------------------------------------------- /ctests/bdy_constant.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil dx(vector#2 float X){ 29 | return X@[-2,2]; 30 | } 31 | parameter M,N; 32 | vector#2 float input[M,N]; 33 | output = dx(input:constant(2)); 34 | return output; -------------------------------------------------------------------------------- /ctests/subdomain_function.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil simple(vector#2 int X){ 29 | return X; 30 | } 31 | parameter M,N; 32 | vector#2 int input[M,N]; 33 | output = simple(input[3..M-1,4..N-2]); 34 | return output; -------------------------------------------------------------------------------- /ctests/vectorfn_subdomain.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | vector simple(vector#2 int X){ 29 | return X; 30 | } 31 | parameter M,N; 32 | vector#2 int input[M,N]; 33 | output = simple(input[3..M-1,4..N-2]); 34 | return output; -------------------------------------------------------------------------------- /experiments/emboss/emboss.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil emboss(vector#2 float X){ 29 | return X@[1,1] + X@[0,1] + X@[1,0] - X@[-1,0] - X@[0,-1] - X@[-1,-1]; 30 | } 31 | parameter M,N; 32 | vector#2 float input[M,N]; 33 | return emboss(input); -------------------------------------------------------------------------------- /ctests/j2d.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil j2d(vector#2 float X) { 29 | res = (1.0f / 5.0f) * (X@[-1,0] + X@[1,0] + X@[0,0] + X@[0,-1] + X@[0,1]); 30 | return res; 31 | } 32 | 33 | vector#2 float input[1000, 1000]; 34 | return j2d(input); 35 | -------------------------------------------------------------------------------- /ctests/sharp.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil sharp(vector#2 float X){ 29 | return 9*X - (X@[-1,-1] + X@[-1,0] + X@[-1,1] + X@[0,1] + X@[0,-1] + X@[1,-1] + X@[1,0] + X@[1,1]); 30 | } 31 | parameter M,N; 32 | vector#2 float input[M,N]; 33 | return sharp(input); -------------------------------------------------------------------------------- /ctests/getmax.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil getmax(vector#2 float a, vector#2 float b){ 29 | return max(a,b); 30 | } 31 | parameter M,N; 32 | vector#2 float input1[M,N]; 33 | vector#2 float input2[M,N]; 34 | output = getmax(input1,input2); 35 | return output; -------------------------------------------------------------------------------- /ctests/try_struct.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | struct RGB{ 29 | int8 r; 30 | int8 g; 31 | int8 b; 32 | } 33 | stencil getr(vector#2 RGB X){ 34 | return struct RGB(X.r,X.g,X.b); 35 | } 36 | parameter M,N; 37 | vector#2 RGB input[M,N]; 38 | return getr(input); -------------------------------------------------------------------------------- /ctests/mixed_bdy_NW.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil bdy(vector#2 float X, vector#2 float Y){ 29 | return X@[-3,-2] + X@[2,3] + Y@[-2,-3] + Y@[3,2]; 30 | } 31 | parameter M,N; 32 | vector#2 float input1[M,N]; 33 | vector#2 float input2[M,N]; 34 | return bdy(input1,input2:wrap); -------------------------------------------------------------------------------- /ctests/simple_stencil.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil simple(vector#2 float X, vector#2 float Y){ 29 | return X@[-3,-2] + X@[2,3] + Y@[-2,-3] + Y@[3,2]; 30 | } 31 | parameter M,N; 32 | vector#2 float input1[M,N]; 33 | vector#2 float input2[M,N]; 34 | return simple(input1,input2); -------------------------------------------------------------------------------- /ctests/mixed_bdy_CM.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil bdy(vector#2 float X, vector#2 float Y){ 29 | return X@[-3,-2] + X@[2,3] + Y@[-2,-3] + Y@[3,2]; 30 | } 31 | parameter M,N; 32 | vector#2 float input1[M,N]; 33 | vector#2 float input2[M,N]; 34 | return bdy(input1:clamped,input2:mirror); -------------------------------------------------------------------------------- /ctests/ternary.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil tern(float a, vector#2 int X, vector#2 int Y){ 29 | return ( a < 0.31414 ? X : Y ); 30 | } 31 | parameter M,N; 32 | float threshold; 33 | vector#2 int input1[M,N]; 34 | vector#2 int input2[M,N]; 35 | return tern(threshold,input1,input2); 36 | -------------------------------------------------------------------------------- /ctests/struct_subdomain.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | struct RGB{ 29 | int8 r; int8 g; int8 b; 30 | } 31 | stencil getr(vector#2 RGB X){ 32 | return X.r; 33 | } 34 | parameter M,N; 35 | vector#2 RGB input[M,N]; 36 | output = struct RGB(getr(input),input.g,input.b); 37 | return output[1..M-2,2..N-3]; -------------------------------------------------------------------------------- /ctests/mixed_bdy.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil dxdy(vector#2 float X, vector#2 float Y){ 29 | dy = 2 * Y - Y@[-1,0] - Y@[1,0]; 30 | dx = 2 * X - X@[0,1] - X@[0,-1]; 31 | return abs(dx) + abs(dy); 32 | } 33 | parameter M,N; 34 | vector#2 float input[M,N]; 35 | return dxdy(input:mirror,input:wrap); -------------------------------------------------------------------------------- /experiments/try.sh: -------------------------------------------------------------------------------- 1 | #****************************************************************************# 2 | #* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *# 3 | #* *# 4 | #* Redistribution and use in source and binary forms, with or without *# 5 | #* modification, are permitted provided that the following conditions *# 6 | #* are met: *# 7 | #* * Redistributions of source code must retain the above copyright *# 8 | #* notice, this list of conditions and the following disclaimer. *# 9 | #* * Redistributions in binary form must reproduce the above copyright *# 10 | #* notice, this list of conditions and the following disclaimer in the *# 11 | #* documentation and/or other materials provided with the distribution. *# 12 | #* * Neither the name of NVIDIA CORPORATION nor the names of its *# 13 | #* contributors may be used to endorse or promote products derived *# 14 | #* from this software without specific prior written permission. *# 15 | #* *# 16 | #* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *# 17 | #* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *# 18 | #* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *# 19 | #* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *# 20 | #* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *# 21 | #* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *# 22 | #* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *# 23 | #* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *# 24 | #* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *# 25 | #* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *# 26 | #* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *# 27 | #****************************************************************************# 28 | #!/bin/bash 29 | for dir in `ls -d */` 30 | do 31 | cd ${dir} 32 | for test in `ls *.x` 33 | do 34 | ./${test} > /dev/null 2> /dev/null 35 | if [ $? -ne 0 ] 36 | then 37 | echo ${test} "FAILED" 38 | else 39 | echo ${test} "PASSED" 40 | fi 41 | done 42 | cd .. 43 | done 44 | -------------------------------------------------------------------------------- /ctests/blur.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil bx(vector#2 int X){ 29 | return (X@[-1,0] + X + X@[1,0]) / 3; 30 | } 31 | stencil by(vector#2 int Y){ 32 | return (Y@[0,-1] + Y + Y@[0,1]) / 3; 33 | } 34 | parameter N,M; 35 | vector#2 int input[N,M]; 36 | blurx = bx(input); 37 | output = by(blurx); 38 | return output; -------------------------------------------------------------------------------- /ctests/blur_int.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil bx(vector#2 int X){ 29 | return (X@[-1,0] + X + X@[1,0]) / 3; 30 | } 31 | stencil by(vector#2 int Y){ 32 | return (Y@[0,-1] + Y + Y@[0,1]) / 3; 33 | } 34 | parameter M,N; 35 | vector#2 int input[M,N]; 36 | blurx = bx(input); 37 | output = by(blurx); 38 | return output; 39 | -------------------------------------------------------------------------------- /ctests/blur_float.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil bx(vector#2 float X){ 29 | return (X@[-1,0] + X + X@[1,0]) / 3; 30 | } 31 | stencil by(vector#2 float Y){ 32 | return (Y@[0,-1] + Y + Y@[0,1]) / 3; 33 | } 34 | parameter M,N; 35 | vector#2 float input[M,N]; 36 | blurx = bx(input); 37 | output = by(blurx); 38 | return output; 39 | -------------------------------------------------------------------------------- /experiments/blur/blur.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil bx(vector#2 float X){ 29 | return (X@[-1,0] + X + X@[1,0]) / 3; 30 | } 31 | stencil by(vector#2 float Y){ 32 | return (Y@[0,-1] + Y + Y@[0,1]) / 3; 33 | } 34 | parameter N,M; 35 | vector#2 float input[N,M]; 36 | blurx = bx(input); 37 | output = by(blurx); 38 | return output; -------------------------------------------------------------------------------- /include/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************# 2 | #* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *# 3 | #* *# 4 | #* Redistribution and use in source and binary forms, with or without *# 5 | #* modification, are permitted provided that the following conditions *# 6 | #* are met: *# 7 | #* * Redistributions of source code must retain the above copyright *# 8 | #* notice, this list of conditions and the following disclaimer. *# 9 | #* * Redistributions in binary form must reproduce the above copyright *# 10 | #* notice, this list of conditions and the following disclaimer in the *# 11 | #* documentation and/or other materials provided with the distribution. *# 12 | #* * Neither the name of NVIDIA CORPORATION nor the names of its *# 13 | #* contributors may be used to endorse or promote products derived *# 14 | #* from this software without specific prior written permission. *# 15 | #* *# 16 | #* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *# 17 | #* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *# 18 | #* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *# 19 | #* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *# 20 | #* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *# 21 | #* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *# 22 | #* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *# 23 | #* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *# 24 | #* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *# 25 | #* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *# 26 | #* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *# 27 | #****************************************************************************# 28 | add_subdirectory(AST) 29 | add_subdirectory(ASTVisitor) 30 | add_subdirectory(CodeGen) 31 | 32 | set(AST_HEADERS ${AST_HEADERS} PARENT_SCOPE) 33 | set(AST_VISITOR_HEADERS ${AST_VISITOR_HEADERS} PARENT_SCOPE) 34 | set(CODEGEN_HEADERS ${CODEGEN_HEADERS} PARENT_SCOPE) 35 | set(AUX_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/program_opts.hpp PARENT_SCOPE) -------------------------------------------------------------------------------- /ctests/blur_double.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil bx(vector#2 double X){ 29 | return (X@[-1,0] + X + X@[1,0]) / 3; 30 | } 31 | stencil by(vector#2 double Y){ 32 | return (Y@[0,-1] + Y + Y@[0,1]) / 3; 33 | } 34 | parameter M,N; 35 | vector#2 double input[M,N]; 36 | blurx = bx(input); 37 | output = by(blurx); 38 | return output; 39 | -------------------------------------------------------------------------------- /ctests/blur_mirror.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil bx(vector#2 float X){ 29 | return (X@[-1,0] + X + X@[1,0]) / 3; 30 | } 31 | stencil by(vector#2 float Y){ 32 | return (Y@[0,-1] + Y + Y@[0,1]) / 3; 33 | } 34 | parameter N,M; 35 | vector#2 float input[N,M]; 36 | blurx = bx(input:mirror); 37 | output = by(blurx:mirror); 38 | return output; -------------------------------------------------------------------------------- /ctests/blur_wrap.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil bx(vector#2 double X){ 29 | return (X@[-1,0] + X + X@[1,0]) / 3.0; 30 | } 31 | stencil by(vector#2 double Y){ 32 | return (Y@[0,-1] + Y + Y@[0,1]) / 3.0; 33 | } 34 | parameter N,M; 35 | vector#2 double input[N,M]; 36 | blurx = bx(input:wrap); 37 | output = by(blurx:wrap); 38 | return output; -------------------------------------------------------------------------------- /experiments/camera_pipe/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************# 2 | #* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *# 3 | #* *# 4 | #* Redistribution and use in source and binary forms, with or without *# 5 | #* modification, are permitted provided that the following conditions *# 6 | #* are met: *# 7 | #* * Redistributions of source code must retain the above copyright *# 8 | #* notice, this list of conditions and the following disclaimer. *# 9 | #* * Redistributions in binary form must reproduce the above copyright *# 10 | #* notice, this list of conditions and the following disclaimer in the *# 11 | #* documentation and/or other materials provided with the distribution. *# 12 | #* * Neither the name of NVIDIA CORPORATION nor the names of its *# 13 | #* contributors may be used to endorse or promote products derived *# 14 | #* from this software without specific prior written permission. *# 15 | #* *# 16 | #* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *# 17 | #* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *# 18 | #* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *# 19 | #* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *# 20 | #* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *# 21 | #* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *# 22 | #* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *# 23 | #* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *# 24 | #* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *# 25 | #* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *# 26 | #* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *# 27 | #****************************************************************************# 28 | set(BENCHMARK_NAME camera_pipe) 29 | add_c_experiment(${BENCHMARK_NAME} ${CMAKE_CURRENT_LIST_DIR}/driver.cpp) 30 | if (CUDA_FOUND) 31 | add_cuda_experiment(${BENCHMARK_NAME} 32 | ${CMAKE_CURRENT_LIST_DIR}/driver_gpu.cpp) 33 | add_texture_experiment(${BENCHMARK_NAME} 34 | ${CMAKE_CURRENT_LIST_DIR}/driver_gpu.cpp) 35 | endif() 36 | -------------------------------------------------------------------------------- /ctests/blur_clamped.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil bx(vector#2 double X){ 29 | return (X@[-1,0] + X + X@[1,0]) / 3.0; 30 | } 31 | stencil by(vector#2 double Y){ 32 | return (Y@[0,-1] + Y + Y@[0,1]) / 3.0; 33 | } 34 | parameter N,M; 35 | vector#2 double input[N,M]; 36 | blurx = bx(input:clamped); 37 | output = by(blurx:clamped); 38 | return output; -------------------------------------------------------------------------------- /ctests/blur_int8.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil bx(vector#2 int8 X){ 29 | return cast((X@[-1,0] + X + X@[1,0]) / 3.0); 30 | } 31 | stencil by(vector#2 int8 Y){ 32 | return cast((Y@[0,-1] + Y + Y@[0,1]) / 3.0); 33 | } 34 | parameter M,N; 35 | vector#2 int8 input[M,N]; 36 | blurx = bx(input); 37 | blury = by(blurx); 38 | return blury; -------------------------------------------------------------------------------- /ctests/blur_int16.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil bx(vector#2 int16 X){ 29 | return cast((X@[-1,0] + X + X@[1,0]) / 3.0); 30 | } 31 | stencil by(vector#2 int16 Y){ 32 | return cast((Y@[0,-1] + Y + Y@[0,1]) / 3.0); 33 | } 34 | parameter M,N; 35 | vector#2 int16 input[M,N]; 36 | blurx = bx(input); 37 | blury = by(blurx); 38 | return blury; -------------------------------------------------------------------------------- /ctests/compose.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil upx_even(vector#2 double X){ 29 | return X@[-1,0] * 0.25 + X * 0.75; 30 | } 31 | stencil upx_odd(vector#2 double X){ 32 | return X@[1,0] * 0.25 + X * 0.75; 33 | } 34 | parameter M,N; 35 | vector#2 double input[M,N]; 36 | return ( @[(0,2),(0,1)] = upx_even(input); 37 | @[(1,2),(0,1)] = upx_odd(input); ); 38 | -------------------------------------------------------------------------------- /experiments/pyramid_mirror/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************# 2 | #* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *# 3 | #* *# 4 | #* Redistribution and use in source and binary forms, with or without *# 5 | #* modification, are permitted provided that the following conditions *# 6 | #* are met: *# 7 | #* * Redistributions of source code must retain the above copyright *# 8 | #* notice, this list of conditions and the following disclaimer. *# 9 | #* * Redistributions in binary form must reproduce the above copyright *# 10 | #* notice, this list of conditions and the following disclaimer in the *# 11 | #* documentation and/or other materials provided with the distribution. *# 12 | #* * Neither the name of NVIDIA CORPORATION nor the names of its *# 13 | #* contributors may be used to endorse or promote products derived *# 14 | #* from this software without specific prior written permission. *# 15 | #* *# 16 | #* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *# 17 | #* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *# 18 | #* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *# 19 | #* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *# 20 | #* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *# 21 | #* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *# 22 | #* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *# 23 | #* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *# 24 | #* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *# 25 | #* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *# 26 | #* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *# 27 | #****************************************************************************# 28 | set(BENCHMARK_NAME pyramid_mirror) 29 | # add_all_tests(${BENCHMARK_NAME} NO_GOLD) 30 | set(C_DRIVER_FILES 31 | ${CMAKE_CURRENT_LIST_DIR}/driver.cpp) 32 | add_c_experiment(${BENCHMARK_NAME} "${C_DRIVER_FILES}") 33 | if (CUDA_FOUND) 34 | set(GPU_DRIVER_FILES 35 | ${CMAKE_CURRENT_LIST_DIR}/driver_gpu.cpp) 36 | add_cuda_experiment(${BENCHMARK_NAME} "${GPU_DRIVER_FILES}") 37 | endif() -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************# 2 | #* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *# 3 | #* *# 4 | #* Redistribution and use in source and binary forms, with or without *# 5 | #* modification, are permitted provided that the following conditions *# 6 | #* are met: *# 7 | #* * Redistributions of source code must retain the above copyright *# 8 | #* notice, this list of conditions and the following disclaimer. *# 9 | #* * Redistributions in binary form must reproduce the above copyright *# 10 | #* notice, this list of conditions and the following disclaimer in the *# 11 | #* documentation and/or other materials provided with the distribution. *# 12 | #* * Neither the name of NVIDIA CORPORATION nor the names of its *# 13 | #* contributors may be used to endorse or promote products derived *# 14 | #* from this software without specific prior written permission. *# 15 | #* *# 16 | #* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *# 17 | #* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *# 18 | #* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *# 19 | #* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *# 20 | #* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *# 21 | #* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *# 22 | #* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *# 23 | #* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *# 24 | #* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *# 25 | #* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *# 26 | #* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *# 27 | #****************************************************************************# 28 | add_subdirectory(AST) 29 | add_subdirectory(CodeGen) 30 | add_subdirectory(ASTVisitor) 31 | set(AST_SRCS ${AST_SRCS} PARENT_SCOPE) 32 | 33 | set(AST_VISITOR_SRCS 34 | ${AST_VISITOR_SRCS} PARENT_SCOPE) 35 | 36 | set(CODEGEN_SRCS 37 | ${CODEGEN_SRCS} PARENT_SCOPE) 38 | 39 | set(AUX_SRCS 40 | ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp 41 | ${CMAKE_CURRENT_SOURCE_DIR}/program_opts.cpp 42 | PARENT_SCOPE) 43 | 44 | -------------------------------------------------------------------------------- /ctests/upsample_mirror.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil upx_even(vector#2 float X){ 29 | return X@[-1,0] * 0.3125f + X * 0.625f + X@[1,0] * 0.0625f; 30 | } 31 | stencil upx_odd(vector#2 float X){ 32 | return X@[-1,0] * 0.0625f + X * 0.625f + X@[1,0] * 0.3125f; 33 | } 34 | parameter M,N; 35 | vector#2 float input[M,N]; 36 | output = ( @[(0,2),(0,1)] = upx_even(input:mirror); 37 | @[(1,2),(0,1)] = upx_odd(input:mirror); ); 38 | return output; 39 | -------------------------------------------------------------------------------- /ctests/j2d-1000x1000-100.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | 29 | stencil j2d(vector#2 float X) { 30 | res = (1.0f / 5.0f) * (X@[-1,0] + X@[1,0] + X@[0,0] + X@[0,-1] + X@[0,1]); 31 | return res; 32 | } 33 | 34 | vector#2 float input[1000, 1000]; 35 | 36 | //return j2d(input); 37 | 38 | out<0> = input; 39 | for i=1..100 40 | // out = ([1...998, 1...998] = j2d(out);); 41 | out = j2d(out); 42 | endfor 43 | 44 | return out<100>; 45 | -------------------------------------------------------------------------------- /ctests/downsample.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil downx(vector#2 float X){ 29 | return 0.0625f * X@[(-2,2),(0,1)] + 0.25f * X@[(-1,2),(0,1)] + 0.375f * X@[(0,2),(0,1)] + 0.25f * X@[(1,2),(0,1)] + 0.0625f * X@[(2,2),(0,1)]; 30 | } 31 | stencil downy(vector#2 float Y){ 32 | return 0.0625f * Y@[(0,1),(-2,2)] + 0.25f * Y@[(0,1),(-1,2)] + 0.375f * Y@[(0,1),(0,2)] + 0.25f * Y@[(0,1),(1,2)] + 0.0625f * Y@[(0,1),(2,2)] ; 33 | } 34 | parameter M,N; 35 | vector#2 float input[M,N]; 36 | return downy(downx(input)); -------------------------------------------------------------------------------- /ctests/downsample_mirror.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil downx(vector#2 float X){ 29 | return 0.0625f * X@[(-2,2),(0,1)] + 0.25f * X@[(-1,2),(0,1)] + 0.375f * X@[(0,2),(0,1)] + 0.25f * X@[(1,2),(0,1)] + 0.0625f * X@[(2,2),(0,1)]; 30 | } 31 | stencil downy(vector#2 float Y){ 32 | return 0.0625f * Y@[(0,1),(-2,2)] + 0.25f * Y@[(0,1),(-1,2)] + 0.375f * Y@[(0,1),(0,2)] + 0.25f * Y@[(0,1),(1,2)] + 0.0625f * Y@[(0,1),(2,2)] ; 33 | } 34 | parameter M,N; 35 | vector#2 float input[M,N]; 36 | return downy(downx(input:mirror):mirror); -------------------------------------------------------------------------------- /include/CodeGen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************# 2 | #* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *# 3 | #* *# 4 | #* Redistribution and use in source and binary forms, with or without *# 5 | #* modification, are permitted provided that the following conditions *# 6 | #* are met: *# 7 | #* * Redistributions of source code must retain the above copyright *# 8 | #* notice, this list of conditions and the following disclaimer. *# 9 | #* * Redistributions in binary form must reproduce the above copyright *# 10 | #* notice, this list of conditions and the following disclaimer in the *# 11 | #* documentation and/or other materials provided with the distribution. *# 12 | #* * Neither the name of NVIDIA CORPORATION nor the names of its *# 13 | #* contributors may be used to endorse or promote products derived *# 14 | #* from this software without specific prior written permission. *# 15 | #* *# 16 | #* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *# 17 | #* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *# 18 | #* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *# 19 | #* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *# 20 | #* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *# 21 | #* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *# 22 | #* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *# 23 | #* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *# 24 | #* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *# 25 | #* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *# 26 | #* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *# 27 | #****************************************************************************# 28 | list (APPEND 29 | CODEGEN_HEADER_FILES 30 | ${CMAKE_CURRENT_SOURCE_DIR}/CodeGen.hpp 31 | ${CMAKE_CURRENT_SOURCE_DIR}/print_C.hpp 32 | ${CMAKE_CURRENT_SOURCE_DIR}/print_CUDA.hpp 33 | ${CMAKE_CURRENT_SOURCE_DIR}/print_dot.hpp 34 | ) 35 | 36 | if(BUILD_WITH_LLVM) 37 | list(APPEND 38 | CODEGEN_HEADER_FILES 39 | ${CMAKE_CURRENT_SOURCE_DIR}/LLVM/CGModule.h 40 | ${CMAKE_CURRENT_SOURCE_DIR}/LLVM/CGFunction.h 41 | ${CMAKE_CURRENT_SOURCE_DIR}/LLVM/CGStencilFn.h 42 | ) 43 | endif() 44 | 45 | set(CODEGEN_HEADERS ${CODEGEN_HEADER_FILES} PARENT_SCOPE) -------------------------------------------------------------------------------- /include/ASTVisitor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************# 2 | #* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *# 3 | #* *# 4 | #* Redistribution and use in source and binary forms, with or without *# 5 | #* modification, are permitted provided that the following conditions *# 6 | #* are met: *# 7 | #* * Redistributions of source code must retain the above copyright *# 8 | #* notice, this list of conditions and the following disclaimer. *# 9 | #* * Redistributions in binary form must reproduce the above copyright *# 10 | #* notice, this list of conditions and the following disclaimer in the *# 11 | #* documentation and/or other materials provided with the distribution. *# 12 | #* * Neither the name of NVIDIA CORPORATION nor the names of its *# 13 | #* contributors may be used to endorse or promote products derived *# 14 | #* from this software without specific prior written permission. *# 15 | #* *# 16 | #* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *# 17 | #* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *# 18 | #* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *# 19 | #* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *# 20 | #* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *# 21 | #* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *# 22 | #* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *# 23 | #* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *# 24 | #* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *# 25 | #* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *# 26 | #* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *# 27 | #****************************************************************************# 28 | # FILE(GLOB ASTVISITOR_HEADERS *.hpp) 29 | 30 | # set(FORMA_HEADERS ${FORMA_HEADERS} ${ASTVISITOR_HEADERS}) 31 | set (AST_VISITOR_HEADERS 32 | ${CMAKE_CURRENT_SOURCE_DIR}/copy_visitor.hpp 33 | ${CMAKE_CURRENT_SOURCE_DIR}/visitor.hpp 34 | ${CMAKE_CURRENT_SOURCE_DIR}/stencil_visitor.hpp 35 | ${CMAKE_CURRENT_SOURCE_DIR}/copy_stencil_expr.hpp 36 | ${CMAKE_CURRENT_SOURCE_DIR}/forward_expr.hpp 37 | ${CMAKE_CURRENT_SOURCE_DIR}/unroll.hpp 38 | ${CMAKE_CURRENT_SOURCE_DIR}/convert_boundaries.hpp 39 | ${CMAKE_CURRENT_SOURCE_DIR}/inline_vectorfn.hpp 40 | PARENT_SCOPE) -------------------------------------------------------------------------------- /experiments/blur/blur_gold.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | void blur_gold(const float* input, int height, int width, float* output) 29 | { 30 | float* blurx = new float[height*width]; 31 | for( int i = 1 ; i < height - 1 ; i++ ) 32 | for( int j = 0 ; j < width ; j++ ) 33 | blurx[i*width+j] = (input[(i-1)*width+j] + input[i*width+j] + input[(i+1)*width+j])/ 3.0; 34 | for( int i = 0 ; i < height ; i++ ) 35 | for( int j = 1 ; j < width - 1 ; j++ ) 36 | output[i*width+j] = (blurx[i*width+j-1] + blurx[i*width+j] + blurx[i*width+j+1])/ 3.0; 37 | delete[] blurx; 38 | } 39 | -------------------------------------------------------------------------------- /ctests/sobel.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil gx(vector#2 int X){ 29 | filter = X@[-1,1] - X@[-1,-1] + 2*(X@[0,1] - X@[0,-1]) + X@[1,1] - X@[1,-1]; 30 | return filter; 31 | } 32 | stencil gy(vector#2 int X){ 33 | filter = X@[-1,-1] - X@[1,-1] + 2*(X@[-1,0] - X@[1,0]) + X@[-1,1] - X@[1,1]; 34 | return filter; 35 | } 36 | stencil combine(vector#2 int X, vector#2 int Y){ 37 | sum = ( X > 0 ? X : -X ) + ( Y > 0 ? Y : -Y ); 38 | clamp_up = ( sum > 255 ? 255 : sum ); 39 | return clamp_up; 40 | } 41 | parameter N,M; 42 | vector#2 int input[N,M]; 43 | return combine(gx(input),gy(input)); 44 | -------------------------------------------------------------------------------- /cuda_header.cu: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | #include "cuda.h" 29 | #include "stdio.h" 30 | 31 | // extern __host__ __device__ int MAX(int a, int b) { return a > b ? a : b; } 32 | // extern __host__ __device__ int MIN(int a, int b) { return a < b ? a : b; } 33 | // extern __host__ __device__ int CEIL(int a, int b) { return ( (a) % (b) == 0 ? (a) / (b) : ( (a) / (b) + 1 ) ); } 34 | 35 | void Check_CUDA_Error(const char* message){ 36 | cudaError_t error = cudaGetLastError(); 37 | if( error != cudaSuccess ){ 38 | printf("CUDA-ERROR:%s, %s\n",message,cudaGetErrorString(error) ); 39 | exit(-1); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/CodeGen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************# 2 | #* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *# 3 | #* *# 4 | #* Redistribution and use in source and binary forms, with or without *# 5 | #* modification, are permitted provided that the following conditions *# 6 | #* are met: *# 7 | #* * Redistributions of source code must retain the above copyright *# 8 | #* notice, this list of conditions and the following disclaimer. *# 9 | #* * Redistributions in binary form must reproduce the above copyright *# 10 | #* notice, this list of conditions and the following disclaimer in the *# 11 | #* documentation and/or other materials provided with the distribution. *# 12 | #* * Neither the name of NVIDIA CORPORATION nor the names of its *# 13 | #* contributors may be used to endorse or promote products derived *# 14 | #* from this software without specific prior written permission. *# 15 | #* *# 16 | #* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *# 17 | #* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *# 18 | #* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *# 19 | #* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *# 20 | #* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *# 21 | #* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *# 22 | #* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *# 23 | #* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *# 24 | #* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *# 25 | #* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *# 26 | #* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *# 27 | #****************************************************************************# 28 | list(APPEND 29 | CODEGEN_SRC_FILES 30 | ${CMAKE_CURRENT_SOURCE_DIR}/CodeGen.cpp 31 | ${CMAKE_CURRENT_SOURCE_DIR}/print_C.cpp 32 | ${CMAKE_CURRENT_SOURCE_DIR}/print_CUDA.cpp 33 | ${CMAKE_CURRENT_SOURCE_DIR}/print_dot.cpp 34 | ) 35 | 36 | if( BUILD_WITH_LLVM) 37 | list(APPEND 38 | CODEGEN_SRC_FILES 39 | ${CMAKE_CURRENT_SOURCE_DIR}/LLVM/CGStencilFn.cpp 40 | ${CMAKE_CURRENT_SOURCE_DIR}/LLVM/CGExpr.cpp 41 | ${CMAKE_CURRENT_SOURCE_DIR}/LLVM/CGFunction.cpp 42 | ${CMAKE_CURRENT_SOURCE_DIR}/LLVM/CGModule.cpp 43 | ) 44 | endif() 45 | 46 | 47 | set(CODEGEN_SRCS ${CODEGEN_SRC_FILES} PARENT_SCOPE) -------------------------------------------------------------------------------- /src/AST/stencil_expr.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | #include "AST/stencil_expr.hpp" 29 | 30 | template<> 31 | void value_node::set_type() 32 | { 33 | elem_type.assign(T_INT); 34 | } 35 | 36 | template<> 37 | void value_node::set_type() 38 | { 39 | elem_type.assign(T_FLOAT); 40 | } 41 | 42 | template<> 43 | void value_node::set_type() 44 | { 45 | elem_type.assign(T_DOUBLE); 46 | } 47 | 48 | 49 | template<> 50 | void value_node::set_type() 51 | { 52 | elem_type.assign(T_INT8); 53 | } 54 | 55 | template<> 56 | void value_node::set_type() 57 | { 58 | elem_type.assign(T_INT16); 59 | } 60 | -------------------------------------------------------------------------------- /llvm_helper.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | #include 29 | #include 30 | #include 31 | extern "C" 32 | void *__formart_alloc(size_t size, int init_zero) { 33 | char* buffer = new char[size]; 34 | if( init_zero == 1 ) 35 | memset(buffer,0,size); 36 | return buffer; 37 | } 38 | 39 | extern "C" 40 | void __formart_dealloc(char* ptr){ 41 | delete[] ptr; 42 | } 43 | 44 | extern "C" 45 | int min(int a, int b){ 46 | return (a < b ? a : b ); 47 | } 48 | 49 | extern "C" 50 | double absd(double a){ 51 | return fabs(a); 52 | } 53 | 54 | extern "C" 55 | int max( int a , int b){ 56 | return ( a > b ? a : b ); 57 | } 58 | -------------------------------------------------------------------------------- /include/AST/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************# 2 | #* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *# 3 | #* *# 4 | #* Redistribution and use in source and binary forms, with or without *# 5 | #* modification, are permitted provided that the following conditions *# 6 | #* are met: *# 7 | #* * Redistributions of source code must retain the above copyright *# 8 | #* notice, this list of conditions and the following disclaimer. *# 9 | #* * Redistributions in binary form must reproduce the above copyright *# 10 | #* notice, this list of conditions and the following disclaimer in the *# 11 | #* documentation and/or other materials provided with the distribution. *# 12 | #* * Neither the name of NVIDIA CORPORATION nor the names of its *# 13 | #* contributors may be used to endorse or promote products derived *# 14 | #* from this software without specific prior written permission. *# 15 | #* *# 16 | #* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *# 17 | #* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *# 18 | #* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *# 19 | #* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *# 20 | #* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *# 21 | #* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *# 22 | #* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *# 23 | #* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *# 24 | #* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *# 25 | #* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *# 26 | #* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *# 27 | #****************************************************************************# 28 | # FILE(GLOB AST_HEADERS *.hpp) 29 | # set(FORMA_HEADERS ${FORMA_HEADERS} ${AST_HEADERS}) 30 | set (AST_HEADERS 31 | ${CMAKE_CURRENT_SOURCE_DIR}/data_types.hpp 32 | ${CMAKE_CURRENT_SOURCE_DIR}/domain.hpp 33 | ${CMAKE_CURRENT_SOURCE_DIR}/fn_defn.hpp 34 | ${CMAKE_CURRENT_SOURCE_DIR}/local_scalars.hpp 35 | ${CMAKE_CURRENT_SOURCE_DIR}/parametric.hpp 36 | ${CMAKE_CURRENT_SOURCE_DIR}/parser.hpp 37 | ${CMAKE_CURRENT_SOURCE_DIR}/pretty_print.hpp 38 | ${CMAKE_CURRENT_SOURCE_DIR}/stencil_expr.hpp 39 | ${CMAKE_CURRENT_SOURCE_DIR}/symbol_table.hpp 40 | ${CMAKE_CURRENT_SOURCE_DIR}/vector_defn.hpp 41 | ${CMAKE_CURRENT_SOURCE_DIR}/vector_expr.hpp 42 | ${CMAKE_CURRENT_SOURCE_DIR}/vector_stmt.hpp 43 | PARENT_SCOPE) -------------------------------------------------------------------------------- /ctests/upsample.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil upx_even(vector#2 float X){ 29 | return X@[-1,0] * 0.25f + X * 0.75f; 30 | } 31 | stencil upx_odd(vector#2 float X){ 32 | return X@[1,0] * 0.25f + X * 0.75f; 33 | } 34 | vector upx(vector#2 float X){ 35 | return ( @[(0,2),(0,1)] = upx_even(X); 36 | @[(1,2),(0,1)] = upx_odd(X); ); 37 | } 38 | stencil upy_even(vector#2 float Y){ 39 | return Y@[0,-1] * 0.25f + Y * 0.75f; 40 | } 41 | stencil upy_odd(vector#2 float Y){ 42 | return Y@[0,1] * 0.25f + Y * 0.75f; 43 | } 44 | vector upy(vector#2 float Y){ 45 | return ( @[(0,1),(0,2)] = upy_even(Y); 46 | @[(0,1),(1,2)] = upy_odd(Y); ); 47 | } 48 | parameter M,N; 49 | vector#2 float input[M,N]; 50 | return upy(upx(input)); -------------------------------------------------------------------------------- /include/ASTVisitor/convert_boundaries.hpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | #ifndef __CONVERT_BOUNDARIES_HPP__ 29 | #define __CONVERT_BOUNDARIES_HPP__ 30 | 31 | #include "ASTVisitor/visitor.hpp" 32 | 33 | class ConvertBoundaries{ 34 | 35 | private: 36 | 37 | class Visitor: public ASTVisitor { 38 | 39 | private: 40 | 41 | vector_expr_node* create_init_expression(const arg_info&); 42 | 43 | vector_expr_node* create_value_expression(int); 44 | 45 | vector_expr_node* visit_fnid_expr(fnid_expr_node*, void*); 46 | 47 | public: 48 | 49 | Visitor() { }; 50 | 51 | ~Visitor() { }; 52 | 53 | } visitor; 54 | 55 | public: 56 | 57 | ConvertBoundaries() { } 58 | 59 | void visit(program_node* curr_program){ 60 | visitor.visit(curr_program,NULL); 61 | } 62 | 63 | ~ConvertBoundaries() { } 64 | 65 | }; 66 | 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /include/ASTVisitor/copy_visitor.hpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | #ifndef __COPY_VISITOR_HPP__ 29 | #define __COPY_VISITOR_HPP__ 30 | 31 | 32 | #include "AST/parser.hpp" 33 | 34 | class CopyVectorExpr{ 35 | 36 | public: 37 | 38 | vector_expr_node* copy(const vector_expr_node*); 39 | 40 | domainfn_node* copy(const domainfn_node*); 41 | 42 | domain_node* copy(const domain_node*); 43 | 44 | bdy_info* copy(const bdy_info*); 45 | 46 | private: 47 | 48 | domain_desc_node* copy(const domain_desc_node*); 49 | 50 | compose_expr_node* copy(const compose_expr_node*); 51 | 52 | vec_id_expr_node* copy(const vec_id_expr_node*); 53 | 54 | make_struct_node* copy(const make_struct_node*); 55 | 56 | fnid_expr_node* copy(const fnid_expr_node*); 57 | 58 | vec_domainfn_node* copy(const vec_domainfn_node*); 59 | 60 | expr_node* copy(const expr_node*); 61 | 62 | }; 63 | 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /include/AST/local_scalars.hpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | #ifndef __LOCAL_SCALARS_HPP__ 29 | #define __LOCAL_SCALARS_HPP__ 30 | 31 | #include "AST/data_types.hpp" 32 | 33 | struct scalar_sym_info { 34 | data_types data_type; 35 | scalar_sym_info(data_types); 36 | }; 37 | 38 | /** Class to represent the symbol table within the stencilfn. These 39 | dont include arguments (which cant be overwritten). These include 40 | only variables defined within the function */ 41 | class local_scalar_symbols : public symbol_table { 42 | 43 | public: 44 | 45 | ///Adds the current definition to the symbol table, overwriting the 46 | ///existing definition 47 | void add_local_scalar(const char*,const expr_node*); 48 | 49 | ///Destructor 50 | ~local_scalar_symbols(){ 51 | for( std::deque >::iterator it = symbols.begin() ; it != symbols.end() ; it++ ) 52 | delete it->second; 53 | symbols.clear(); 54 | } 55 | 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /include/ASTVisitor/stencil_visitor.hpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | #ifndef __STENCIL_VISITOR_HPP__ 29 | #define __STENCIL_VISITOR_HPP__ 30 | 31 | #include "AST/parser.hpp" 32 | 33 | 34 | class StencilExprVisitor{ 35 | 36 | public: 37 | 38 | StencilExprVisitor() { } 39 | 40 | virtual ~StencilExprVisitor() { } 41 | 42 | virtual void visit_stmt(pt_stmt_node* ); 43 | 44 | virtual expr_node* visit(expr_node* ); 45 | 46 | protected: 47 | 48 | virtual expr_node* visit_unary_expr(unary_neg_expr_node* ); 49 | 50 | virtual expr_node* visit_math_fn(math_fn_expr_node* ); 51 | 52 | virtual expr_node* visit_id(id_expr_node* a) { return NULL; } 53 | 54 | virtual expr_node* visit_ternary(ternary_expr_node*); 55 | 56 | virtual expr_node* visit_expr_op(expr_op_node*); 57 | 58 | virtual expr_node* visit_pt_struct(pt_struct_node*); 59 | 60 | virtual expr_node* visit_stencil_op(stencil_op_node* a ) { return NULL; } 61 | 62 | virtual expr_node* visit_array_access(array_access_node* a); 63 | 64 | }; 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /experiments/canny/canny.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil gaussian(vector#2 float X){ 29 | return (2 * X@[-2,-2] + 4 * X@[-2,-1] + 5 * X@[-2,0] + 4 * X@[-2,1] + 2 * X@[-2,2] + 4 * X@[-1,-2] + 9 * X@[-1,-1] + 12 * X@[-1,0] + 9 * X@[-1,1] + 4 * X@[-1,2] + 5 * X@[0,-2] + 12 * X@[0,-1] + 15 * X@[0,0] + 12 * X@[0,1] + 5 * X@[0,2] + 4 * X@[1,-2] + 9 * X@[1,-1] + 12 * X@[1,0] + 9 * X@[1,1] + 4 * X@[1,2] + 2 * X@[2,-2] + 4 * X@[2,-1] + 5 * X@[2,0] + 4 * X@[2,1] + 2 * X@[2,2] ) / 159; 30 | } 31 | stencil gradientx(vector#2 float X){ 32 | filter = X@[-1,1] - X@[-1,-1] + 2*(X@[0,1] - X@[0,-1]) + X@[1,1] - X@[1,-1]; 33 | return filter; 34 | } 35 | stencil gradienty(vector#2 float X){ 36 | filter = X@[1,-1] - X@[-1,-1] + 2*(X@[1,0] - X@[-1,0]) + X@[1,1] - X@[-1,1]; 37 | return filter; 38 | } 39 | stencil magnitude(vector#2 float X, vector#2 float Y){ 40 | return X + Y; 41 | } 42 | parameter N,M; 43 | vector#2 float input[N,M]; 44 | blurred = gaussian(input); 45 | gx = gradientx(blurred); 46 | gy = gradienty(blurred); 47 | return magnitude(gx,gy); 48 | -------------------------------------------------------------------------------- /ctests/canny_mirror.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil gaussian(vector#2 float X){ 29 | return (2 * X@[-2,-2] + 4 * X@[-2,-1] + 5 * X@[-2,0] + 4 * X@[-2,1] + 2 * X@[-2,2] + 4 * X@[-1,-2] + 9 * X@[-1,-1] + 12 * X@[-1,0] + 9 * X@[-1,1] + 4 * X@[-1,2] + 5 * X@[0,-2] + 12 * X@[0,-1] + 15 * X@[0,0] + 12 * X@[0,1] + 5 * X@[0,2] + 4 * X@[1,-2] + 9 * X@[1,-1] + 12 * X@[1,0] + 9 * X@[1,1] + 4 * X@[1,2] + 2 * X@[2,-2] + 4 * X@[2,-1] + 5 * X@[2,0] + 4 * X@[2,1] + 2 * X@[2,2] ) / 159; 30 | } 31 | stencil gradientx(vector#2 float X){ 32 | filter = X@[-1,1] - X@[-1,-1] + 2*(X@[0,1] - X@[0,-1]) + X@[1,1] - X@[1,-1]; 33 | return filter; 34 | } 35 | stencil gradienty(vector#2 float X){ 36 | filter = X@[1,-1] - X@[-1,-1] + 2*(X@[1,0] - X@[-1,0]) + X@[1,1] - X@[-1,1]; 37 | return filter; 38 | } 39 | stencil magnitude(vector#2 float X, vector#2 float Y){ 40 | return X + Y; 41 | } 42 | parameter N,M; 43 | vector#2 float input[N,M]; 44 | blurred = gaussian(input:mirror); 45 | gx = gradientx(blurred:mirror); 46 | gy = gradienty(blurred:mirror); 47 | return magnitude(gx,gy); -------------------------------------------------------------------------------- /src/AST/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************# 2 | #* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *# 3 | #* *# 4 | #* Redistribution and use in source and binary forms, with or without *# 5 | #* modification, are permitted provided that the following conditions *# 6 | #* are met: *# 7 | #* * Redistributions of source code must retain the above copyright *# 8 | #* notice, this list of conditions and the following disclaimer. *# 9 | #* * Redistributions in binary form must reproduce the above copyright *# 10 | #* notice, this list of conditions and the following disclaimer in the *# 11 | #* documentation and/or other materials provided with the distribution. *# 12 | #* * Neither the name of NVIDIA CORPORATION nor the names of its *# 13 | #* contributors may be used to endorse or promote products derived *# 14 | #* from this software without specific prior written permission. *# 15 | #* *# 16 | #* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *# 17 | #* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *# 18 | #* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *# 19 | #* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *# 20 | #* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *# 21 | #* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *# 22 | #* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *# 23 | #* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *# 24 | #* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *# 25 | #* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *# 26 | #* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *# 27 | #****************************************************************************# 28 | find_program(FLEX flex) 29 | if (NOT FLEX) 30 | message(FATAL_ERROR "flex not found. Please add path to flex to PATH") 31 | endif() 32 | execute_process( 33 | COMMAND ${FLEX} -o lex.yy.c tokenize.lex 34 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 35 | ) 36 | 37 | find_program(BISON bison) 38 | if (NOT BISON) 39 | message(FATAL_ERROR "bison not found. Please add path to bison to PATH") 40 | endif() 41 | execute_process( 42 | COMMAND ${BISON} -d -b parser parser.y 43 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 44 | ) 45 | 46 | set(AST_SRCS 47 | ${CMAKE_CURRENT_SOURCE_DIR}/data_types.cpp 48 | ${CMAKE_CURRENT_SOURCE_DIR}/domain.cpp 49 | ${CMAKE_CURRENT_SOURCE_DIR}/fn_defn.cpp 50 | ${CMAKE_CURRENT_SOURCE_DIR}/lex.yy.c 51 | ${CMAKE_CURRENT_SOURCE_DIR}/parametric.cpp 52 | ${CMAKE_CURRENT_SOURCE_DIR}/parser.tab.c 53 | ${CMAKE_CURRENT_SOURCE_DIR}/print_node.cpp 54 | ${CMAKE_CURRENT_SOURCE_DIR}/pretty_print.cpp 55 | ${CMAKE_CURRENT_SOURCE_DIR}/stencil_expr.cpp 56 | ${CMAKE_CURRENT_SOURCE_DIR}/symbol_table.cpp 57 | ${CMAKE_CURRENT_SOURCE_DIR}/vector_expr.cpp 58 | PARENT_SCOPE) 59 | 60 | 61 | -------------------------------------------------------------------------------- /include/CodeGen/print_LLVM.hpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | 29 | #ifdef FORMA_USE_LLVM 30 | 31 | #include "program_opts.hpp" 32 | #include "AST/parser.hpp" 33 | #include "llvm/IR/DerivedTypes.h" 34 | #include "llvm/IR/IRBuilder.h" 35 | #include "llvm/IR/LLVMContext.h" 36 | #include "llvm/IR/Type.h" 37 | 38 | 39 | /// Base class for LLVM-based targets 40 | class PrintLLVM { 41 | public: 42 | PrintLLVM(); 43 | virtual ~PrintLLVM(); 44 | 45 | virtual void print_program(const program_node *, const program_options &) = 0; 46 | 47 | 48 | protected: 49 | 50 | /// Context for the LLVM code generator 51 | struct CGContext { 52 | CGContext(llvm::LLVMContext &ctx) 53 | : builder(ctx) {} 54 | 55 | llvm::IRBuilder<> builder; 56 | }; 57 | 58 | 59 | llvm::Type *getTypeForFormaType(const data_types &type); 60 | llvm::LLVMContext &getLLVMContext() { return Ctx; } 61 | const llvm::LLVMContext &getLLVMContext() const { return Ctx; } 62 | 63 | llvm::Value *generateExpr(const expr_node *expr, 64 | CGContext &context); 65 | llvm::Value *generateConstant(const expr_node *expr, 66 | CGContext &context); 67 | llvm::Value *generateBinaryOp(const expr_op_node *expr, 68 | CGContext &context); 69 | llvm::Value *generateStencilOp(const stencil_op_node *expr, 70 | CGContext &context); 71 | 72 | private: 73 | 74 | llvm::LLVMContext Ctx; 75 | 76 | }; 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /include/CodeGen/print_dot.hpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | #ifndef __PRINT_DOT_HPP__ 29 | #define __PRINT_DOT_HPP__ 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include "CodeGen.hpp" 36 | 37 | typedef std::map dot_symbol_table; 38 | typedef std::pair dot_symbol_entry; 39 | 40 | class PrintDot : public CodeGen{ 41 | 42 | public: 43 | 44 | PrintDot(){ 45 | node_count = 0; 46 | } 47 | 48 | void GenerateCode(const program_node* curr_program, const program_options& program_opts); 49 | 50 | private: 51 | 52 | int node_count; 53 | 54 | std::stringstream output_stream; 55 | 56 | void print(const vectorfn_defn_node*); 57 | 58 | void print(const stmt_node*, dot_symbol_table&); 59 | 60 | void print(const vector_expr_node*, dot_symbol_table&, std::set&); 61 | 62 | void print(const vector_defn_node*, dot_symbol_table&); 63 | 64 | void print(const fnid_expr_node*, dot_symbol_table&, std::set&); 65 | 66 | void print(const compose_expr_node*, dot_symbol_table&, std::set&); 67 | 68 | void print(const make_struct_node*, dot_symbol_table&, std::set&); 69 | 70 | void print(const vec_domainfn_node*, dot_symbol_table&, std::set&); 71 | 72 | void print(const stencilfn_defn_node*, std::stringstream& )const; 73 | 74 | void print(const domain_node* , std::stringstream& )const; 75 | 76 | void print(const parametric_exp*, std::stringstream&) const; 77 | 78 | void print(const domainfn_node*, std::stringstream& )const; 79 | }; 80 | 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /ctests/canny_float.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil gaussian(vector#2 float X){ 29 | return (2 * X@[-2,-2] + 4 * X@[-2,-1] + 5 * X@[-2,0] + 4 * X@[-2,1] + 2 * X@[-2,2] + 4 * X@[-1,-2] + 9 * X@[-1,-1] + 12 * X@[-1,0] + 9 * X@[-1,1] + 4 * X@[-1,2] + 5 * X@[0,-2] + 12 * X@[0,-1] + 15 * X@[0,0] + 12 * X@[0,1] + 5 * X@[0,2] + 4 * X@[1,-2] + 9 * X@[1,-1] + 12 * X@[1,0] + 9 * X@[1,1] + 4 * X@[1,2] + 2 * X@[2,-2] + 4 * X@[2,-1] + 5 * X@[2,0] + 4 * X@[2,1] + 2 * X@[2,2] ) / 159; 30 | } 31 | stencil gradientx(vector#2 float X){ 32 | filter = X@[-1,1] - X@[-1,-1] + 2*(X@[0,1] - X@[0,-1]) + X@[1,1] - X@[1,-1]; 33 | return filter; 34 | } 35 | stencil gradienty(vector#2 float X){ 36 | filter = X@[-1,-1] - X@[1,-1] + 2*(X@[-1,0] - X@[1,0]) + X@[-1,1] - X@[1,1]; 37 | return filter; 38 | } 39 | stencil magnitude(vector#2 float X, vector#2 float Y){ 40 | return absd(X) + absd(Y); 41 | } 42 | stencil suppress(vector#2 float gx, vector#2 float gy, vector#2 float mag){ 43 | theta = ( gx == 0 ? ( 3.14156f / 2 ) : atan(gy/gx)) ; 44 | result = ( theta < -3 * 3.14156f / 8 ? ( mag > max(mag@[-1,0],mag@[1,0]) ? mag : 0.0f ) : ( theta < -3.14156f / 8 ? ( mag > max(mag@[1,1],mag@[-1,-1]) ? mag : 0.0f ) : ( theta < 3.14156f / 8 ? ( mag > max(mag@[0,1],mag@[0,-1]) ? mag : 0.0f ) : ( theta < 3 * 3.14156f / 8 ? ( mag > max(mag@[-1,1],mag@[1,-1]) ? mag : 0.0f ) : ( mag > max(mag@[-1,0],mag@[0,1]) ? mag : 0.0f ) ) ) ) ); 45 | return result; 46 | } 47 | parameter N,M; 48 | vector#2 float input[N,M]; 49 | blurred = gaussian(input); 50 | gx = gradientx(blurred); 51 | gy = gradienty(blurred); 52 | mag = magnitude(gx,gy); 53 | return suppress(gx,gy,mag); -------------------------------------------------------------------------------- /ctests/canny.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil gaussian(vector#2 double X){ 29 | return (2 * X@[-2,-2] + 4 * X@[-2,-1] + 5 * X@[-2,0] + 4 * X@[-2,1] + 2 * X@[-2,2] + 4 * X@[-1,-2] + 9 * X@[-1,-1] + 12 * X@[-1,0] + 9 * X@[-1,1] + 4 * X@[-1,2] + 5 * X@[0,-2] + 12 * X@[0,-1] + 15 * X@[0,0] + 12 * X@[0,1] + 5 * X@[0,2] + 4 * X@[1,-2] + 9 * X@[1,-1] + 12 * X@[1,0] + 9 * X@[1,1] + 4 * X@[1,2] + 2 * X@[2,-2] + 4 * X@[2,-1] + 5 * X@[2,0] + 4 * X@[2,1] + 2 * X@[2,2] ) / 159; 30 | } 31 | stencil gradientx(vector#2 double X){ 32 | filter = (X@[-1,1] - X@[-1,-1]) + 2*(X@[0,1] - X@[0,-1]) + (X@[1,1] - X@[1,-1]); 33 | return filter; 34 | } 35 | stencil gradienty(vector#2 double X){ 36 | filter = (X@[-1,-1] - X@[1,-1]) + 2*(X@[-1,0] - X@[1,0]) + (X@[-1,1] - X@[1,1]); 37 | return filter; 38 | } 39 | stencil magnitude(vector#2 double X, vector#2 double Y){ 40 | return fabs(X) + fabs(Y); 41 | } 42 | stencil suppress(vector#2 double gx, vector#2 double gy, vector#2 double mag){ 43 | theta = ( gx == 0 ? ( 3.14156 / 2 ) : atan(gy/gx)) ; 44 | result = ( theta < -3 * 3.14156 / 8 ? ( mag > max(mag@[-1,0],mag@[1,0]) ? mag : 0.0 ) : ( theta < -3.14156 / 8 ? ( mag > max(mag@[1,1],mag@[-1,-1]) ? mag : 0.0 ) : ( theta < 3.14156 / 8 ? ( mag > max(mag@[0,1],mag@[0,-1]) ? mag : 0.0 ) : ( theta < 3 * 3.14156 / 8 ? ( mag > max(mag@[-1,1],mag@[1,-1]) ? mag : 0.0 ) : ( mag > max(mag@[-1,0],mag@[0,1]) ? mag : 0.0 ) ) ) ) ); 45 | return result; 46 | } 47 | parameter M,N; 48 | vector#2 double input[M,N]; 49 | blurred = gaussian(input); 50 | gx = gradientx(blurred); 51 | gy = gradienty(blurred); 52 | mag = magnitude(gx,gy); 53 | return suppress(gx,gy,mag); 54 | -------------------------------------------------------------------------------- /experiments/emboss/emboss_gold.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | /* 29 | * Copyright 2014 NVIDIA Corporation. All rights reserved. 30 | * 31 | * NOTICE TO USER: The source code, and related code and software 32 | * ("Code"), is copyrighted under U.S. and international laws. 33 | * 34 | * NVIDIA Corporation owns the copyright and any patents issued or 35 | * pending for the Code. 36 | * 37 | * NVIDIA CORPORATION MAKES NO REPRESENTATION ABOUT THE SUITABILITY 38 | * OF THIS CODE FOR ANY PURPOSE. IT IS PROVIDED "AS-IS" WITHOUT EXPRESS 39 | * OR IMPLIED WARRANTY OF ANY KIND. NVIDIA CORPORATION DISCLAIMS ALL 40 | * WARRANTIES WITH REGARD TO THE CODE, INCLUDING NON-INFRINGEMENT, AND 41 | * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 42 | * PURPOSE. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY 43 | * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 44 | * WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATED TO THE USE OR 45 | * PERFORMANCE OF THE CODE, INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT, 46 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 47 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, AND WHETHER OR NOT THE 48 | * POSSIBILITY OF SUCH DAMAGES WERE KNOWN OR MADE KNOWN TO NVIDIA 49 | * CORPORATION. 50 | */ 51 | extern void emboss_gold(const float*,int,int,float*); 52 | 53 | void emboss_gold(const float* input, int height, int width, float* output) 54 | { 55 | for( int i = 1 ; i < height - 1 ; i++ ) 56 | for( int j = 1 ; j < width - 1 ; j++ ) 57 | output[i*width+j] = input[(i+1)*width+(j+1)] + input[i*width+j+1] + input[(i+1)*width+j] - input[(i-1)*width+j] - input[i*width+j-1] - input[(i-1)*width+j-1]; 58 | } 59 | -------------------------------------------------------------------------------- /ctests/hdr_direct.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | struct rgb { double r ; double g ; double b; } 29 | stencil make_grey(vector#2 rgb X){ 30 | return (0.02126 * X.r + 0.7152 * X.g + 0.0722 * X.b) / 255; 31 | } 32 | stencil laplacian(vector#2 double X){ 33 | return 4 * X - ( X@[-1,0] + X@[0,-1] + X@[1,0] + X@[0,1] ); 34 | } 35 | stencil saturation(vector#2 rgb X){ 36 | average = ( X.r + X.g + X.b ) / 3.0; 37 | std_dev = sqrt( ( ( X.r - average)*(X.r - average) + (X.b - average)*(X.b - average) + (X.g - average)*(X.g - average) ) / 3.0 ); 38 | return std_dev; 39 | } 40 | stencil well_exposed(vector#2 rgb Y){ 41 | red_var = (Y.r/255.0) - 0.5; 42 | red = exp(-12.5 * red_var * red_var ); 43 | green_var = (Y.g/255.0) - 0.5; 44 | green = exp(-12.5 * green_var * green_var); 45 | blue_var = (Y.b/255.0) - 0.5; 46 | blue = exp(-12.5 * blue_var * blue_var); 47 | return red * green * blue; 48 | } 49 | stencil multiply(vector#2 double X, vector#2 double Y, vector#2 double Z){ 50 | return X * Y * Z ; 51 | } 52 | vector compute_weights(vector#2 rgb image){ 53 | grey = make_grey(image); 54 | laplacian = laplacian(grey); 55 | saturation = saturation(image); 56 | well_exposed = well_exposed(image); 57 | return multiply(laplacian,saturation,well_exposed); 58 | } 59 | stencil combine(vector#2 double W1, vector#2 rgb I1, vector#2 double W2, vector#2 rgb I2){ 60 | sum = W1 + W2; 61 | red = ( W1 * I1.r + W2 * I2.r ) / sum; 62 | green = ( W1 * I1.g + W2 * I2.g ) / sum; 63 | blue = ( W1 * I1.b + W2 * I2.b ) / sum; 64 | return struct rgb(red,green,blue); 65 | } 66 | parameter M,N; 67 | vector#2 rgb image1[M,N]; 68 | vector#2 rgb image2[M,N]; 69 | weights1 = compute_weights(image1); 70 | weights2 = compute_weights(image2); 71 | return combine(weights1,image1,weights2,image2); 72 | -------------------------------------------------------------------------------- /experiments/pyramid/pyramid.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil downx(vector#2 float X){ 29 | return 0.0625f * X@[(-2,2),(0,1)] + 0.25f * X@[(-1,2),(0,1)] + 0.375f * X@[(0,2),(0,1)] + 0.25f * X@[(1,2),(0,1)] + 0.0625f * X@[(2,2),(0,1)]; 30 | } 31 | stencil downy(vector#2 float Y){ 32 | return 0.0625f * Y@[(0,1),(-2,2)] + 0.25f * Y@[(0,1),(-1,2)] + 0.375f * Y@[(0,1),(0,2)] + 0.25f * Y@[(0,1),(1,2)] + 0.0625f * Y@[(0,1),(2,2)] ; 33 | } 34 | vector downsample(vector#2 float X){ 35 | return downy(downx(X)); 36 | } 37 | stencil upx_even(vector#2 float X){ 38 | return X@[-1,0] * 0.3125f + X * 0.625f + X@[1,0] * 0.0625f; 39 | } 40 | stencil upx_odd(vector#2 float X){ 41 | return X@[-1,0] * 0.0625f + X * 0.625f + X@[1,0] * 0.3125f; 42 | } 43 | vector upx(vector#2 float X){ 44 | return ( @[(0,2),(0,1)] = upx_even(X); 45 | @[(1,2),(0,1)] = upx_odd(X); ); 46 | } 47 | stencil upy_even(vector#2 float X){ 48 | return X@[0,-1] * 0.3125f + X * 0.625f + X@[0,1] * 0.0625f; 49 | } 50 | stencil upy_odd(vector#2 float X){ 51 | return X@[0,-1] * 0.0625f + X * 0.625f + X@[0,1] * 0.3125f ; 52 | } 53 | vector upy(vector#2 float Y){ 54 | return ( @[(0,1),(0,2)] = upy_even(Y); 55 | @[(0,1),(1,2)] = upy_odd(Y); ); 56 | } 57 | vector upsample(vector#2 float X){ 58 | return upy(upx(X)); 59 | } 60 | stencil laplacian(vector#2 float X, vector#2 float Y){ 61 | return X - Y; 62 | } 63 | stencil sum(vector#2 float X, vector#2 float Y){ 64 | return X+Y; 65 | } 66 | vector#2 float input[2048,2048]; 67 | gpyramid<0> = input; 68 | for i = 1..4 69 | gpyramid = downsample(gpyramid); 70 | lpyramid = laplacian(gpyramid,upsample(gpyramid)); 71 | endfor 72 | outpyramid<4> = gpyramid<4>; 73 | for j = 3..0 74 | outpyramid = sum(upsample(outpyramid),lpyramid); 75 | endfor 76 | return outpyramid<0>; -------------------------------------------------------------------------------- /experiments/pyramid_mirror/pyramid_mirror.idsl: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | stencil downx(vector#2 float X){ 29 | return 0.0625f * X@[(-2,2),(0,1)] + 0.25f * X@[(-1,2),(0,1)] + 0.375f * X@[(0,2),(0,1)] + 0.25f * X@[(1,2),(0,1)] + 0.0625f * X@[(2,2),(0,1)]; 30 | } 31 | stencil downy(vector#2 float Y){ 32 | return 0.0625f * Y@[(0,1),(-2,2)] + 0.25f * Y@[(0,1),(-1,2)] + 0.375f * Y@[(0,1),(0,2)] + 0.25f * Y@[(0,1),(1,2)] + 0.0625f * Y@[(0,1),(2,2)] ; 33 | } 34 | vector downsample(vector#2 float X){ 35 | return downy(downx(X:mirror):mirror); 36 | } 37 | stencil upx_even(vector#2 float X){ 38 | return X@[-1,0] * 0.3125f + X * 0.625f + X@[1,0] * 0.0625f; 39 | } 40 | stencil upx_odd(vector#2 float X){ 41 | return X@[-1,0] * 0.0625f + X * 0.625f + X@[1,0] * 0.3125f; 42 | } 43 | vector upx(vector#2 float X){ 44 | return ( @[(0,2),(0,1)] = upx_even(X:mirror); 45 | @[(1,2),(0,1)] = upx_odd(X:mirror); ); 46 | } 47 | stencil upy_even(vector#2 float X){ 48 | return X@[0,-1] * 0.3125f + X * 0.625f + X@[0,1] * 0.0625f; 49 | } 50 | stencil upy_odd(vector#2 float X){ 51 | return X@[0,-1] * 0.0625f + X * 0.625f + X@[0,1] * 0.3125f ; 52 | } 53 | vector upy(vector#2 float Y){ 54 | return ( @[(0,1),(0,2)] = upy_even(Y:mirror); 55 | @[(0,1),(1,2)] = upy_odd(Y:mirror); ); 56 | } 57 | vector upsample(vector#2 float X){ 58 | return upy(upx(X)); 59 | } 60 | stencil laplacian(vector#2 float X, vector#2 float Y){ 61 | return X - Y; 62 | } 63 | stencil sum(vector#2 float X, vector#2 float Y){ 64 | return X+Y; 65 | } 66 | vector#2 float input[512,512]; 67 | gpyramid<0> = input; 68 | for i = 1..4 69 | gpyramid = downsample(gpyramid); 70 | lpyramid = laplacian(gpyramid,upsample(gpyramid)); 71 | endfor 72 | outpyramid<4> = gpyramid<4>; 73 | for j = 3..0 74 | outpyramid = sum(upsample(outpyramid),lpyramid); 75 | endfor 76 | return outpyramid<0>; -------------------------------------------------------------------------------- /include/program_opts.hpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************// 2 | //* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. *// 3 | //* *// 4 | //* Redistribution and use in source and binary forms, with or without *// 5 | //* modification, are permitted provided that the following conditions *// 6 | //* are met: *// 7 | //* * Redistributions of source code must retain the above copyright *// 8 | //* notice, this list of conditions and the following disclaimer. *// 9 | //* * Redistributions in binary form must reproduce the above copyright *// 10 | //* notice, this list of conditions and the following disclaimer in the *// 11 | //* documentation and/or other materials provided with the distribution. *// 12 | //* * Neither the name of NVIDIA CORPORATION nor the names of its *// 13 | //* contributors may be used to endorse or promote products derived *// 14 | //* from this software without specific prior written permission. *// 15 | //* *// 16 | //* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY *// 17 | //* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *// 18 | //* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *// 19 | //* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *// 20 | //* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *// 21 | //* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *// 22 | //* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *// 23 | //* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY *// 24 | //* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *// 25 | //* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *// 26 | //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *// 27 | //****************************************************************************// 28 | #ifndef __PROGRAM_OPTS_HPP__ 29 | #define __PROGRAM_OPTS_HPP__ 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | 36 | struct program_options{ 37 | /// input file 38 | FILE* inp_file; 39 | 40 | /// Forma optimizations 41 | bool unroll_loops; 42 | bool forward_exprs; 43 | bool inline_vectorfn; 44 | 45 | /// Pretty print 46 | bool pretty_print; 47 | 48 | /// generic codegen options 49 | std::string kernel_name; 50 | std::string header_file_name; 51 | bool init_zero; 52 | bool use_single_malloc; 53 | bool generate_unroll_code; 54 | std::deque unroll_factors; 55 | 56 | /// Dot code-generation 57 | bool print_dot; 58 | std::string dot_file_name; 59 | 60 | /// C code generation options 61 | bool print_c; 62 | bool generate_affine; 63 | bool use_openmp; 64 | bool use_icc_pragmas; 65 | std::string c_output_file; 66 | 67 | /// Cuda code generation options 68 | bool print_cuda; 69 | bool use_texture; 70 | bool use_syncthreads; 71 | std::string cuda_output_file; 72 | 73 | /// LLVM Code generation options 74 | bool print_llvm; 75 | std::string llvm_file_name; 76 | 77 | program_options() : 78 | inp_file(NULL), 79 | 80 | unroll_loops(true), 81 | forward_exprs(false), 82 | inline_vectorfn(false), 83 | 84 | pretty_print(false), 85 | 86 | kernel_name(""), 87 | header_file_name(""), 88 | init_zero(false), 89 | use_single_malloc(false), 90 | generate_unroll_code(false), 91 | 92 | print_dot(false), 93 | dot_file_name(""), 94 | 95 | print_c(false), 96 | generate_affine(false), 97 | use_openmp(true), 98 | use_icc_pragmas(false), 99 | c_output_file(""), 100 | 101 | print_cuda(false), 102 | use_texture(false), 103 | use_syncthreads(true), 104 | cuda_output_file(""), 105 | 106 | print_llvm(false), 107 | llvm_file_name("") 108 | { } 109 | ~program_options(){ } 110 | void parse_options(int,char**); 111 | }; 112 | 113 | #endif 114 | --------------------------------------------------------------------------------