diff --git a/.github/workflows/cmake_single_platform.yml b/.github/workflows/cmake_single_platform.yml new file mode 100644 index 0000000..55aaa8e --- /dev/null +++ b/.github/workflows/cmake_single_platform.yml @@ -0,0 +1,38 @@ +# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage. +# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml +name: CMake on a single platform + +on: + push: + branches: [ "*" ] + pull_request: + branches: [ "*" ] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + build: + # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. + # You can convert this to a matrix build if you need cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Configure CMake + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTS=ON + + - name: Build + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + + - name: Test + working-directory: ${{github.workspace}}/build + # Execute tests defined by the CMake configuration. + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: ctest -C ${{env.BUILD_TYPE}} --verbose diff --git a/.gitignore b/.gitignore index 13c24d2..a75bbaf 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,9 @@ /packages /.idea /examples/OpenCL/IntelBitonicSort/BitonicSort/.vs/BitonicSort_2015/v15 + +# Linux +build/ + +# VS Code +.vscode/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..b2259a9 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,41 @@ +cmake_minimum_required(VERSION 3.10) +project(Shaderator) +#project(recipe-07 LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + + +include(GNUInstallDirs) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY + ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY + ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY + ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}) + + +# defines targets and sources +add_subdirectory(Shaderator) + +# Include directories for Shaderator +target_include_directories(Shaderator + PUBLIC + ${CMAKE_CURRENT_LIST_DIR} + ${CMAKE_CURRENT_LIST_DIR}/glm +) + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug) +endif() + +# Add an option to build tests +option(BUILD_TESTS "Build Shaderator tests" ON) + +# enable testing and define tests +if(BUILD_TESTS) + enable_testing() + add_subdirectory(ShaderatorTests) + add_subdirectory(examples) +endif() diff --git a/LICENSE.txt b/LICENSE.txt index f28557e..fad8580 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,84 +1,7 @@ -Some elements of this software are derived from or make use of material -that is subject to the terms of The Happy Bunny License (Modified MIT License). -The The Happy Bunny License (Modified MIT License) in question is shown below: +Copyright (c) 2024 Cezary Bloch - ================================================================================ - OpenGL Mathematics (GLM) - -------------------------------------------------------------------------------- - GLM is licensed under The Happy Bunny License and MIT License +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - ================================================================================ - The Happy Bunny License (Modified MIT License) - -------------------------------------------------------------------------------- - Copyright (c) 2005 - 2014 G-Truc Creation - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - Restrictions: - By making use of the Software for military purposes, you choose to make a - Bunny unhappy. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - - ================================================================================ - The MIT License - -------------------------------------------------------------------------------- - Copyright (c) 2005 - 2014 G-Truc Creation - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - -Some elements of this software are derived from or make use of material -that is subject to the terms of The MIT License (MIT). -The MIT License (MIT) in question is shown below: - - The MIT License (MIT) - - Copyright (c) 2017 Microsoft Corp - - Permission is hereby granted, free of charge, to any person obtaining a copy of this - software and associated documentation files (the "Software"), to deal in the Software - without restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to the following - conditions: - - The above copyright notice and this permission notice shall be included in all copies - or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A - PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE - OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index da9f15e..fa192e5 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -[![Build Status](https://potrecs.visualstudio.com/_apis/public/build/definitions/76cd276e-183c-4a57-9255-523bf379583d/2/badge)](https://potrecs.visualstudio.com/Shaderator/_build/index?definitionId=2) - # What is this? Shaderator is a productivity library intended to speed up complex Compute Shader development. It also provides means to Unit Tests shader code offering protection against regressions. Click on the image below to see the Lighting Talk from ACCU 2018 Conference. @@ -8,7 +6,71 @@ Shaderator is a productivity library intended to speed up complex Compute Shader # What problem does it solve? Due to the nature of GPUs shaders are hard to debug. Back in the day developer wrote one, executed a batch and hoped for the best that the result is correct. Kernel function is usually executed hundreds of thousand times writing data to output buffer which can only be looked up when the Dispatch finished. This tool compiles .hlsl shader code to C++ and enables developer to leverage full Visual Studio debugging functionality to quickly find problems in the code. -# Getting started with debugging +# Setup + +If you use VS Code install recommended extensions from + +```configs/recommended_extensions.json``` + +## Linux + +Install compiler and build tools + +```sudo apt-get install -y cmake build-essential gdb``` + +# Building + +Shaderators uses CMake to setup and run the build process. + +## Linux + +Run the following commands to build: + +``` +mkdir build +cd build +cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON .. +make +``` + +CMake will download the neccessary dependencies like GoogleTests. + +# Unit testing + +To execute unit tests run from command line run + +```ctests --verbose``` + +When using VS Code and all the recommended extensions were installed, then tests should be visible in the 'Test Explorer UI'. + + +# Examples + +There are several examples in folder ```examples``` how to write a test for you shaders/kernels. The idea is not leave the production code as much untouched as possible, but it's not always possible. Sometimes variables or data types need to be wrapped in a ```Shaderator``` macros. + +You also need to write an ```executor``` which will handle input and exectution of your specific kernel. + +There are examples for: +- Direct Compute HLSL +- OpenGL GLSL +- OpenCL C + +Functionality for your specific kernel may be missing and would need to be added. If that is the case please submit an issue or feature request on github. + +# FAQ + +## Will this work with any shader? +Not yet, the project is in it's early phase, however it should work with many shaders. If there is interest, support for more HLSL language features will be added. +At the moment matrices are not supported yet. + +# Problems or feedback + +Submit any issues on github. Feel free to contact the author directly with information available on github. + + +# (old instructions) Windows - Getting started with debugging + +NOTE: This instructions are from year 2018 and serve as reference. Running Shaderator on Windows has not been tried since then. 1. Open Shaderator.sln in VS 2017 2. Build solution (better choose Debug configuration to see more variables under debugger) @@ -16,13 +78,9 @@ Due to the nature of GPUs shaders are hard to debug. Back in the day developer w 4. Put breakpoint anywhere in ComputeShaderSort11.hlsl shader file 5. Press F5 to Debug -![](http://oi65.tinypic.com/358dwm1.jpg) - VS will start regular debugging session and you will be able to debug the .hlsl shader code as C++ code. You can see all variables, can add them to watch, pin or look-up values when hovering the mouse. CPU shader is obviously very slow. The intention is to provide tools for faster Computer Shader development. -![](http://oi67.tinypic.com/1zp6rvc.jpg) - If you have Visual Assist X installed debugging experience may be reduced. # Getting started with Unit Tests @@ -37,11 +95,3 @@ If you have Visual Assist X installed debugging experience may be reduced. * Windows 10 * Visual Studio 2017 - -# Will this work with any shader? -Not yet, the project is in it's early phase, however it should work with many shaders. If there is interest, support for more HLSL language features will be added. -At the moment matrices are not supported yet. - -# Problems or feedback - -Please e-mail me at cez dot bloch at gmail dot com, you can also find email on my github profile. \ No newline at end of file diff --git a/Shaderator/CMakeLists.txt b/Shaderator/CMakeLists.txt new file mode 100644 index 0000000..c8e5b3e --- /dev/null +++ b/Shaderator/CMakeLists.txt @@ -0,0 +1,33 @@ +add_library(Shaderator "") + +target_sources(Shaderator + PRIVATE + cpp_functions.cpp + Engine.cpp + CpuTimeMeasurement.cpp + opencl_support.cpp + PUBLIC + ${CMAKE_CURRENT_LIST_DIR}/access_counting_container.h + ${CMAKE_CURRENT_LIST_DIR}/Barrier.h + ${CMAKE_CURRENT_LIST_DIR}/cpp_include.h + ${CMAKE_CURRENT_LIST_DIR}/element.h + ${CMAKE_CURRENT_LIST_DIR}/Engine.h + ${CMAKE_CURRENT_LIST_DIR}/CpuTimeMeasurement.h + ${CMAKE_CURRENT_LIST_DIR}/glsl_include.h + ${CMAKE_CURRENT_LIST_DIR}/hlsl_include.h + ${CMAKE_CURRENT_LIST_DIR}/OpenCLEngine.h + ${CMAKE_CURRENT_LIST_DIR}/opencl_support.h + ${CMAKE_CURRENT_LIST_DIR}/opencl_types.h + ${CMAKE_CURRENT_LIST_DIR}/thread_joiner.h + ${CMAKE_CURRENT_LIST_DIR}/shaderator.h + ${CMAKE_CURRENT_LIST_DIR}/shader_types.h + ${CMAKE_CURRENT_LIST_DIR}/texture_2d.h + ${CMAKE_CURRENT_LIST_DIR}/thread_pool.h + ${CMAKE_CURRENT_LIST_DIR}/threadsafe_queue.h + + ) + +target_include_directories(Shaderator + PUBLIC + ${CMAKE_CURRENT_LIST_DIR} + ) \ No newline at end of file diff --git a/Shaderator/OpenCLEngine.h b/Shaderator/OpenCLEngine.h index 1f9f043..42dd4cc 100644 --- a/Shaderator/OpenCLEngine.h +++ b/Shaderator/OpenCLEngine.h @@ -16,7 +16,7 @@ namespace Shaderator { namespace OpenCL { public: using Kernel = std::function; - Engine::Engine(Kernel main, ClearGroupSharedVariables clear_function, uint3 numThreads) + Engine(Kernel main, ClearGroupSharedVariables clear_function, uint3 numThreads) : kernel_(main) , clear_groupshared_variables_(clear_function) , threads_amount_in_group_(numThreads) diff --git a/Shaderator/access_counting_container.h b/Shaderator/access_counting_container.h index 1639add..9263eb8 100644 --- a/Shaderator/access_counting_container.h +++ b/Shaderator/access_counting_container.h @@ -76,7 +76,7 @@ class AccessCountingContainer void reset_access_counts() { - std::memset(&access_counts_[0], 0, (sizeof uint) * size_.x * size_.y); + std::memset(&access_counts_[0], 0, sizeof(uint) * size_.x * size_.y); for (auto& el : data_) { el.reset_count(); } diff --git a/Shaderator/cpp_functions.cpp b/Shaderator/cpp_functions.cpp index fb390e6..b37e966 100644 --- a/Shaderator/cpp_functions.cpp +++ b/Shaderator/cpp_functions.cpp @@ -1,18 +1,30 @@ #include "cpp_include.h" #include "Barrier.h" -#include "windows.h" +//#include "windows.h" +#include +//#include static std::unique_ptr g_GroupMemoryBarrierWithGroupSync; -void ShaderInterlockedOr(int& dest, int value) +// void ShaderInterlockedOr(int& dest, int value) +// { +// InterlockedOr(reinterpret_cast(&dest), value); +// } + +// void ShaderInterlockedAnd(int& dest, int value) +// { +// InterlockedAnd(reinterpret_cast(&dest), value); +// } + +void ShaderInterlockedOr(std::atomic& dest, int value) { - InterlockedOr(reinterpret_cast(&dest), value); + dest.fetch_or(value, std::memory_order_seq_cst); } -void ShaderInterlockedAnd(int& dest, int value) +void ShaderInterlockedAnd(std::atomic& dest, int value) { - InterlockedAnd(reinterpret_cast(&dest), value); + dest.fetch_and(value, std::memory_order_seq_cst); } void ShaderAssert(bool expression) @@ -96,7 +108,7 @@ int compareInts(int x, int y) // From OpenCL 1.2 Specification: // "For vector types, the relational operators shall return 0 if the specified -// relation is false and –1(i.e.all bits set) if the specified relation is true." +// relation is false and �1(i.e.all bits set) if the specified relation is true." int4 operator<(int4 v1, int4 v2) { int4 result; diff --git a/Shaderator/opencl_support.cpp b/Shaderator/opencl_support.cpp index 5cd3726..e057085 100644 --- a/Shaderator/opencl_support.cpp +++ b/Shaderator/opencl_support.cpp @@ -1,6 +1,9 @@ +#include + #include "opencl_support.h" #include "cpp_include.h" + std::mutex g_thread_descriptions_mutex; std::map g_thread_descriptions; diff --git a/Shaderator/opencl_support.h b/Shaderator/opencl_support.h index 6ed17a7..9dff6dd 100644 --- a/Shaderator/opencl_support.h +++ b/Shaderator/opencl_support.h @@ -1,8 +1,9 @@ #pragma once -#include #include -#include "windows.h" +#include +#include + #include "opencl_types.h" #define __global @@ -14,18 +15,18 @@ #define CLK_LOCAL_MEM_FENCE 1 #define CLK_GLOBAL_MEM_FENCE 2 -template -void atomic_or(T* dest, T value) -{ - InterlockedOr(reinterpret_cast(dest), value); -} +// template +// void atomic_or(T* dest, T value) +// { +// InterlockedOr(reinterpret_cast(dest), value); +// } -template -void atomic_and(T* dest, T value) -{ - InterlockedAnd(reinterpret_cast(dest), value); -} +// template +// void atomic_and(T* dest, T value) +// { +// InterlockedAnd(reinterpret_cast(dest), value); +// } void barrier(int type); int sub_group_reduce_add(int value); diff --git a/Shaderator/thread_pool.h b/Shaderator/thread_pool.h index 5080520..c283d66 100644 --- a/Shaderator/thread_pool.h +++ b/Shaderator/thread_pool.h @@ -24,7 +24,8 @@ class thread_pool { public: thread_pool(ShaderKernel kernel, unsigned int threadsAmount) - : m_shader(kernel) + : m_exit(false) + , m_shader(kernel) , m_joiner(m_threads) { for (uint i = 0; i < threadsAmount; ++i) @@ -65,7 +66,7 @@ class thread_pool } } - std::atomic_bool m_exit = false; + std::atomic_bool m_exit; ShaderKernel m_shader; std::vector m_threads; threadsafe_queue m_argumentsQueue; diff --git a/ShaderatorTests/CMakeLists.txt b/ShaderatorTests/CMakeLists.txt new file mode 100644 index 0000000..6f7df90 --- /dev/null +++ b/ShaderatorTests/CMakeLists.txt @@ -0,0 +1,25 @@ +# Download GoogleTest +include(FetchContent) +FetchContent_Declare( + googletest + # Specify the commit you depend on and update it regularly. + URL https://github.com/google/googletest/archive/5376968f6948923e2411081fd9372e71a59d8e77.zip +) +# For Windows: Prevent overriding the parent project's compiler/linker settings +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +FetchContent_MakeAvailable(googletest) + +# ---------------------------------------- +# Define the ShaderatorTests executable + +add_executable(shaderator_tests + access_counting_container_tests.cpp + barrier_tests.cpp + hlsl_syntax_tests.cpp + thread_pool_tests.cpp + threadsafe_queue_tests.cpp +) +# Link the Shaderator library and pthread and Gtest +target_link_libraries(shaderator_tests Shaderator pthread gtest_main) + +add_test(NAME shaderator_tests COMMAND shaderator_tests) diff --git a/ShaderatorTests/thread_pool_tests.cpp b/ShaderatorTests/thread_pool_tests.cpp index 301f891..89a3871 100644 --- a/ShaderatorTests/thread_pool_tests.cpp +++ b/ShaderatorTests/thread_pool_tests.cpp @@ -33,4 +33,4 @@ TEST(ThreadPool, finishes_all_tasks) } EXPECT_EQ(g_values[6], 49); -} \ No newline at end of file +} diff --git a/ShaderatorTests/threadsafe_queue_tests.cpp b/ShaderatorTests/threadsafe_queue_tests.cpp index 060fdca..ea5caa4 100644 --- a/ShaderatorTests/threadsafe_queue_tests.cpp +++ b/ShaderatorTests/threadsafe_queue_tests.cpp @@ -4,6 +4,7 @@ #include "threadsafe_queue.h" #include +#include TEST(ThreadSafeQueue, is_empty) diff --git a/configs/recommended_extensions.json b/configs/recommended_extensions.json new file mode 100644 index 0000000..039d63f --- /dev/null +++ b/configs/recommended_extensions.json @@ -0,0 +1,7 @@ +{ + "recommendations": [ + "github.vscode-github-actions", + "hbenl.vscode-test-explorer", + "matepek.vscode-catch2-test-adapter" + ] +} diff --git a/examples/BasicComputeTests/CMakeLists.txt b/examples/BasicComputeTests/CMakeLists.txt new file mode 100644 index 0000000..5c801b5 --- /dev/null +++ b/examples/BasicComputeTests/CMakeLists.txt @@ -0,0 +1,8 @@ +add_executable(basic_direct_compute_11_tests + basic_compute_executor.cpp + basic_compute_tests.cpp +) + +target_link_libraries(basic_direct_compute_11_tests Shaderator pthread gtest_main) + +add_test(NAME basic_direct_compute_11_tests COMMAND basic_direct_compute_11_tests) \ No newline at end of file diff --git a/examples/BitonicSort/CMakeLists.txt b/examples/BitonicSort/CMakeLists.txt new file mode 100644 index 0000000..e949dde --- /dev/null +++ b/examples/BitonicSort/CMakeLists.txt @@ -0,0 +1,16 @@ +add_library(BitonicSort "") + +target_sources(BitonicSort + PRIVATE + bitonic_sort_executor.cpp + ComputeShaderSort11.hlsl + PUBLIC + ${CMAKE_CURRENT_LIST_DIR}/bitonic_sort_executor.h + ) + +target_include_directories(BitonicSort + PUBLIC + ${CMAKE_CURRENT_LIST_DIR} + ) + +target_link_libraries(BitonicSort Shaderator) diff --git a/examples/BitonicSortTests/CMakeLists.txt b/examples/BitonicSortTests/CMakeLists.txt new file mode 100644 index 0000000..6fc8a81 --- /dev/null +++ b/examples/BitonicSortTests/CMakeLists.txt @@ -0,0 +1,7 @@ +add_executable(bitonic_sort_tests + bitonic_sort_tests.cpp +) + +target_link_libraries(bitonic_sort_tests Shaderator BitonicSort pthread gtest_main) + +add_test(NAME bitonic_sort_tests COMMAND bitonic_sort_tests) \ No newline at end of file diff --git a/examples/BitonicSortTests/bitonic_sort_tests.cpp b/examples/BitonicSortTests/bitonic_sort_tests.cpp index ef069a5..216f296 100644 --- a/examples/BitonicSortTests/bitonic_sort_tests.cpp +++ b/examples/BitonicSortTests/bitonic_sort_tests.cpp @@ -1,14 +1,16 @@ #define _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING #define TRACE_ACCESS -#include "gtest/gtest.h" -#include "bitonic_sort_executor.h" -#include "shader_types.h" +#include //std::sort, std::shuffle #include //std::begin #include //std::itoa #include #include +#include "gtest/gtest.h" +#include "bitonic_sort_executor.h" +#include "shader_types.h" + using UINT = unsigned int; const UINT BITONIC_BLOCK_SIZE = 16; diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 0000000..ef3a606 --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,5 @@ +add_subdirectory(BasicComputeTests) +add_subdirectory(BitonicSort) +add_subdirectory(BitonicSortTests) +add_subdirectory(GlslShadersTests) +add_subdirectory(OpenCL) \ No newline at end of file diff --git a/examples/GlslShadersTests/CMakeLists.txt b/examples/GlslShadersTests/CMakeLists.txt new file mode 100644 index 0000000..d18bfc4 --- /dev/null +++ b/examples/GlslShadersTests/CMakeLists.txt @@ -0,0 +1,7 @@ +add_executable(glsl_shaders_tests + ray_tracer_tests.cpp +) + +target_link_libraries(glsl_shaders_tests Shaderator pthread gtest_main) + +add_test(NAME glsl_shaders_tests COMMAND glsl_shaders_tests) \ No newline at end of file diff --git a/examples/OpenCL/CMakeLists.txt b/examples/OpenCL/CMakeLists.txt new file mode 100644 index 0000000..6480348 --- /dev/null +++ b/examples/OpenCL/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(IntelBitonicSortTests) \ No newline at end of file diff --git a/examples/OpenCL/IntelBitonicSortTests/CMakeLists.txt b/examples/OpenCL/IntelBitonicSortTests/CMakeLists.txt new file mode 100644 index 0000000..8705efb --- /dev/null +++ b/examples/OpenCL/IntelBitonicSortTests/CMakeLists.txt @@ -0,0 +1,8 @@ +add_executable(opencl_intel_bitonic_sort_tests + intel_bitonic_sort_executor.cpp + intel_bitonic_sort_tests.cpp +) + +target_link_libraries(opencl_intel_bitonic_sort_tests Shaderator pthread gtest_main) + +add_test(NAME opencl_intel_bitonic_sort_tests COMMAND opencl_intel_bitonic_sort_tests) \ No newline at end of file diff --git a/examples/OpenCL/IntelBitonicSortTests/intel_bitonic_sort_tests.cpp b/examples/OpenCL/IntelBitonicSortTests/intel_bitonic_sort_tests.cpp index c4b530e..616ec2f 100644 --- a/examples/OpenCL/IntelBitonicSortTests/intel_bitonic_sort_tests.cpp +++ b/examples/OpenCL/IntelBitonicSortTests/intel_bitonic_sort_tests.cpp @@ -1,10 +1,14 @@ #include "pch.h" -#include "intel_bitonic_sort_executor.h" + +#include //std::sort, std::shuffle #include //std::begin #include //std::itoa #include #include +#include "intel_bitonic_sort_executor.h" + + class Fixture { public: