├── .clang-format ├── .github ├── CODEOWNERS └── workflows │ ├── build-linux.yml │ ├── build-windows.yml │ ├── clang-format.yml │ ├── container-prune.yml │ ├── container.yml │ ├── coverage.yml │ ├── coverity-pull-request.yml │ ├── coverity.yml │ ├── fuzz-test.yml │ ├── tsan.yml │ └── unix.yml ├── CHANGELOG.md ├── CMakeLists.txt ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── RELEASE.md ├── cmake ├── manifests │ ├── linux │ │ ├── install_manifest.txt │ │ ├── install_manifest_CL.txt │ │ ├── install_manifest_CppUTest.txt │ │ ├── install_manifest_MMD.txt │ │ ├── install_manifest_acl.txt │ │ ├── install_manifest_acl_check_sys_cmd.txt │ │ ├── install_manifest_acl_hash.txt │ │ ├── install_manifest_acl_threadsupport.txt │ │ └── install_manifest_pkg_editor.txt │ └── windows │ │ ├── install_manifest.txt │ │ ├── install_manifest_CL.txt │ │ ├── install_manifest_CppUTest.txt │ │ ├── install_manifest_MMD.txt │ │ ├── install_manifest_acl.txt │ │ ├── install_manifest_acl_check_sys_cmd.txt │ │ ├── install_manifest_acl_hash.txt │ │ ├── install_manifest_acl_threadsupport.txt │ │ └── install_manifest_pkg_editor.txt ├── modules │ └── FindElf.cmake └── scripts │ └── version.cmake ├── container ├── debian-11-arm-dev │ └── Dockerfile ├── opensuse-leap-15-dev │ └── Dockerfile ├── rockylinux-8-dev │ └── Dockerfile ├── rockylinux-9-dev │ └── Dockerfile ├── ubuntu-20.04-dev │ └── Dockerfile └── ubuntu-22.04-dev │ └── Dockerfile ├── docs ├── README.md └── buffers.md ├── fuzz_testing ├── CMakeLists.txt ├── README.md ├── fuzz_src │ └── fuzz_testing.h ├── original_inputs │ └── acl_auto_configure_fuzz_test.yml ├── script │ ├── fuzz_test.py │ └── mutator.py └── test │ ├── CMakeLists.txt │ ├── acl_auto_configure_fuzz_test.cpp │ ├── acl_fuzz_test.cpp │ ├── acl_fuzz_test.h │ ├── acl_globals_fuzz_test.cpp │ ├── acl_globals_fuzz_test.h │ ├── acl_hal_fuzz_test.cpp │ └── acl_hal_fuzz_test.h ├── glibc_wrap ├── CMakeLists.txt └── glibc_wrap.c ├── include ├── CL │ ├── .clang-format │ ├── LICENSE │ ├── cl.h │ ├── cl_d3d10.h │ ├── cl_d3d11.h │ ├── cl_dx9_media_sharing.h │ ├── cl_dx9_media_sharing_intel.h │ ├── cl_egl.h │ ├── cl_ext.h │ ├── cl_ext_intel.h │ ├── cl_ext_intelfpga.h │ ├── cl_gl.h │ ├── cl_gl_ext.h │ ├── cl_half.h │ ├── cl_icd.h │ ├── cl_layer.h │ ├── cl_platform.h │ ├── cl_va_api_media_sharing_intel.h │ ├── cl_version.h │ ├── opencl.h │ └── opencl.hpp ├── MMD │ ├── .clang-format │ ├── aocl_mmd.h │ └── aocl_mmd_deprecated.h ├── acl.h ├── acl_auto.h ├── acl_auto_configure.h ├── acl_auto_configure_version.h ├── acl_bsp_io.h ├── acl_command.h ├── acl_command_queue.h ├── acl_context.h ├── acl_device_binary.h ├── acl_device_op.h ├── acl_event.h ├── acl_globals.h ├── acl_hal.h ├── acl_hal_mmd.h ├── acl_hostch.h ├── acl_icd_dispatch.h ├── acl_kernel.h ├── acl_kernel_if.h ├── acl_mem.h ├── acl_offline_hal.h ├── acl_platform.h ├── acl_pll.h ├── acl_printf.h ├── acl_profiler.h ├── acl_program.h ├── acl_sampler.h ├── acl_shared_aligned_ptr.h ├── acl_shipped_board_cfgs.h ├── acl_support.h ├── acl_svm.h ├── acl_thread.h ├── acl_types.h ├── acl_usm.h ├── acl_util.h ├── acl_version.h.in └── acl_visibility.h ├── lib ├── CMakeLists.txt ├── CppUTest │ ├── .clang-format │ ├── CMakeLists.txt │ ├── COPYING │ ├── include │ │ └── CppUTest │ │ │ ├── CommandLineArguments.h │ │ │ ├── CommandLineTestRunner.h │ │ │ ├── Failure.h │ │ │ ├── JUnitTestOutput.h │ │ │ ├── MemoryLeakAllocator.h │ │ │ ├── MemoryLeakDetector.h │ │ │ ├── MemoryLeakWarningPlugin.h │ │ │ ├── PlatformSpecificFunctions.h │ │ │ ├── SimpleString.h │ │ │ ├── Synchronization.h │ │ │ ├── TestHarness.h │ │ │ ├── TestHarness_c.h │ │ │ ├── TestOutput.h │ │ │ ├── TestPlugin.h │ │ │ ├── TestRegistry.h │ │ │ ├── TestResult.h │ │ │ ├── TestTestingFixture.h │ │ │ ├── Utest.h │ │ │ ├── UtestMacros.h │ │ │ └── VirtualCall.h │ ├── src │ │ ├── CommandLineArguments.cpp │ │ ├── CommandLineTestRunner.cpp │ │ ├── Failure.cpp │ │ ├── JUnitTestOutput.cpp │ │ ├── MemoryLeakAllocator.cpp │ │ ├── MemoryLeakDetector.cpp │ │ ├── MemoryLeakWarningPlugin.cpp │ │ ├── SimpleString.cpp │ │ ├── TestHarness_c.cpp │ │ ├── TestOutput.cpp │ │ ├── TestPlugin.cpp │ │ ├── TestRegistry.cpp │ │ ├── TestResult.cpp │ │ ├── Utest.cpp │ │ ├── UtestPlatformGcc.cpp │ │ └── UtestPlatformVisualCpp.cpp │ └── test │ │ ├── AllTests.cpp │ │ ├── CMakeLists.txt │ │ ├── CommandLineArgumentsTest.cpp │ │ ├── CommandLineTestRunnerTest.cpp │ │ ├── FailureTest.cpp │ │ ├── JUnitOutputTest.cpp │ │ ├── MemoryLeakAllocatorTest.cpp │ │ ├── MemoryLeakDetectorTest.cpp │ │ ├── MemoryLeakWarningTest.cpp │ │ ├── NullTestTest.cpp │ │ ├── PluginTest.cpp │ │ ├── SetPluginTest.cpp │ │ ├── SimpleStringTest.cpp │ │ ├── TestHarness_cTest.cpp │ │ ├── TestInstallerTest.cpp │ │ ├── TestOutputTest.cpp │ │ ├── TestRegistryTest.cpp │ │ ├── TestResultTest.cpp │ │ └── UtestTest.cpp ├── acl_check_sys_cmd │ ├── CMakeLists.txt │ ├── include │ │ └── acl_check_sys_cmd │ │ │ └── acl_check_sys_cmd.h │ ├── src │ │ └── acl_check_sys_cmd.c │ └── test │ │ ├── CMakeLists.txt │ │ └── acl_check_sys_cmd_test.cpp ├── acl_hash │ ├── CMakeLists.txt │ ├── include │ │ └── acl_hash │ │ │ └── acl_hash.h │ ├── src │ │ └── acl_hash.c │ └── test │ │ ├── CMakeLists.txt │ │ ├── acl_hash_test.cpp │ │ ├── acl_test.cpp │ │ └── acl_test.h ├── acl_threadsupport │ ├── CMakeLists.txt │ ├── include │ │ └── acl_threadsupport │ │ │ └── acl_threadsupport.h │ ├── src │ │ └── acl_threadsupport.c │ └── test │ │ ├── CMakeLists.txt │ │ ├── acl_test.cpp │ │ ├── acl_test.h │ │ └── acl_threadsupport_test.cpp └── pkg_editor │ ├── CMakeLists.txt │ ├── include │ └── pkg_editor │ │ └── pkg_editor.h │ ├── src │ └── pkg_editor.c │ └── test │ ├── CMakeLists.txt │ └── pkg_editor_test.cpp ├── scripts ├── changelog-link-pr.sh ├── clang-format.sh ├── coverage_diff.py ├── install_libelf.ps1 ├── install_ninja.ps1 └── install_zlib.ps1 ├── security.md ├── src ├── acl_auto_configure.cpp ├── acl_bsp_io.cpp ├── acl_command.cpp ├── acl_command_queue.cpp ├── acl_context.cpp ├── acl_device.cpp ├── acl_device_binary.cpp ├── acl_device_op.cpp ├── acl_device_program_info.cpp ├── acl_event.cpp ├── acl_globals.cpp ├── acl_hal.cpp ├── acl_hal_mmd.cpp ├── acl_hostch.cpp ├── acl_icd_dispatch.cpp ├── acl_kernel.cpp ├── acl_kernel_if.cpp ├── acl_mem.cpp ├── acl_offline_hal.cpp ├── acl_platform.cpp ├── acl_pll.cpp ├── acl_printf.cpp ├── acl_profiler.cpp ├── acl_program.cpp ├── acl_sampler.cpp ├── acl_shared_aligned_ptr.cpp ├── acl_support.cpp ├── acl_svm.cpp ├── acl_thread.cpp ├── acl_usm.cpp ├── check_copy_overlap.c ├── check_copy_overlap.h └── unref.h └── test ├── CMakeLists.txt ├── acl_auto_configure_test.cpp ├── acl_command_queue_test.cpp ├── acl_context_test.cpp ├── acl_device_op_test.cpp ├── acl_device_op_test.h ├── acl_device_test.cpp ├── acl_event_test.cpp ├── acl_globals_test.cpp ├── acl_globals_test.h ├── acl_hal_mmd_test.cpp ├── acl_hal_test.cpp ├── acl_hal_test.h ├── acl_kernel_test.cpp ├── acl_mem_device_global_test.cpp ├── acl_mem_test.cpp ├── acl_platform_test.cpp ├── acl_profiler_test.cpp ├── acl_program_test.cpp ├── acl_sampler_test.cpp ├── acl_support_test.cpp ├── acl_svm_test.cpp ├── acl_test.cpp ├── acl_test.h ├── acl_thread_test.cpp ├── acl_usm_test.cpp ├── board └── a10_ref │ ├── README.md │ ├── board_env.xml │ └── hardware │ └── a10_ref_small │ └── board_spec.xml ├── example_binary ├── README.md ├── linux │ ├── compile_aocr.sh │ ├── example.aocr │ └── foo.aocr ├── src │ ├── example.cl │ └── foo.cl └── windows │ ├── compile_aocr.cmd │ ├── example.aocr │ └── foo.aocr └── fake_bsp ├── CMakeLists.txt ├── fakegoodbsp.cpp └── missingfuncbsp.cpp /.clang-format: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | BasedOnStyle: LLVM 5 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | # https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-syntax 5 | # 6 | # Note the required access permissions for users and teams to the repository. 7 | 8 | # The runtime maintainers are the default owners of all files 9 | # in this repository, unless a later match takes precedence. 10 | * @intel/fpga-runtime-for-opencl-maintain 11 | 12 | # Profiler 13 | acl_profiler* @intel/fpga-runtime-for-opencl-maintain @smffraser 14 | -------------------------------------------------------------------------------- /.github/workflows/clang-format.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions 5 | 6 | name: clang-format 7 | 8 | permissions: 9 | # Grant read permissions to private container images. 10 | packages: read 11 | 12 | on: 13 | push: 14 | paths: 15 | - '.github/workflows/clang-format.yml' 16 | - 'scripts/clang-format.sh' 17 | - '**.c' 18 | - '**.cpp' 19 | - '**.h' 20 | 21 | pull_request: 22 | paths: 23 | - '.github/workflows/clang-format.yml' 24 | - 'scripts/clang-format.sh' 25 | - '**.c' 26 | - '**.cpp' 27 | - '**.h' 28 | 29 | jobs: 30 | build: 31 | runs-on: ubuntu-20.04 32 | 33 | container: 34 | image: ghcr.io/intel/fpga-runtime-for-opencl/ubuntu-22.04-dev:main 35 | 36 | steps: 37 | - name: checkout code 38 | uses: actions/checkout@v4 39 | 40 | - name: run clang-format on source files 41 | run: ./scripts/clang-format.sh --verbose 42 | 43 | - name: ensure source files are unchanged 44 | run: git diff --exit-code 45 | -------------------------------------------------------------------------------- /.github/workflows/container-prune.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions 5 | 6 | # https://docs.docker.com/config/pruning/ 7 | name: prune container images on self-hosted runners 8 | 9 | # docker permits only a single prune operation at a time 10 | concurrency: container-prune 11 | 12 | # https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/ 13 | # https://github.com/ossf/scorecard/blob/2ef20f17fb2e64147c83440cd2c769653454015a/docs/checks.md#token-permissions 14 | permissions: 15 | # top-level permissions must be defined for security reasons. 16 | contents: read 17 | 18 | on: 19 | push: 20 | branches: 21 | - main 22 | paths: 23 | - '.github/workflows/container-prune.yml' 24 | 25 | # https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#scheduled-events-schedule 26 | schedule: 27 | # UTC time of midnight in Pacific Standard Time 28 | - cron: '0 8 * * *' 29 | 30 | workflow_dispatch: 31 | 32 | jobs: 33 | build: 34 | runs-on: 35 | - self-hosted 36 | - linux 37 | - x64 38 | - container 39 | 40 | steps: 41 | # https://pkg.go.dev/time#ParseDuration 42 | - name: prune stopped containers, unused networks, unused untagged images, and build cache older than a day 43 | run: docker system prune --force --filter 'until=24h' 44 | 45 | - name: prune unused tagged images older than a week 46 | run: docker system prune --force --all --filter 'until=168h' 47 | -------------------------------------------------------------------------------- /.github/workflows/coverage.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions 5 | 6 | name: code coverage 7 | 8 | permissions: 9 | # Grant read permissions to private container images. 10 | packages: read 11 | 12 | on: 13 | pull_request: 14 | paths: 15 | - '**' 16 | - '!**.md' 17 | - '!**/.clang-format' 18 | - '!**/COPYING' 19 | - '!**/LICENSE' 20 | - '!.github/**' 21 | - '.github/workflows/coverage.yml' 22 | - '!.gitignore' 23 | - '!cmake/manifests/**' 24 | - 'cmake/manifests/linux/**' 25 | - '!container/**' 26 | - '!docs/**' 27 | - '!scripts/**' 28 | 29 | jobs: 30 | build: 31 | runs-on: ubuntu-22.04 32 | 33 | container: 34 | image: ghcr.io/intel/fpga-runtime-for-opencl/ubuntu-22.04-dev:main 35 | 36 | steps: 37 | - name: checkout main branch 38 | uses: actions/checkout@v4 39 | with: 40 | ref: ${{ github.base_ref }} 41 | 42 | - name: create build directory 43 | run: mkdir build 44 | 45 | - name: create parent build files 46 | run: cd build && cmake -G Ninja "$GITHUB_WORKSPACE" -DCMAKE_BUILD_TYPE=Debug -DACL_CODE_COVERAGE=ON -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache 47 | 48 | - name: build parent runtime 49 | run: cd build && ninja -v -k0 50 | 51 | - name: parent runtime coverage scan 52 | run: cd build && ctest -T Test -T Coverage 53 | 54 | - name: save build directory for later comparison 55 | run: mv -t "$RUNNER_TEMP" build 56 | 57 | - name: checkout current branch 58 | uses: actions/checkout@v4 59 | 60 | - name: create build directory 61 | run: mkdir build 62 | 63 | - name: create child build files 64 | run: cd build && cmake -G Ninja "$GITHUB_WORKSPACE" -DCMAKE_BUILD_TYPE=Debug -DACL_CODE_COVERAGE=ON -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache 65 | 66 | - name: build child runtime 67 | run: cd build && ninja -v -k0 68 | 69 | - name: child runtime coverage scan 70 | run: cd build && ctest -T Test -T Coverage 71 | 72 | - name: coverage status 73 | run: ./scripts/coverage_diff.py build "$RUNNER_TEMP"/build 74 | -------------------------------------------------------------------------------- /.github/workflows/coverity.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions 5 | 6 | name: Coverity 7 | 8 | permissions: 9 | # Grant read permissions to private container images. 10 | packages: read 11 | 12 | on: 13 | push: 14 | paths: 15 | - '**' 16 | - '!**.md' 17 | - '!**/.clang-format' 18 | - '!**/COPYING' 19 | - '!**/LICENSE' 20 | - '!.github/**' 21 | - '.github/workflows/coverity.yml' 22 | - '!.gitignore' 23 | - '!cmake/manifests/**' 24 | - '!container/**' 25 | - '!docs/**' 26 | - '!scripts/**' 27 | 28 | jobs: 29 | build: 30 | runs-on: 31 | - self-hosted 32 | - linux 33 | - x64 34 | - container 35 | 36 | container: 37 | image: ghcr.io/intel/fpga-runtime-for-opencl/ubuntu-22.04-dev:main 38 | volumes: 39 | - /opt/coverity:/opt/coverity 40 | 41 | steps: 42 | - uses: actions/checkout@v4 43 | - run: cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=Release 44 | - run: echo /opt/coverity/latest/bin >> "$GITHUB_PATH" 45 | # The --compiler names must match those used by CMake. 46 | # https://community.synopsys.com/s/article/cov-build-returns-WARNING-No-files-were-emitted-This-may-be-due-to-a-problem-with-your-configuration 47 | # https://community.synopsys.com/s/article/Configuring-Your-Compilers-for-Coverity-Analysis 48 | - run: cov-configure --config config.xml --template --comptype gcc --compiler cc 49 | - run: cov-configure --config config.xml --template --comptype g++ --compiler c++ 50 | - run: cov-build --config config.xml --dir results ninja -C build -v -k0 51 | - run: cov-manage-emit --dir results --tu-pattern "file('/lib/CppUTest/')" delete 52 | - run: cov-analyze --config config.xml --dir results --concurrency --security --rule --enable-constraint-fpp --enable-fnptr --enable-virtual 53 | - run: cov-format-errors --text-output-style multiline --dir results --filesort --file "$PWD" --strip-path "$PWD" > cov-errors.txt 54 | - run: cat cov-errors.txt 55 | - run: count=$(grep -c '^$' cov-errors.txt) || true && echo "$(( $count / 2 ))" 56 | - uses: actions/upload-artifact@v4 57 | with: 58 | name: fpga-runtime-for-opencl-${{ github.sha }}-coverity-${{ github.run_id }} 59 | path: cov-errors.txt 60 | if-no-files-found: error 61 | -------------------------------------------------------------------------------- /.github/workflows/fuzz-test.yml: -------------------------------------------------------------------------------- 1 | name: Runtime Fuzz Testing 2 | 3 | # https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/ 4 | # https://github.com/ossf/scorecard/blob/2ef20f17fb2e64147c83440cd2c769653454015a/docs/checks.md#token-permissions 5 | permissions: 6 | # top-level permissions must be defined for security reasons. 7 | packages: read 8 | 9 | on: 10 | workflow_dispatch: 11 | inputs: 12 | num_of_iterations: 13 | description: Number of iterations per fuzzable variable 14 | required: False 15 | default: 5 16 | 17 | jobs: 18 | build: 19 | runs-on: ubuntu-22.04 20 | 21 | container: 22 | image: ghcr.io/intel/fpga-runtime-for-opencl/ubuntu-22.04-dev:main 23 | 24 | name: Fuzz Testing 25 | steps: 26 | - name: Clone Radamsa 27 | run: | 28 | mkdir radamsa_repo 29 | cd radamsa_repo 30 | git clone https://gitlab.com/akihe/radamsa.git . 31 | - name: Install Radamsa 32 | run: | 33 | cd radamsa_repo 34 | make 35 | sudo make install 36 | cd .. 37 | - name: Install PyYAML 38 | run: pip install pyyaml 39 | - name: Checkout runtime 40 | uses: actions/checkout@v4 41 | - name: Build 42 | run: | 43 | mkdir -p build/fuzz_testing 44 | cd build/fuzz_testing 45 | CC="${CC:-gcc}" CXX="${CXX:-g++}" cmake -G Ninja ../.. -DCMAKE_BUILD_TYPE=Debug -DACL_CODE_COVERAGE=ON -DACL_TSAN=OFF -DACL_WITH_ASAN=ON -DFUZZ_TESTING=ON "$@" 46 | ninja -v 47 | - name: Fuzz testing 48 | run: | 49 | cd build/fuzz_testing 50 | ls 51 | cd fuzz_testing/script 52 | export AOCL_BOARD_PACKAGE_ROOT="$(git rev-parse --show-toplevel)/test/board/a10_ref" 53 | export ACL_TEST_EXAMPLE_BINARY="$(git rev-parse --show-toplevel)/test/example_binary" 54 | NUM_OF_ITERATIONS=${{ github.event.inputs.num_of_iterations }} 55 | # This if block is only used during testing, because if this workflow is triggered via pull_request, ${{ github.event.inputs.num_of_iterations }} would be empty 56 | if [ -z "${NUM_OF_ITERATIONS}" ]; then 57 | NUM_OF_ITERATIONS=1 58 | fi 59 | python3 fuzz_test.py --all -n $NUM_OF_ITERATIONS 60 | - name: Peek results 61 | run: | 62 | cat build/fuzz_testing/fuzz_testing/results/results.yml 63 | - name: Upload results 64 | uses: actions/upload-artifact@v4 65 | with: 66 | name: fpga-runtime-for-opencl-${{ github.sha }}-fuzz-test-results-${{ github.run_id }} 67 | path: | 68 | /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/build/fuzz_testing/fuzz_testing/results/results.yml 69 | /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/build/fuzz_testing/fuzz_testing/test_outputs 70 | if-no-files-found: error 71 | -------------------------------------------------------------------------------- /.github/workflows/tsan.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions 5 | 6 | name: thread sanitizer 7 | 8 | # https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/ 9 | permissions: 10 | # Grant read permissions to repository in case it is not a forked public 11 | # repository, but a private repository that was created manually. 12 | contents: read 13 | 14 | # Grant read permissions to private container images. 15 | packages: read 16 | 17 | on: 18 | push: 19 | paths: 20 | - '**' 21 | - '!**.md' 22 | - '!**/.clang-format' 23 | - '!**/COPYING' 24 | - '!**/LICENSE' 25 | - '!.github/**' 26 | - '.github/workflows/tsan.yml' 27 | - '!.gitignore' 28 | - '!cmake/manifests/**' 29 | - 'cmake/manifests/linux/**' 30 | - '!container/**' 31 | - '!docs/**' 32 | - '!scripts/**' 33 | 34 | pull_request: 35 | paths: 36 | - '**' 37 | - '!**.md' 38 | - '!**/.clang-format' 39 | - '!**/COPYING' 40 | - '!**/LICENSE' 41 | - '!.github/**' 42 | - '.github/workflows/tsan.yml' 43 | - '!.gitignore' 44 | - '!cmake/manifests/**' 45 | - 'cmake/manifests/linux/**' 46 | - '!container/**' 47 | - '!docs/**' 48 | - '!scripts/**' 49 | 50 | jobs: 51 | build: 52 | runs-on: ubuntu-22.04 53 | 54 | container: 55 | image: ghcr.io/intel/fpga-runtime-for-opencl/ubuntu-22.04-dev:main 56 | 57 | continue-on-error: true 58 | 59 | steps: 60 | - name: checkout code 61 | uses: actions/checkout@v4 62 | 63 | - name: query distribution 64 | run: cat /etc/os-release 65 | 66 | - name: create build directory 67 | run: mkdir build 68 | 69 | - name: create build files 70 | run: | 71 | cd build 72 | cmake -G Ninja .. -DCMAKE_BUILD_TYPE=Debug -DACL_TSAN=ON 73 | env: 74 | CC: gcc 75 | CXX: g++ 76 | 77 | - name: build runtime 78 | run: | 79 | cd build 80 | ninja -v -k0 81 | 82 | - name: test runtime 83 | run: | 84 | cd build 85 | ctest -V 86 | 87 | - name: tsan result 88 | uses: actions/upload-artifact@v4 89 | if: always() 90 | with: 91 | name: tsan-report 92 | path: build/Testing/Temporary/LastTest.log 93 | -------------------------------------------------------------------------------- /.github/workflows/unix.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions 5 | 6 | # While mixing files with DOS or Unix line endings in the same project is 7 | # usually not an issue, DOS line endings may cause unexpected surprises, e.g., 8 | # hash-bangs in scripts do not work with DOS line endings. For consistency, 9 | # enforce UNIX line endings for all except Windows-specific text files. 10 | name: ensure UNIX line endings 11 | 12 | # https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/ 13 | # https://github.com/ossf/scorecard/blob/2ef20f17fb2e64147c83440cd2c769653454015a/docs/checks.md#token-permissions 14 | permissions: 15 | # top-level permissions must be defined for security reasons. 16 | contents: read 17 | 18 | on: 19 | push: 20 | pull_request: 21 | 22 | jobs: 23 | build: 24 | runs-on: ubuntu-20.04 25 | 26 | steps: 27 | - name: checkout code 28 | uses: actions/checkout@v4 29 | 30 | # See Git Glossary for pathspec patterns 31 | # https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefpathspecapathspec 32 | - name: ensure text files do not contain DOS line endings 33 | run: | 34 | status=0 35 | git grep -I --files-with-matches --perl-regexp '\r' -- \ 36 | ':/' \ 37 | ':/!cmake/manifests/windows' \ 38 | || status=$? 39 | test $status -eq 1 40 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Intel(R) FPGA Runtime for OpenCL(TM) Software Technology 2 | ======================================================== 3 | 4 | Copyright (C) 2010-2021 Intel Corporation 5 | SPDX-License-Identifier: BSD-3-Clause 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | 3. Neither the name of the copyright holder nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | 25 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | Software from third parties 34 | =========================== 35 | 36 | The Intel(R) FPGA Runtime for OpenCL(TM) Software Technology includes software 37 | from third parties which are subject to their respective license terms that are 38 | provided in either or both of these two forms: 39 | 40 | 1. A separate `COPYING` or `LICENSE` file stating the license terms which 41 | apply to all files in that directory and its subdirectories, with the 42 | exception of files stating other license terms at the top of the file. 43 | 44 | 2. The license terms are stated at the top of the file. 45 | -------------------------------------------------------------------------------- /cmake/manifests/linux/install_manifest.txt: -------------------------------------------------------------------------------- 1 | /fpga-runtime-for-opencl/lib/libalteracl.so 2 | /fpga-runtime-for-opencl/include/acl.h 3 | /fpga-runtime-for-opencl/include/acl_auto.h 4 | /fpga-runtime-for-opencl/include/acl_auto_configure.h 5 | /fpga-runtime-for-opencl/include/acl_auto_configure_version.h 6 | /fpga-runtime-for-opencl/include/acl_context.h 7 | /fpga-runtime-for-opencl/include/acl_device_binary.h 8 | /fpga-runtime-for-opencl/include/acl_globals.h 9 | /fpga-runtime-for-opencl/include/acl_hal.h 10 | /fpga-runtime-for-opencl/include/acl_hal_mmd.h 11 | /fpga-runtime-for-opencl/include/acl_hostch.h 12 | /fpga-runtime-for-opencl/include/acl_icd_dispatch.h 13 | /fpga-runtime-for-opencl/include/acl_shared_aligned_ptr.h 14 | /fpga-runtime-for-opencl/include/acl_support.h 15 | /fpga-runtime-for-opencl/include/acl_thread.h 16 | /fpga-runtime-for-opencl/include/acl_types.h 17 | /fpga-runtime-for-opencl/include/acl_util.h 18 | /fpga-runtime-for-opencl/include/acl_visibility.h 19 | /fpga-runtime-for-opencl/include/CL/cl.h 20 | /fpga-runtime-for-opencl/include/CL/cl_d3d10.h 21 | /fpga-runtime-for-opencl/include/CL/cl_d3d11.h 22 | /fpga-runtime-for-opencl/include/CL/cl_dx9_media_sharing.h 23 | /fpga-runtime-for-opencl/include/CL/cl_dx9_media_sharing_intel.h 24 | /fpga-runtime-for-opencl/include/CL/cl_egl.h 25 | /fpga-runtime-for-opencl/include/CL/cl_ext.h 26 | /fpga-runtime-for-opencl/include/CL/cl_ext_intel.h 27 | /fpga-runtime-for-opencl/include/CL/cl_ext_intelfpga.h 28 | /fpga-runtime-for-opencl/include/CL/cl_gl.h 29 | /fpga-runtime-for-opencl/include/CL/cl_gl_ext.h 30 | /fpga-runtime-for-opencl/include/CL/cl_half.h 31 | /fpga-runtime-for-opencl/include/CL/cl_icd.h 32 | /fpga-runtime-for-opencl/include/CL/cl_layer.h 33 | /fpga-runtime-for-opencl/include/CL/cl_platform.h 34 | /fpga-runtime-for-opencl/include/CL/cl_va_api_media_sharing_intel.h 35 | /fpga-runtime-for-opencl/include/CL/cl_version.h 36 | /fpga-runtime-for-opencl/include/CL/opencl.h 37 | /fpga-runtime-for-opencl/include/CL/opencl.hpp 38 | /fpga-runtime-for-opencl/include/MMD/aocl_mmd.h 39 | /fpga-runtime-for-opencl/include/MMD/aocl_mmd_deprecated.h 40 | /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/glibc_wrap/libglibc_wrap.a -------------------------------------------------------------------------------- /cmake/manifests/linux/install_manifest_CL.txt: -------------------------------------------------------------------------------- 1 | /fpga-runtime-for-opencl/include/CL/cl.h 2 | /fpga-runtime-for-opencl/include/CL/cl_d3d10.h 3 | /fpga-runtime-for-opencl/include/CL/cl_d3d11.h 4 | /fpga-runtime-for-opencl/include/CL/cl_dx9_media_sharing.h 5 | /fpga-runtime-for-opencl/include/CL/cl_dx9_media_sharing_intel.h 6 | /fpga-runtime-for-opencl/include/CL/cl_egl.h 7 | /fpga-runtime-for-opencl/include/CL/cl_ext.h 8 | /fpga-runtime-for-opencl/include/CL/cl_ext_intel.h 9 | /fpga-runtime-for-opencl/include/CL/cl_ext_intelfpga.h 10 | /fpga-runtime-for-opencl/include/CL/cl_gl.h 11 | /fpga-runtime-for-opencl/include/CL/cl_gl_ext.h 12 | /fpga-runtime-for-opencl/include/CL/cl_half.h 13 | /fpga-runtime-for-opencl/include/CL/cl_icd.h 14 | /fpga-runtime-for-opencl/include/CL/cl_layer.h 15 | /fpga-runtime-for-opencl/include/CL/cl_platform.h 16 | /fpga-runtime-for-opencl/include/CL/cl_va_api_media_sharing_intel.h 17 | /fpga-runtime-for-opencl/include/CL/cl_version.h 18 | /fpga-runtime-for-opencl/include/CL/opencl.h 19 | /fpga-runtime-for-opencl/include/CL/opencl.hpp -------------------------------------------------------------------------------- /cmake/manifests/linux/install_manifest_CppUTest.txt: -------------------------------------------------------------------------------- 1 | /fpga-runtime-for-opencl/lib/libCppUTest.a 2 | /fpga-runtime-for-opencl/include/CppUTest/CommandLineArguments.h 3 | /fpga-runtime-for-opencl/include/CppUTest/CommandLineTestRunner.h 4 | /fpga-runtime-for-opencl/include/CppUTest/Failure.h 5 | /fpga-runtime-for-opencl/include/CppUTest/JUnitTestOutput.h 6 | /fpga-runtime-for-opencl/include/CppUTest/MemoryLeakAllocator.h 7 | /fpga-runtime-for-opencl/include/CppUTest/MemoryLeakDetector.h 8 | /fpga-runtime-for-opencl/include/CppUTest/MemoryLeakWarningPlugin.h 9 | /fpga-runtime-for-opencl/include/CppUTest/PlatformSpecificFunctions.h 10 | /fpga-runtime-for-opencl/include/CppUTest/SimpleString.h 11 | /fpga-runtime-for-opencl/include/CppUTest/Synchronization.h 12 | /fpga-runtime-for-opencl/include/CppUTest/TestHarness.h 13 | /fpga-runtime-for-opencl/include/CppUTest/TestHarness_c.h 14 | /fpga-runtime-for-opencl/include/CppUTest/TestOutput.h 15 | /fpga-runtime-for-opencl/include/CppUTest/TestPlugin.h 16 | /fpga-runtime-for-opencl/include/CppUTest/TestRegistry.h 17 | /fpga-runtime-for-opencl/include/CppUTest/TestResult.h 18 | /fpga-runtime-for-opencl/include/CppUTest/TestTestingFixture.h 19 | /fpga-runtime-for-opencl/include/CppUTest/Utest.h 20 | /fpga-runtime-for-opencl/include/CppUTest/UtestMacros.h 21 | /fpga-runtime-for-opencl/include/CppUTest/VirtualCall.h -------------------------------------------------------------------------------- /cmake/manifests/linux/install_manifest_MMD.txt: -------------------------------------------------------------------------------- 1 | /fpga-runtime-for-opencl/include/MMD/aocl_mmd.h 2 | /fpga-runtime-for-opencl/include/MMD/aocl_mmd_deprecated.h -------------------------------------------------------------------------------- /cmake/manifests/linux/install_manifest_acl.txt: -------------------------------------------------------------------------------- 1 | /fpga-runtime-for-opencl/lib/libalteracl.so 2 | /fpga-runtime-for-opencl/include/acl.h 3 | /fpga-runtime-for-opencl/include/acl_auto.h 4 | /fpga-runtime-for-opencl/include/acl_auto_configure.h 5 | /fpga-runtime-for-opencl/include/acl_auto_configure_version.h 6 | /fpga-runtime-for-opencl/include/acl_context.h 7 | /fpga-runtime-for-opencl/include/acl_device_binary.h 8 | /fpga-runtime-for-opencl/include/acl_globals.h 9 | /fpga-runtime-for-opencl/include/acl_hal.h 10 | /fpga-runtime-for-opencl/include/acl_hal_mmd.h 11 | /fpga-runtime-for-opencl/include/acl_hostch.h 12 | /fpga-runtime-for-opencl/include/acl_icd_dispatch.h 13 | /fpga-runtime-for-opencl/include/acl_shared_aligned_ptr.h 14 | /fpga-runtime-for-opencl/include/acl_support.h 15 | /fpga-runtime-for-opencl/include/acl_thread.h 16 | /fpga-runtime-for-opencl/include/acl_types.h 17 | /fpga-runtime-for-opencl/include/acl_util.h 18 | /fpga-runtime-for-opencl/include/acl_visibility.h -------------------------------------------------------------------------------- /cmake/manifests/linux/install_manifest_acl_check_sys_cmd.txt: -------------------------------------------------------------------------------- 1 | /fpga-runtime-for-opencl/lib/libacl_check_sys_cmd.a 2 | /fpga-runtime-for-opencl/include/acl_check_sys_cmd/acl_check_sys_cmd.h -------------------------------------------------------------------------------- /cmake/manifests/linux/install_manifest_acl_hash.txt: -------------------------------------------------------------------------------- 1 | /fpga-runtime-for-opencl/lib/libacl_hash.a 2 | /fpga-runtime-for-opencl/include/acl_hash/acl_hash.h -------------------------------------------------------------------------------- /cmake/manifests/linux/install_manifest_acl_threadsupport.txt: -------------------------------------------------------------------------------- 1 | /fpga-runtime-for-opencl/lib/libacl_threadsupport.a 2 | /fpga-runtime-for-opencl/include/acl_threadsupport/acl_threadsupport.h -------------------------------------------------------------------------------- /cmake/manifests/linux/install_manifest_pkg_editor.txt: -------------------------------------------------------------------------------- 1 | /fpga-runtime-for-opencl/lib/libpkg_editor.a 2 | /fpga-runtime-for-opencl/include/pkg_editor/pkg_editor.h -------------------------------------------------------------------------------- /cmake/manifests/windows/install_manifest.txt: -------------------------------------------------------------------------------- 1 | C:/fpga-runtime-for-opencl/lib/alteracl.lib 2 | C:/fpga-runtime-for-opencl/bin/alteracl.dll 3 | C:/fpga-runtime-for-opencl/include/acl.h 4 | C:/fpga-runtime-for-opencl/include/acl_auto.h 5 | C:/fpga-runtime-for-opencl/include/acl_auto_configure.h 6 | C:/fpga-runtime-for-opencl/include/acl_auto_configure_version.h 7 | C:/fpga-runtime-for-opencl/include/acl_context.h 8 | C:/fpga-runtime-for-opencl/include/acl_device_binary.h 9 | C:/fpga-runtime-for-opencl/include/acl_globals.h 10 | C:/fpga-runtime-for-opencl/include/acl_hal.h 11 | C:/fpga-runtime-for-opencl/include/acl_hal_mmd.h 12 | C:/fpga-runtime-for-opencl/include/acl_hostch.h 13 | C:/fpga-runtime-for-opencl/include/acl_icd_dispatch.h 14 | C:/fpga-runtime-for-opencl/include/acl_shared_aligned_ptr.h 15 | C:/fpga-runtime-for-opencl/include/acl_support.h 16 | C:/fpga-runtime-for-opencl/include/acl_thread.h 17 | C:/fpga-runtime-for-opencl/include/acl_types.h 18 | C:/fpga-runtime-for-opencl/include/acl_util.h 19 | C:/fpga-runtime-for-opencl/include/acl_visibility.h 20 | C:/fpga-runtime-for-opencl/include/CL/cl.h 21 | C:/fpga-runtime-for-opencl/include/CL/cl_d3d10.h 22 | C:/fpga-runtime-for-opencl/include/CL/cl_d3d11.h 23 | C:/fpga-runtime-for-opencl/include/CL/cl_dx9_media_sharing.h 24 | C:/fpga-runtime-for-opencl/include/CL/cl_dx9_media_sharing_intel.h 25 | C:/fpga-runtime-for-opencl/include/CL/cl_egl.h 26 | C:/fpga-runtime-for-opencl/include/CL/cl_ext.h 27 | C:/fpga-runtime-for-opencl/include/CL/cl_ext_intel.h 28 | C:/fpga-runtime-for-opencl/include/CL/cl_ext_intelfpga.h 29 | C:/fpga-runtime-for-opencl/include/CL/cl_gl.h 30 | C:/fpga-runtime-for-opencl/include/CL/cl_gl_ext.h 31 | C:/fpga-runtime-for-opencl/include/CL/cl_half.h 32 | C:/fpga-runtime-for-opencl/include/CL/cl_icd.h 33 | C:/fpga-runtime-for-opencl/include/CL/cl_layer.h 34 | C:/fpga-runtime-for-opencl/include/CL/cl_platform.h 35 | C:/fpga-runtime-for-opencl/include/CL/cl_va_api_media_sharing_intel.h 36 | C:/fpga-runtime-for-opencl/include/CL/cl_version.h 37 | C:/fpga-runtime-for-opencl/include/CL/opencl.h 38 | C:/fpga-runtime-for-opencl/include/CL/opencl.hpp 39 | C:/fpga-runtime-for-opencl/include/MMD/aocl_mmd.h 40 | C:/fpga-runtime-for-opencl/include/MMD/aocl_mmd_deprecated.h -------------------------------------------------------------------------------- /cmake/manifests/windows/install_manifest_CL.txt: -------------------------------------------------------------------------------- 1 | C:/fpga-runtime-for-opencl/include/CL/cl.h 2 | C:/fpga-runtime-for-opencl/include/CL/cl_d3d10.h 3 | C:/fpga-runtime-for-opencl/include/CL/cl_d3d11.h 4 | C:/fpga-runtime-for-opencl/include/CL/cl_dx9_media_sharing.h 5 | C:/fpga-runtime-for-opencl/include/CL/cl_dx9_media_sharing_intel.h 6 | C:/fpga-runtime-for-opencl/include/CL/cl_egl.h 7 | C:/fpga-runtime-for-opencl/include/CL/cl_ext.h 8 | C:/fpga-runtime-for-opencl/include/CL/cl_ext_intel.h 9 | C:/fpga-runtime-for-opencl/include/CL/cl_ext_intelfpga.h 10 | C:/fpga-runtime-for-opencl/include/CL/cl_gl.h 11 | C:/fpga-runtime-for-opencl/include/CL/cl_gl_ext.h 12 | C:/fpga-runtime-for-opencl/include/CL/cl_half.h 13 | C:/fpga-runtime-for-opencl/include/CL/cl_icd.h 14 | C:/fpga-runtime-for-opencl/include/CL/cl_layer.h 15 | C:/fpga-runtime-for-opencl/include/CL/cl_platform.h 16 | C:/fpga-runtime-for-opencl/include/CL/cl_va_api_media_sharing_intel.h 17 | C:/fpga-runtime-for-opencl/include/CL/cl_version.h 18 | C:/fpga-runtime-for-opencl/include/CL/opencl.h 19 | C:/fpga-runtime-for-opencl/include/CL/opencl.hpp -------------------------------------------------------------------------------- /cmake/manifests/windows/install_manifest_CppUTest.txt: -------------------------------------------------------------------------------- 1 | C:/fpga-runtime-for-opencl/lib/CppUTest.lib 2 | C:/fpga-runtime-for-opencl/include/CppUTest/CommandLineArguments.h 3 | C:/fpga-runtime-for-opencl/include/CppUTest/CommandLineTestRunner.h 4 | C:/fpga-runtime-for-opencl/include/CppUTest/Failure.h 5 | C:/fpga-runtime-for-opencl/include/CppUTest/JUnitTestOutput.h 6 | C:/fpga-runtime-for-opencl/include/CppUTest/MemoryLeakAllocator.h 7 | C:/fpga-runtime-for-opencl/include/CppUTest/MemoryLeakDetector.h 8 | C:/fpga-runtime-for-opencl/include/CppUTest/MemoryLeakWarningPlugin.h 9 | C:/fpga-runtime-for-opencl/include/CppUTest/PlatformSpecificFunctions.h 10 | C:/fpga-runtime-for-opencl/include/CppUTest/SimpleString.h 11 | C:/fpga-runtime-for-opencl/include/CppUTest/Synchronization.h 12 | C:/fpga-runtime-for-opencl/include/CppUTest/TestHarness.h 13 | C:/fpga-runtime-for-opencl/include/CppUTest/TestHarness_c.h 14 | C:/fpga-runtime-for-opencl/include/CppUTest/TestOutput.h 15 | C:/fpga-runtime-for-opencl/include/CppUTest/TestPlugin.h 16 | C:/fpga-runtime-for-opencl/include/CppUTest/TestRegistry.h 17 | C:/fpga-runtime-for-opencl/include/CppUTest/TestResult.h 18 | C:/fpga-runtime-for-opencl/include/CppUTest/TestTestingFixture.h 19 | C:/fpga-runtime-for-opencl/include/CppUTest/Utest.h 20 | C:/fpga-runtime-for-opencl/include/CppUTest/UtestMacros.h 21 | C:/fpga-runtime-for-opencl/include/CppUTest/VirtualCall.h -------------------------------------------------------------------------------- /cmake/manifests/windows/install_manifest_MMD.txt: -------------------------------------------------------------------------------- 1 | C:/fpga-runtime-for-opencl/include/MMD/aocl_mmd.h 2 | C:/fpga-runtime-for-opencl/include/MMD/aocl_mmd_deprecated.h -------------------------------------------------------------------------------- /cmake/manifests/windows/install_manifest_acl.txt: -------------------------------------------------------------------------------- 1 | C:/fpga-runtime-for-opencl/lib/alteracl.lib 2 | C:/fpga-runtime-for-opencl/bin/alteracl.dll 3 | C:/fpga-runtime-for-opencl/include/acl.h 4 | C:/fpga-runtime-for-opencl/include/acl_auto.h 5 | C:/fpga-runtime-for-opencl/include/acl_auto_configure.h 6 | C:/fpga-runtime-for-opencl/include/acl_auto_configure_version.h 7 | C:/fpga-runtime-for-opencl/include/acl_context.h 8 | C:/fpga-runtime-for-opencl/include/acl_device_binary.h 9 | C:/fpga-runtime-for-opencl/include/acl_globals.h 10 | C:/fpga-runtime-for-opencl/include/acl_hal.h 11 | C:/fpga-runtime-for-opencl/include/acl_hal_mmd.h 12 | C:/fpga-runtime-for-opencl/include/acl_hostch.h 13 | C:/fpga-runtime-for-opencl/include/acl_icd_dispatch.h 14 | C:/fpga-runtime-for-opencl/include/acl_shared_aligned_ptr.h 15 | C:/fpga-runtime-for-opencl/include/acl_support.h 16 | C:/fpga-runtime-for-opencl/include/acl_thread.h 17 | C:/fpga-runtime-for-opencl/include/acl_types.h 18 | C:/fpga-runtime-for-opencl/include/acl_util.h 19 | C:/fpga-runtime-for-opencl/include/acl_visibility.h -------------------------------------------------------------------------------- /cmake/manifests/windows/install_manifest_acl_check_sys_cmd.txt: -------------------------------------------------------------------------------- 1 | C:/fpga-runtime-for-opencl/lib/acl_check_sys_cmd.lib 2 | C:/fpga-runtime-for-opencl/include/acl_check_sys_cmd/acl_check_sys_cmd.h -------------------------------------------------------------------------------- /cmake/manifests/windows/install_manifest_acl_hash.txt: -------------------------------------------------------------------------------- 1 | C:/fpga-runtime-for-opencl/lib/acl_hash.lib 2 | C:/fpga-runtime-for-opencl/include/acl_hash/acl_hash.h -------------------------------------------------------------------------------- /cmake/manifests/windows/install_manifest_acl_threadsupport.txt: -------------------------------------------------------------------------------- 1 | C:/fpga-runtime-for-opencl/lib/acl_threadsupport.lib 2 | C:/fpga-runtime-for-opencl/include/acl_threadsupport/acl_threadsupport.h -------------------------------------------------------------------------------- /cmake/manifests/windows/install_manifest_pkg_editor.txt: -------------------------------------------------------------------------------- 1 | C:/fpga-runtime-for-opencl/lib/pkg_editor.lib 2 | C:/fpga-runtime-for-opencl/include/pkg_editor/pkg_editor.h -------------------------------------------------------------------------------- /cmake/modules/FindElf.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | find_path(Elf_INCLUDE_DIR NAMES libelf/libelf.h libelf.h) 5 | 6 | if(Elf_INCLUDE_DIR AND EXISTS "${Elf_INCLUDE_DIR}/libelf/libelf.h") 7 | set(Elf_HAVE_LIBELF_LIBELF TRUE) 8 | else() 9 | set(Elf_HAVE_LIBELF_LIBELF FALSE) 10 | endif() 11 | 12 | find_library(Elf_LIBRARY NAMES elf libelf) 13 | 14 | mark_as_advanced(Elf_INCLUDE_DIR Elf_LIBRARY) 15 | 16 | include(FindPackageHandleStandardArgs) 17 | find_package_handle_standard_args(Elf REQUIRED_VARS Elf_INCLUDE_DIR Elf_LIBRARY) 18 | 19 | if(Elf_FOUND) 20 | add_library(Elf::Elf UNKNOWN IMPORTED) 21 | set_target_properties(Elf::Elf PROPERTIES 22 | IMPORTED_LINK_INTERFACE_LANGUAGES C 23 | IMPORTED_LOCATION "${Elf_LIBRARY}" 24 | INTERFACE_INCLUDE_DIRECTORIES "${Elf_INCLUDE_DIR}" 25 | INTERFACE_COMPILE_DEFINITIONS "$<$:HAVE_LIBELF_LIBELF>" 26 | ) 27 | endif() 28 | -------------------------------------------------------------------------------- /cmake/scripts/version.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | # This script generates a header containing the runtime version based on the 5 | # output of git describe, which generates a human readable name for a commit. 6 | 7 | # Use upper case to signal that this is a placeholder value. 8 | set(ACL_GIT_COMMIT "UNKNOWN") 9 | 10 | # The extraction of the git commit is strictly optional; if a failure occurs 11 | # due to any reason, the placeholder value for ACL_GIT_COMMIT must be retained. 12 | if(GIT_FOUND) 13 | execute_process( 14 | COMMAND "${GIT_EXECUTABLE}" describe --always --dirty --first-parent --long 15 | RESULT_VARIABLE ACL_GIT_DESCRIBE_RESULT 16 | OUTPUT_VARIABLE ACL_GIT_DESCRIBE_OUTPUT 17 | OUTPUT_STRIP_TRAILING_WHITESPACE 18 | ) 19 | 20 | if(ACL_GIT_DESCRIBE_RESULT EQUAL 0 AND ACL_GIT_DESCRIBE_OUTPUT) 21 | set(ACL_GIT_COMMIT "${ACL_GIT_DESCRIBE_OUTPUT}") 22 | endif() 23 | endif() 24 | 25 | # This only writes the output file when the content has changed, which in turn 26 | # only triggers a rebuild of dependent source files when the commit changes. 27 | configure_file( 28 | "${ACL_VERSION_INPUT_FILE}" 29 | "${ACL_VERSION_OUTPUT_FILE}" 30 | @ONLY 31 | ) 32 | -------------------------------------------------------------------------------- /container/debian-11-arm-dev/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | # https://docs.docker.com/develop/develop-images/dockerfile_best-practices/ 5 | 6 | FROM debian:11 7 | 8 | # Optionally override uid of default user in container, e.g., 9 | # docker build --build-arg uid=1001 ... 10 | ARG uid 11 | 12 | WORKDIR /work 13 | 14 | # Before using a new script, update .github/workflows/container.yml 15 | # to extend the `paths` on which the workflow runs. 16 | COPY scripts/. ./ 17 | 18 | # https://wiki.debian.org/Multiarch/HOWTO 19 | RUN dpkg --add-architecture armhf \ 20 | && apt-get -y update \ 21 | && DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade \ 22 | build-essential \ 23 | ca-certificates \ 24 | ccache \ 25 | cmake \ 26 | curl \ 27 | git \ 28 | jq \ 29 | libtinfo5 \ 30 | libxml2 \ 31 | ninja-build \ 32 | python3 \ 33 | sudo \ 34 | # Install cross-compile toolchain and libraries 35 | g++-arm-linux-gnueabihf \ 36 | gcc-arm-linux-gnueabihf \ 37 | libelf-dev:armhf \ 38 | zlib1g-dev:armhf \ 39 | && apt-get -y clean \ 40 | && useradd --system ${uid:+--uid "$uid"} --user-group --shell /sbin/nologin --create-home --home-dir /home/build build \ 41 | && echo 'build ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/build \ 42 | && rm -rf "$PWD" 43 | 44 | USER build 45 | WORKDIR /home/build 46 | -------------------------------------------------------------------------------- /container/opensuse-leap-15-dev/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | # https://docs.docker.com/develop/develop-images/dockerfile_best-practices/ 5 | 6 | FROM opensuse/leap:15 7 | 8 | # Optionally override uid of default user in container, e.g., 9 | # docker build --build-arg uid=1001 ... 10 | ARG uid 11 | 12 | WORKDIR /work 13 | 14 | # Before using a new script, update .github/workflows/container.yml 15 | # to extend the `paths` on which the workflow runs. 16 | COPY scripts/. ./ 17 | 18 | RUN zypper -n update \ 19 | && zypper -n install \ 20 | ccache \ 21 | cmake \ 22 | curl \ 23 | gcc \ 24 | gcc-c++ \ 25 | git \ 26 | gzip \ 27 | jq \ 28 | libelf-devel \ 29 | libncurses5 \ 30 | make \ 31 | ninja \ 32 | perl \ 33 | python3 \ 34 | sudo \ 35 | tar \ 36 | which \ 37 | zlib-devel \ 38 | && zypper -n clean \ 39 | && useradd --system ${uid:+--uid "$uid"} --user-group --shell /sbin/nologin --create-home --home-dir /home/build build \ 40 | && echo 'build ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/build \ 41 | && rm -rf "$PWD" 42 | 43 | USER build 44 | WORKDIR /home/build 45 | -------------------------------------------------------------------------------- /container/rockylinux-8-dev/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | # https://docs.docker.com/develop/develop-images/dockerfile_best-practices/ 5 | 6 | FROM rockylinux:8 7 | 8 | # Optionally override uid of default user in container, e.g., 9 | # docker build --build-arg uid=1001 ... 10 | ARG uid 11 | 12 | WORKDIR /work 13 | 14 | # Before using a new script, update .github/workflows/container.yml 15 | # to extend the `paths` on which the workflow runs. 16 | COPY scripts/. ./ 17 | 18 | RUN \ 19 | sed -i '/^enabled=/s#0#1#' /etc/yum.repos.d/Rocky-PowerTools.repo \ 20 | && grep '^enabled=1$' /etc/yum.repos.d/Rocky-PowerTools.repo \ 21 | && yum -y upgrade \ 22 | && yum -y install \ 23 | cmake \ 24 | curl \ 25 | elfutils-libelf-devel \ 26 | gcc \ 27 | gcc-c++ \ 28 | git \ 29 | jq \ 30 | libasan \ 31 | liblsan \ 32 | libnsl \ 33 | libtsan \ 34 | libubsan \ 35 | make \ 36 | ncurses-compat-libs-6.1 \ 37 | ninja-build \ 38 | perl \ 39 | python3 \ 40 | sudo \ 41 | which \ 42 | zlib-devel \ 43 | && yum -y clean all \ 44 | && useradd --system ${uid:+--uid "$uid"} --user-group --shell /sbin/nologin --create-home --home-dir /home/build build \ 45 | && echo 'build ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/build \ 46 | && rm -rf "$PWD" 47 | 48 | USER build 49 | WORKDIR /home/build 50 | -------------------------------------------------------------------------------- /container/rockylinux-9-dev/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | # https://docs.docker.com/develop/develop-images/dockerfile_best-practices/ 5 | 6 | FROM rockylinux:9 7 | 8 | # Optionally override uid of default user in container, e.g., 9 | # docker build --build-arg uid=1001 ... 10 | ARG uid 11 | 12 | WORKDIR /work 13 | 14 | # Before using a new script, update .github/workflows/container.yml 15 | # to extend the `paths` on which the workflow runs. 16 | COPY scripts/. ./ 17 | 18 | RUN \ 19 | sed -i '/^\[crb\]$/,/^\[/s#^enabled=0$#enabled=1#' /etc/yum.repos.d/rocky.repo \ 20 | && grep '^enabled=1$' /etc/yum.repos.d/rocky.repo \ 21 | && sed -i '/^\[devel\]$/,/^\[/s#^enabled=0$#enabled=1#' /etc/yum.repos.d/rocky-devel.repo \ 22 | && grep '^enabled=1$' /etc/yum.repos.d/rocky-devel.repo \ 23 | && yum -y upgrade \ 24 | && yum -y install \ 25 | cmake \ 26 | # curl \ Start from rockylinux 9.2, curl is available by default 27 | elfutils-libelf-devel \ 28 | gcc \ 29 | gcc-c++ \ 30 | git \ 31 | jq \ 32 | libasan \ 33 | liblsan \ 34 | libnsl \ 35 | libtsan \ 36 | libubsan \ 37 | libxcrypt-compat \ 38 | make \ 39 | ncurses-compat-libs \ 40 | ninja-build \ 41 | perl \ 42 | python3 \ 43 | sudo \ 44 | which \ 45 | zlib-devel \ 46 | && yum -y clean all \ 47 | && useradd --system ${uid:+--uid "$uid"} --user-group --shell /sbin/nologin --create-home --home-dir /home/build build \ 48 | && echo 'build ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/build \ 49 | && rm -rf "$PWD" 50 | 51 | USER build 52 | WORKDIR /home/build 53 | -------------------------------------------------------------------------------- /container/ubuntu-20.04-dev/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | # https://docs.docker.com/develop/develop-images/dockerfile_best-practices/ 5 | 6 | FROM ubuntu:20.04 7 | 8 | # Optionally override uid of default user in container, e.g., 9 | # docker build --build-arg uid=1001 ... 10 | ARG uid 11 | 12 | WORKDIR /work 13 | 14 | # Before using a new script, update .github/workflows/container.yml 15 | # to extend the `paths` on which the workflow runs. 16 | COPY scripts/. ./ 17 | 18 | RUN apt-get -y update \ 19 | && DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade \ 20 | build-essential \ 21 | ca-certificates \ 22 | ccache \ 23 | cmake \ 24 | curl \ 25 | git \ 26 | jq \ 27 | libelf-dev \ 28 | libtinfo5 \ 29 | libxml2 \ 30 | ninja-build \ 31 | python3 \ 32 | sudo \ 33 | zlib1g-dev \ 34 | && apt-get -y clean \ 35 | && useradd --system ${uid:+--uid "$uid"} --user-group --shell /sbin/nologin --create-home --home-dir /home/build build \ 36 | && echo 'build ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/build \ 37 | && rm -rf "$PWD" 38 | 39 | USER build 40 | WORKDIR /home/build 41 | -------------------------------------------------------------------------------- /container/ubuntu-22.04-dev/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | # https://docs.docker.com/develop/develop-images/dockerfile_best-practices/ 5 | 6 | # Requires Docker >= 20.10.9, which returns ENOSYS instead of the 7 | # default EPERM on clone3 syscall to ensure that glibc falls back to 8 | # clone syscall. Needed for dpkg and apt to run DPkg::Post-Invoke and 9 | # APT::Update::Post-Invoke as part of /etc/apt/apt.conf.d/docker-clean 10 | # https://github.com/moby/moby/issues/42680 11 | # https://github.com/moby/moby/pull/42681 12 | FROM ubuntu:22.04 13 | 14 | # Optionally override uid of default user in container, e.g., 15 | # docker build --build-arg uid=1001 ... 16 | ARG uid 17 | 18 | WORKDIR /work 19 | 20 | # Before using a new script, update .github/workflows/container.yml 21 | # to extend the `paths` on which the workflow runs. 22 | COPY scripts/. ./ 23 | 24 | RUN apt-get -y update \ 25 | && DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade \ 26 | build-essential \ 27 | ca-certificates \ 28 | ccache \ 29 | clang-format-13 \ 30 | cmake \ 31 | curl \ 32 | git \ 33 | jq \ 34 | libelf-dev \ 35 | libtinfo5 \ 36 | libxml2 \ 37 | ninja-build \ 38 | python3 \ 39 | python3-pip \ 40 | sudo \ 41 | zlib1g-dev \ 42 | && apt-get -y clean \ 43 | && useradd --system ${uid:+--uid "$uid"} --user-group --shell /sbin/nologin --create-home --home-dir /home/build build \ 44 | && echo 'build ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/build \ 45 | && rm -rf "$PWD" 46 | 47 | USER build 48 | WORKDIR /home/build 49 | 50 | ENV PATH="/usr/lib/llvm-13/bin:$PATH" 51 | RUN clang-format --version 52 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # FPGA Runtime for OpenCL documentation 2 | 3 | ## OpenCL background 4 | 5 | [Khronos® OpenCL™] is a standard for writing programs that run across 6 | heterogeneous platforms consisting of FPGA, CPU, GPU, DSP, etc. The [Intel® FPGA 7 | Runtime for OpenCL™ Software Technology] implements the [OpenCL 1.2] standard 8 | including selected vendor extensions. 9 | 10 | ## What is the FPGA runtime? 11 | 12 | The following components work together to program an [Intel® FPGA]: 13 | 14 | 1. host program and host compiler 15 | 2. OpenCL kernel(s) and offline compiler 16 | 3. [Custom Platform] 17 | 18 | The runtime is responsible for executing the host program (1) and queueing the 19 | kernel to be executed on the FPGA device. It takes in the hardware programming 20 | image from the compiler (2), builds the contained programs, allocates 21 | host/shared/device memory, programs devices, enqueues and executes the kernels, 22 | and collects kernel execution status signaled from the memory-mapped device 23 | ([MMD](../include/MMD/aocl_mmd.h)). Each step is described in the following. 24 | 25 | ## Why is the FPGA runtime needed? 26 | 27 | FPGA hardware design deals with I/O constraints, protocols, monitoring, DDR 28 | calibration, and memory dependencies. The FPGA runtime provides a layer of 29 | abstraction to ease the development flow. 30 | 31 | ### Memory 32 | 33 | Each kernel execution may require accessing device memory. The device memory 34 | needs to be reserved/allocated before kernel execution. The runtime keeps track 35 | of the memory allocation. There are two main types of memory allocations: 36 | [buffers](buffers.md) and unified shared memory (USM). 37 | 38 | ### Kernels 39 | 40 | Kernels are data-parallel functions that extend C99 for parallelism and memory 41 | hierarchy. 42 | 43 | ### Queues 44 | 45 | Queues manage buffer mapping, memory migration, device programming, and kernel 46 | execution. A queue receives asynchronous command completion notifications from 47 | the device. A queue also manages dependencies between commands using events and 48 | barriers. 49 | 50 | ### Profiling 51 | 52 | The runtime keeps track of the status of a kernel execution to record the 53 | wall time of each stage. This provides the user with insights into the 54 | performance of their program. 55 | 56 | ## User flow 57 | 58 | For more information on how users interact with each of the above components, 59 | see the [Intel® FPGA SDK for OpenCL™ Pro Edition: Programming Guide]. 60 | 61 | ## How to contribute 62 | 63 | To contribute to the runtime, see [CONTRIBUTING.md](../CONTRIBUTING.md). 64 | To build, test, and use the runtime, see [README.md](../README.md). 65 | 66 | [Khronos® OpenCL™]: https://www.khronos.org/opencl/ 67 | [OpenCL 1.2]: https://www.khronos.org/registry/OpenCL/sdk/1.2/docs/man/xhtml/ 68 | [Intel® FPGA]: https://www.intel.com/content/www/us/en/products/programmable.html 69 | [Intel® FPGA Runtime for OpenCL™ Software Technology]: https://github.com/intel/fpga-runtime-for-opencl 70 | [Intel® FPGA SDK for OpenCL™ Pro Edition: Programming Guide]: https://www.intel.com/content/www/us/en/docs/programmable/683846/ 71 | [Custom Platform]: https://www.intel.com/content/www/us/en/docs/programmable/683085/ 72 | -------------------------------------------------------------------------------- /fuzz_testing/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | add_subdirectory(test) 5 | file(COPY original_inputs DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) 6 | file(COPY script DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) 7 | -------------------------------------------------------------------------------- /fuzz_testing/README.md: -------------------------------------------------------------------------------- 1 | # Fuzz Testing 2 | 3 | ## Context 4 | "In programming and software development, fuzzing or fuzz testing is an automated software testing technique that involves providing invalid, unexpected, or random data as inputs to a computer program. The program is then monitored for exceptions such as crashes, failing built-in code assertions, or potential memory leaks." 5 | 6 | ## How to do fuzz testing on Github 7 | 1. Click on the `Actions` tab 8 | 2. Click on `Runtime Fuzz Testing` workflow 9 | 3. Click on `Run workflow` (Dropdown button) 10 | 4. Enter the number of iterations you want a single variable to be mutated 11 | 5. Click on `Run workflow` (Green button) 12 | 6. Wait until the test finishes 13 | 7. Inside the workflow run, click `Peek results` to look at the results 14 | 8. Download the artifact from the `Job Summary` to view the full output & result 15 | 16 | ## How to do fuzz testing locally 17 | 1. Follow [Prerequisites](https://github.com/intel/fpga-runtime-for-opencl#prerequisites) & [Build](https://github.com/intel/fpga-runtime-for-opencl#building-the-runtime) & [Test](https://github.com/intel/fpga-runtime-for-opencl#building-the-runtime) instructions to get a working build. Make sure that the unit tests finishes successfully. 18 | 2. Install Radamsa 0.6+, Python 3.10.7+ and Pyyaml/6.0+ 19 | 3. Run the following at the top level in the runtime repo 20 | ``` 21 | mkdir -p build/fuzz_testing 22 | cd build/fuzz_testing 23 | CC="${CC:-gcc}" CXX="${CXX:-g++}" cmake -G Ninja ../.. -DCMAKE_BUILD_TYPE=Debug -DACL_CODE_COVERAGE=ON -DACL_TSAN=OFF -DACL_WITH_ASAN=ON -DFUZZ_TESTING=ON "$@" 24 | ninja -v 25 | cd fuzz_testing/script 26 | export AOCL_BOARD_PACKAGE_ROOT="$(git rev-parse --show-toplevel)/test/board/a10_ref" 27 | python3 fuzz_test.py --all 28 | ``` 29 | 4. A results directory and a test_output directory will be created after the fuzz test finishes 30 | 31 | ## Classifying Failures 32 | - Address Sanitizer Error (ASAN Errors): Any errors caught by address sanitizer such as memory leaks (Not acceptable) 33 | - Aborted Runs: The test aborted/crashed during execution (Not acceptable) 34 | - Assertion Failures: The test failed due to an assertion (Acceptable) 35 | - Failed Runs: The test failed because the CHECK statements failed (Acceptable) 36 | - Hangs: The program did not terminate (Not acceptable) 37 | - Successful runs: The test succeeded (Acceptable) 38 | - Test errors: The test failed due to bugs in the fuzz testing infrastructure (Acceptable) 39 | 40 | ## Additional Notes 41 | - Currently we are doing most of the fuzz testing on auto discovery strings because these strings are indirectly given by the user. 42 | - The fuzz tests are initialized based on the current unit tests, however they should be regarded as separate tests. (i.e. You can make fuzz_test/unit_test only changes) 43 | -------------------------------------------------------------------------------- /fuzz_testing/script/mutator.py: -------------------------------------------------------------------------------- 1 | import yaml 2 | import argparse 3 | import subprocess 4 | import os 5 | 6 | parser = argparse.ArgumentParser(description='Mutate single variable') 7 | parser.add_argument("file_name", type=str, help="Unit test file name") 8 | parser.add_argument("group_name", type=str, help="Unit test group name") 9 | parser.add_argument("test_name", type=str, help="Specific unit test name") 10 | parser.add_argument("variable_name", type=str, help="Variable name") 11 | args = parser.parse_args() 12 | 13 | # Fetch data from original_inputs 14 | original_file_path = "../original_inputs/" + args.file_name + ".yml" 15 | 16 | with open(original_file_path, 'r') as file: 17 | inputs = yaml.safe_load(file) 18 | 19 | value = inputs[args.group_name][args.test_name][args.variable_name] 20 | 21 | # Mutation 22 | # Pipe the output to a txt file, we can not save this output as a variable in python3 because 23 | # as it might be converted to a binary 24 | if os.path.exists("temp.txt"): 25 | os.remove("temp.txt") 26 | subprocess.check_output("echo {0} | radamsa > temp.txt".format(value), shell=True) 27 | # Remove last newline character 28 | subprocess.check_output("perl -pi -e 'chomp if eof' temp.txt", shell=True) 29 | mutated_key = args.group_name + "--" + args.test_name + "--" + args.variable_name 30 | 31 | # Output to mutated_inputs 32 | mutated_inputs_path = "../mutated_inputs" 33 | mutated_inputs_file_path = mutated_inputs_path + "/" + args.file_name + ".yml" 34 | if not os.path.exists(mutated_inputs_path): 35 | os.makedirs(mutated_inputs_path) 36 | tab = " " 37 | col = ":" 38 | nl = "\n" 39 | if os.path.exists(mutated_inputs_file_path): 40 | os.remove(mutated_inputs_file_path) 41 | for group in inputs: 42 | with open(mutated_inputs_file_path, 'a+') as file: 43 | file.write(group + col + nl) 44 | for test in inputs[group]: 45 | with open(mutated_inputs_file_path, 'a+') as file: 46 | file.write(tab + test + col + nl) 47 | for var in inputs[group][test]: 48 | with open(mutated_inputs_file_path, 'a+') as file: 49 | file.write(tab + tab + var + col + " \"") 50 | # file.write(inputs[group][test][var]) 51 | current_key = group + "--" + test + "--" + var 52 | if current_key == mutated_key: 53 | command = "cat temp.txt >> " + mutated_inputs_file_path 54 | subprocess.check_output(command, shell=True) 55 | else: 56 | with open(mutated_inputs_file_path, 'a+') as file: 57 | file.write(inputs[group][test][var]) 58 | with open(mutated_inputs_file_path, 'a+') as file: 59 | file.write("\"" + nl) 60 | -------------------------------------------------------------------------------- /fuzz_testing/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | add_library(test_acl_fuzz_test_header INTERFACE) 5 | target_include_directories(test_acl_fuzz_test_header INTERFACE .) 6 | 7 | add_executable(acl_fuzz_test 8 | $ 9 | acl_auto_configure_fuzz_test.cpp 10 | acl_globals_fuzz_test.cpp 11 | acl_hal_fuzz_test.cpp 12 | acl_fuzz_test.cpp 13 | ) 14 | set_target_properties(acl_fuzz_test PROPERTIES CXX_EXTENSIONS OFF) 15 | target_compile_features(acl_fuzz_test PRIVATE cxx_std_11) 16 | target_compile_definitions(acl_fuzz_test PRIVATE 17 | "ACL_TARGET_BIT=${ACL_TARGET_BIT}" 18 | CL_USE_DEPRECATED_OPENCL_1_0_APIS=1 19 | CL_USE_DEPRECATED_OPENCL_1_1_APIS=1 20 | CL_USE_DEPRECATED_OPENCL_1_2_APIS=1 21 | CL_TARGET_OPENCL_VERSION=300 22 | ) 23 | target_include_directories(acl_fuzz_test PRIVATE 24 | "${CMAKE_BINARY_DIR}/include" 25 | "${CMAKE_SOURCE_DIR}/src" 26 | ) 27 | target_link_libraries(acl_fuzz_test PRIVATE 28 | acl_headers 29 | acl_check_sys_cmd 30 | acl_hash 31 | acl_threadsupport 32 | CppUTest 33 | pkg_editor 34 | ) 35 | 36 | # Fuzz tests should not be added to regular unit testing, it should be explicitly called 37 | # add_test(NAME acl_fuzz_test COMMAND acl_fuzz_test -v) 38 | # set_property(TEST acl_fuzz_test PROPERTY ENVIRONMENT 39 | # "AOCL_BOARD_PACKAGE_ROOT=${CMAKE_CURRENT_SOURCE_DIR}/board/a10_ref" 40 | # ) 41 | -------------------------------------------------------------------------------- /fuzz_testing/test/acl_fuzz_test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_TEST_H 5 | #define ACL_TEST_H 6 | 7 | #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) 8 | 9 | #include 10 | 11 | #include 12 | 13 | #include 14 | 15 | #include 16 | 17 | // Use the default board for the SDK, but with less memory for unit test 18 | // purposes. Must also update the table of hashes in acl_program_test.cpp 19 | #if ACDS_PRO == 0 20 | #define ACLTEST_DEFAULT_BOARD "s5_net_small" 21 | #else 22 | #define ACLTEST_DEFAULT_BOARD "a10_ref_small" 23 | #endif 24 | 25 | // Default setup and teardown. 26 | void acl_test_setup_generic_system(); 27 | void acl_test_setup_empty_system(); 28 | void acl_test_setup_sample_default_board_system(void); 29 | void acl_test_teardown_generic_system(void); 30 | void acl_test_teardown_system(void); 31 | void acl_test_teardown_sample_default_board_system(void); 32 | void acl_hal_test_setup_generic_system(void); 33 | void acl_hal_test_teardown_generic_system(void); 34 | void acl_test_run_standard_teardown_checks(); 35 | 36 | void acl_test_unsetenv(const char *var); 37 | void acl_test_setenv(const char *var, const char *value); 38 | 39 | cl_context_properties *acl_test_context_prop_preloaded_binary_only(void); 40 | 41 | const unsigned char *acl_test_get_example_binary(size_t *binary_len); 42 | 43 | SimpleString StringFrom(cl_uint x); 44 | SimpleString StringFrom(cl_ulong x); 45 | SimpleString StringFrom(size_t x); 46 | 47 | #ifdef _WIN32 48 | SimpleString StringFrom(intptr_t x); 49 | #endif 50 | 51 | // Context error notify callback function. 52 | void CL_CALLBACK acl_test_notify_print(const char *errinfo, 53 | const void *private_info, size_t cb, 54 | void *user_data); 55 | 56 | #define ACL_LOCKED(...) \ 57 | do { \ 58 | std::scoped_lock lock{acl_mutex_wrapper}; \ 59 | { __VA_ARGS__; } \ 60 | } while (0) 61 | 62 | /* CAUTION. These are only used in self-tests. 63 | * The runtime does not use these constants any more. 64 | */ 65 | #define ACL_MAX_EVENT (1024 * 16) 66 | #define ACL_MAX_COMMAND \ 67 | ACL_MAX_EVENT /* each event refers to a command. if same number of them, \ 68 | then there is less worry about running out of commands when \ 69 | creating an event */ 70 | 71 | typedef struct mem_data_s mem_data_t; 72 | 73 | typedef struct mem_data_s { 74 | int mmd_interface; 75 | size_t offset; 76 | size_t size; 77 | void *data; 78 | mem_data_t *next; 79 | } mem_data_t; 80 | typedef struct { 81 | cl_bool is_active; 82 | mem_data_t *mem_data; 83 | aocl_mmd_interrupt_handler_fn kernel_interrupt; 84 | void *interrupt_user_data; 85 | aocl_mmd_status_handler_fn kernel_status; 86 | void *status_user_data; 87 | } acl_hal_device_test; 88 | 89 | // Default mem_org address. 90 | // Runtime is now using one loaded from autodiscovery, 91 | // rather than hard coded value. 92 | // For tests, autodiscovery will still have the default value. 93 | #define OFFSET_MEM_ORG ((dev_addr_t)0x0018) 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /fuzz_testing/test/acl_globals_fuzz_test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_GLOBALS_TEST_H 5 | #define ACL_GLOBALS_TEST_H 6 | 7 | #include 8 | 9 | const acl_system_def_t *acl_test_get_complex_system_def(); 10 | const acl_system_def_t *acl_test_get_empty_system_def(); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /fuzz_testing/test/acl_hal_fuzz_test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_HAL_TEST_H 5 | #define ACL_HAL_TEST_H 6 | 7 | // A simple HAL for testing. 8 | 9 | const acl_hal_t *acl_test_get_simple_hal(void); 10 | 11 | void acltest_hal_teardown(void); 12 | 13 | // Make sure that all these device addresses have host storage representing 14 | // them. And translate them into a host pointer. It's transient though! 15 | void *acltest_translate_device_address(const void *device_ptr, size_t offset); 16 | 17 | void acl_test_hal_set_svm_memory_support(int value); 18 | void acl_test_hal_set_physical_memory_support(bool value); 19 | void acl_test_hal_set_buffer_location_support(bool value); 20 | 21 | extern bool acltest_hal_emulate_device_mem; 22 | 23 | void acltest_call_event_update_callback(cl_event event, int new_status); 24 | void acltest_call_kernel_update_callback(int activation_id, cl_int status); 25 | void acltest_call_printf_buffer_callback(int activation_id, int size, 26 | int stalled); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /glibc_wrap/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT WIN32) 2 | add_library(glibc_wrap STATIC glibc_wrap.c) 3 | # Ensure position-independent code is generated 4 | set_target_properties(glibc_wrap PROPERTIES POSITION_INDEPENDENT_CODE ON) 5 | target_include_directories(glibc_wrap PRIVATE ${CMAKE_SOURCE_DIR}/src) 6 | # Specify the wrapped functions on the interface link options. 7 | # This causes libraries linking against this one to use the wrapped 8 | # functions rather than those in a potentially too new glibc for 9 | # our minimum supported OS. See glibc_wrap.c for details. 10 | target_link_libraries(glibc_wrap INTERFACE ${GLIBC_WRAP_FUNCTIONS}) 11 | 12 | # Link the math library for debian-11-arm-dev 13 | target_link_libraries(glibc_wrap INTERFACE m) 14 | 15 | install(TARGETS glibc_wrap DESTINATION ${CMAKE_SOURCE_DIR}/glibc_wrap) 16 | endif() 17 | -------------------------------------------------------------------------------- /glibc_wrap/glibc_wrap.c: -------------------------------------------------------------------------------- 1 | // These functions are only called by our code when built on newer distros. We 2 | // add '-Wl,--wrap={funcname}' to the link line which changes all calls to 3 | // '{funcname}' to '__wrap_{funcname}' 4 | 5 | // For all the gritty details: 6 | // https://www.win.tue.nl/~aeb/linux/misc/gcc-semibug.html 7 | // https://stackoverflow.com/questions/4032373/linking-against-an-old-version-of-libc-to-provide-greater-application-coverage 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #ifndef __arm__ 15 | // Use GLIBC 2.2.5 versioning only if not on ARM 16 | asm(".symver log2_glibc_225, log2@GLIBC_2.2.5"); 17 | extern double log2_glibc_225(double num); 18 | #endif 19 | 20 | double __wrap_log2(double num) { 21 | #ifdef __arm__ 22 | // If compiling for ARM, just call the system-native log2 function 23 | return log2(num); 24 | #else 25 | // Call the GLIBC 2.2.5 version of log2 if not on ARM 26 | return log2_glibc_225(num); 27 | #endif 28 | } 29 | 30 | pid_t __wrap_gettid(void) { return (pid_t)syscall(SYS_gettid); } 31 | -------------------------------------------------------------------------------- /include/CL/.clang-format: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | DisableFormat: true 5 | SortIncludes: false 6 | -------------------------------------------------------------------------------- /include/CL/cl_dx9_media_sharing_intel.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-2020 The Khronos Group Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #include 18 | #pragma message("The Intel DX9 media sharing extensions have been moved into cl_dx9_media_sharing.h. Please include cl_dx9_media_sharing.h directly.") 19 | -------------------------------------------------------------------------------- /include/CL/cl_ext_intel.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-2020 The Khronos Group Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | ******************************************************************************/ 17 | 18 | #include 19 | #pragma message("The Intel extensions have been moved into cl_ext.h. Please include cl_ext.h directly.") 20 | -------------------------------------------------------------------------------- /include/CL/cl_gl_ext.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-2021 The Khronos Group Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #include 18 | #pragma message("All OpenGL-related extensions have been moved into cl_gl.h. Please include cl_gl.h directly.") 19 | -------------------------------------------------------------------------------- /include/CL/cl_layer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 The Khronos Group Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * OpenCL is a trademark of Apple Inc. used under license by Khronos. 17 | */ 18 | 19 | #ifndef OPENCL_CL_LAYER_H 20 | #define OPENCL_CL_LAYER_H 21 | 22 | #include 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | typedef cl_uint cl_layer_info; 29 | typedef cl_uint cl_layer_api_version; 30 | #define CL_LAYER_API_VERSION 0x4240 31 | #define CL_LAYER_API_VERSION_100 100 32 | 33 | extern CL_API_ENTRY cl_int CL_API_CALL 34 | clGetLayerInfo(cl_layer_info param_name, 35 | size_t param_value_size, 36 | void *param_value, 37 | size_t *param_value_size_ret); 38 | 39 | typedef cl_int 40 | (CL_API_CALL *pfn_clGetLayerInfo)(cl_layer_info param_name, 41 | size_t param_value_size, 42 | void *param_value, 43 | size_t *param_value_size_ret); 44 | 45 | extern CL_API_ENTRY cl_int CL_API_CALL 46 | clInitLayer(cl_uint num_entries, 47 | const cl_icd_dispatch *target_dispatch, 48 | cl_uint *num_entries_ret, 49 | const cl_icd_dispatch **layer_dispatch_ret); 50 | 51 | typedef cl_int 52 | (CL_API_CALL *pfn_clInitLayer)(cl_uint num_entries, 53 | const cl_icd_dispatch *target_dispatch, 54 | cl_uint *num_entries_ret, 55 | const cl_icd_dispatch **layer_dispatch_ret); 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif /* OPENCL_CL_LAYER_H */ 62 | -------------------------------------------------------------------------------- /include/CL/cl_version.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2018-2020 The Khronos Group Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef __CL_VERSION_H 18 | #define __CL_VERSION_H 19 | 20 | /* Detect which version to target */ 21 | #if !defined(CL_TARGET_OPENCL_VERSION) 22 | #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)") 23 | #define CL_TARGET_OPENCL_VERSION 300 24 | #endif 25 | #if CL_TARGET_OPENCL_VERSION != 100 && \ 26 | CL_TARGET_OPENCL_VERSION != 110 && \ 27 | CL_TARGET_OPENCL_VERSION != 120 && \ 28 | CL_TARGET_OPENCL_VERSION != 200 && \ 29 | CL_TARGET_OPENCL_VERSION != 210 && \ 30 | CL_TARGET_OPENCL_VERSION != 220 && \ 31 | CL_TARGET_OPENCL_VERSION != 300 32 | #pragma message("cl_version: CL_TARGET_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220, 300). Defaulting to 300 (OpenCL 3.0)") 33 | #undef CL_TARGET_OPENCL_VERSION 34 | #define CL_TARGET_OPENCL_VERSION 300 35 | #endif 36 | 37 | 38 | /* OpenCL Version */ 39 | #if CL_TARGET_OPENCL_VERSION >= 300 && !defined(CL_VERSION_3_0) 40 | #define CL_VERSION_3_0 1 41 | #endif 42 | #if CL_TARGET_OPENCL_VERSION >= 220 && !defined(CL_VERSION_2_2) 43 | #define CL_VERSION_2_2 1 44 | #endif 45 | #if CL_TARGET_OPENCL_VERSION >= 210 && !defined(CL_VERSION_2_1) 46 | #define CL_VERSION_2_1 1 47 | #endif 48 | #if CL_TARGET_OPENCL_VERSION >= 200 && !defined(CL_VERSION_2_0) 49 | #define CL_VERSION_2_0 1 50 | #endif 51 | #if CL_TARGET_OPENCL_VERSION >= 120 && !defined(CL_VERSION_1_2) 52 | #define CL_VERSION_1_2 1 53 | #endif 54 | #if CL_TARGET_OPENCL_VERSION >= 110 && !defined(CL_VERSION_1_1) 55 | #define CL_VERSION_1_1 1 56 | #endif 57 | #if CL_TARGET_OPENCL_VERSION >= 100 && !defined(CL_VERSION_1_0) 58 | #define CL_VERSION_1_0 1 59 | #endif 60 | 61 | /* Allow deprecated APIs for older OpenCL versions. */ 62 | #if CL_TARGET_OPENCL_VERSION <= 220 && !defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS) 63 | #define CL_USE_DEPRECATED_OPENCL_2_2_APIS 64 | #endif 65 | #if CL_TARGET_OPENCL_VERSION <= 210 && !defined(CL_USE_DEPRECATED_OPENCL_2_1_APIS) 66 | #define CL_USE_DEPRECATED_OPENCL_2_1_APIS 67 | #endif 68 | #if CL_TARGET_OPENCL_VERSION <= 200 && !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS) 69 | #define CL_USE_DEPRECATED_OPENCL_2_0_APIS 70 | #endif 71 | #if CL_TARGET_OPENCL_VERSION <= 120 && !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS) 72 | #define CL_USE_DEPRECATED_OPENCL_1_2_APIS 73 | #endif 74 | #if CL_TARGET_OPENCL_VERSION <= 110 && !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 75 | #define CL_USE_DEPRECATED_OPENCL_1_1_APIS 76 | #endif 77 | #if CL_TARGET_OPENCL_VERSION <= 100 && !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS) 78 | #define CL_USE_DEPRECATED_OPENCL_1_0_APIS 79 | #endif 80 | 81 | #endif /* __CL_VERSION_H */ 82 | -------------------------------------------------------------------------------- /include/CL/opencl.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-2021 The Khronos Group Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef __OPENCL_H 18 | #define __OPENCL_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif /* __OPENCL_H */ 33 | -------------------------------------------------------------------------------- /include/MMD/.clang-format: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | DisableFormat: true 5 | SortIncludes: false 6 | -------------------------------------------------------------------------------- /include/MMD/aocl_mmd_deprecated.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef AOCL_MMD_OTHER_H 5 | #define AOCL_MMD_OTHER_H 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | /* Support for USM calls on ACL devices*/ 12 | 13 | #ifndef AOCL_MMD_CALL 14 | #if defined(_WIN32) 15 | #define AOCL_MMD_CALL __declspec(dllimport) 16 | #else 17 | #define AOCL_MMD_CALL 18 | #endif 19 | #endif 20 | 21 | #ifndef WEAK 22 | #if defined(_WIN32) 23 | #define WEAK 24 | #else 25 | #define WEAK __attribute__((weak)) 26 | #endif 27 | #endif 28 | 29 | /* DEPRECATED. Use aocl_mmd_program instead 30 | * This reprogram API is only for mmd version previous than 18.1 31 | */ 32 | AOCL_MMD_CALL int aocl_mmd_reprogram( int handle, void * user_data, size_t size) WEAK; 33 | 34 | /** 35 | * Legacy shared memory allocator. Consider using the new API aocl_mmd_shared_alloc. 36 | * Allocates memory that is shared between the host and the FPGA. The 37 | * host will access this memory using the pointer returned by 38 | * aocl_mmd_shared_mem_alloc, while the FPGA will access the shared memory 39 | * using device_ptr_out. If shared memory is not supported this should return 40 | * NULL. 41 | * 42 | * Shared memory survives FPGA reprogramming if the CPU is not rebooted. 43 | * 44 | * Arguments: 45 | * size - the size of the shared memory to allocate 46 | * device_ptr_out - will receive the pointer value used by the FPGA (the device) 47 | * to access the shared memory. Cannot be NULL. The type is 48 | * unsigned long long to handle the case where the host has a 49 | * smaller pointer size than the device. 50 | * 51 | * Returns: The pointer value to be used by the host to access the shared 52 | * memory if successful, otherwise NULL. 53 | */ 54 | AOCL_MMD_CALL void * aocl_mmd_shared_mem_alloc( int handle, size_t size, unsigned long long *device_ptr_out ) WEAK; 55 | 56 | /** 57 | * Frees memory allocated by aocl_mmd_shared_mem_alloc(). If shared memory is not supported, 58 | * this function should do nothing. 59 | * 60 | * Arguments: 61 | * host_ptr - the host pointer that points to the shared memory, as returned by 62 | * aocl_mmd_shared_mem_alloc 63 | * size - the size of the shared memory to free. Must match the size 64 | * originally passed to aocl_mmd_shared_mem_alloc 65 | */ 66 | AOCL_MMD_CALL void aocl_mmd_shared_mem_free ( int handle, void* host_ptr, size_t size ) WEAK; 67 | 68 | /** 69 | * Make host memory allocation available on specific device 70 | * @param name Device name that will now have access to the host allocation 71 | * @param size The size of the host allocation 72 | * @param host_ptr The pointer to host allocated memory 73 | */ 74 | AOCL_MMD_CALL void aocl_mmd_shared_mem_prepare_buffer( const char *name, size_t size, void* host_ptr ) WEAK; 75 | 76 | /** 77 | * Release the buffer that has been prepared by aocl_mmd_shared_mem_prepare_buffer() 78 | * Must be called for each device the memory has been prepared for, before that 79 | * memory can be released by the host. 80 | * @param name Device name that had access to the host allocation 81 | * @param host_ptr The pointer to host allocated memory 82 | */ 83 | AOCL_MMD_CALL void aocl_mmd_shared_mem_release_buffer ( const char *name, void* host_ptr ) WEAK; 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif //AOCL_MMD_OTHER_H 90 | -------------------------------------------------------------------------------- /include/acl_auto.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #if defined(__cplusplus) 5 | extern "C" { 6 | #endif 7 | 8 | /* Get version info from boilerplate infrastructure. 9 | * This is a .tmpl file so that #include "acl_auto.h" forces 10 | * the preprocessor is forced to get the file contents from 11 | * the work dir, not the original source dir. 12 | * Example, for ACL being in 17.1 OR 17.1std: 13 | * ACL_VERSION is "v17.1.0" 14 | * ACL_VERSION_PLAIN is "17.1" 15 | * ACL_VERSION_PLAIN_FOR_DRIVER_QUERY is "17.1" 16 | * The last one is for the driver version query. The OpenCL spec says it 17 | * has to match \d+.\d+ and nothing else. 18 | */ 19 | #define ACL_VERSION "v2025.1.0" 20 | #define ACL_VERSION_PLAIN "2025.1" 21 | #define ACL_VERSION_PLAIN_FOR_DRIVER_QUERY "2025.1" 22 | 23 | /* Check if we are currently compiling for ACDS Pro or Standard. 24 | * 1 means Pro and 0 means Standard. 25 | */ 26 | #define ACDS_PRO 1 27 | 28 | /* 29 | * This symbol will be unique for a version and build. 30 | * Link will fail if libraries don't line up. 31 | */ 32 | #define ACL_VERSION_COMPATIBILITY_SYMBOL _ALTERA_SDK_FOR_OPENCL_21_1_0_98_2 33 | extern int ACL_VERSION_COMPATIBILITY_SYMBOL; 34 | #define ACL_USE_VERSION_COMPATIBILITY_SYMBOL \ 35 | { ACL_VERSION_COMPATIBILITY_SYMBOL = 42; } 36 | 37 | #if defined(__cplusplus) 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /include/acl_auto_configure.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_AUTO_CONFIGURE_H 5 | #define ACL_AUTO_CONFIGURE_H 6 | 7 | #include "acl.h" 8 | #include "acl_types.h" 9 | #include "acl_visibility.h" 10 | 11 | #ifdef __GNUC__ 12 | #pragma GCC visibility push(protected) 13 | #endif 14 | 15 | // Load info about a compiled program from its system description string into 16 | // devdef. 17 | // Return true if successful, false otherwise. 18 | // If an error occurred err_str will contain an error message describing the 19 | // cause of the failure. 20 | bool acl_load_device_def_from_str(const std::string &config_str, 21 | acl_device_def_autodiscovery_t &devdef, 22 | std::string &err_str) noexcept; 23 | 24 | #ifdef __GNUC__ 25 | #pragma GCC visibility pop 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /include/acl_auto_configure_version.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_AUTO_CONFIGURE_VERSIONID 5 | // ATTENTION! The autodiscovery string is now forward-compatible; as a result 6 | // the version ID should not be updated except in very special circustances. 7 | #define ACL_AUTO_CONFIGURE_VERSIONID 23 8 | 9 | #endif 10 | 11 | // This is the oldest version with which the current ACL host runtime is 12 | // compatible. When you update this, make sure to update the backwards 13 | // compatibility unit test in acl_auto_configure_test.cpp. The test is currently 14 | // located in the "simple" test of the auto_configure testgroup. 15 | 16 | #ifndef ACL_AUTO_CONFIGURE_BACKWARDS_COMPATIBLE_WITH_VERSIONID 17 | #define ACL_AUTO_CONFIGURE_BACKWARDS_COMPATIBLE_WITH_VERSIONID 23 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /include/acl_bsp_io.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_BSP_IO_H 5 | #define ACL_BSP_IO_H 6 | 7 | #ifndef _WIN32 8 | #include 9 | #endif 10 | #include 11 | 12 | #include "acl_hal_mmd.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | typedef unsigned long long time_ns; 19 | 20 | // Board addresses are independent of host, so define type for device addresses 21 | typedef uintptr_t dev_addr_t; 22 | 23 | struct acl_bsp_io_t; 24 | typedef struct acl_bsp_io_t acl_bsp_io; 25 | 26 | struct acl_bsp_io_t { 27 | 28 | acl_mmd_device_t *device_info; 29 | 30 | // Read accessor - returns number of bytes read 31 | size_t (*read)(acl_bsp_io *io, dev_addr_t src, char *dest, size_t size); 32 | 33 | // Write accessor - returns number of bytes written 34 | size_t (*write)(acl_bsp_io *io, dev_addr_t dest, const char *src, 35 | size_t size); 36 | 37 | time_ns (*get_time_ns)(); 38 | 39 | int (*printf)(const char *fmt, ...); 40 | 41 | int debug_verbosity; 42 | }; 43 | 44 | int acl_bsp_io_is_valid(acl_bsp_io *bsp_io); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif // ACL_BSP_IO_H 51 | -------------------------------------------------------------------------------- /include/acl_command.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_COMMAND_H 5 | #define ACL_COMMAND_H 6 | 7 | #include "acl.h" 8 | #include "acl_types.h" 9 | 10 | #ifdef __GNUC__ 11 | #pragma GCC visibility push(protected) 12 | #endif 13 | 14 | // Launch a command if we can. 15 | // Return a number bigger than zero if we made forward progress, false 16 | // otherwise. 17 | int acl_submit_command(cl_event event); 18 | 19 | #ifdef __GNUC__ 20 | #pragma GCC visibility pop 21 | #endif 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /include/acl_command_queue.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_COMMAND_QUEUE_H 5 | #define ACL_COMMAND_QUEUE_H 6 | 7 | #include "acl.h" 8 | #include "acl_types.h" 9 | 10 | #ifdef __GNUC__ 11 | #pragma GCC visibility push(protected) 12 | #endif 13 | 14 | // Caller must have already checked that they we can add another. 15 | void acl_command_queue_add_event(cl_command_queue command_queue, 16 | cl_event event); 17 | 18 | #if defined(__cplusplus) 19 | extern "C" { 20 | #endif 21 | 22 | // Process updates on the queue. 23 | // This is part of the main event loop for the runtime. 24 | // Respond to status updates from devices 25 | // Process event completion 26 | // 27 | // Returns number of things updated. 28 | // If it's 0 then we're idle and can "wait" a bit longer perhaps. 29 | // If it's greater than zero, then we should continue updating the 30 | // contexts's queues because perhaps we have finished a command and removed 31 | // some event dependencies. That might allow dependent events to become 32 | // ready and hence we can launch their associated commands. 33 | int acl_update_queue(cl_command_queue command_queue); 34 | int acl_update_inorder_queue(cl_command_queue command_queue); 35 | int acl_update_ooo_queue(cl_command_queue command_queue); 36 | 37 | // Update data structures in response to async msgs from devices. 38 | void acl_idle_update_queue(cl_command_queue command_queue); 39 | 40 | // Delete the command queue if the command queue is no longer retained 41 | void acl_delete_command_queue(cl_command_queue command_queue); 42 | 43 | #if defined(__cplusplus) 44 | } /* extern "C" */ 45 | #endif 46 | 47 | #ifdef __GNUC__ 48 | #pragma GCC visibility pop 49 | #endif 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /include/acl_context.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_CONTEXT_H 5 | #define ACL_CONTEXT_H 6 | 7 | #include 8 | 9 | #include "acl_types.h" 10 | 11 | #if defined(__cplusplus) 12 | extern "C" { 13 | #endif 14 | 15 | #ifdef __GNUC__ 16 | #pragma GCC visibility push(protected) 17 | #endif 18 | 19 | // Constants 20 | static constexpr const char *ENV_CL_CONTEXT_ALLOW_MULTIPROCESSING_INTELFPGA = 21 | "CL_CONTEXT_ALLOW_MULTIPROCESSING_INTELFPGA"; 22 | static constexpr const char *ENV_AOCL_EAGERLY_LOAD_FIRST_BINARY = 23 | "AOCL_EAGERLY_LOAD_FIRST_BINARY"; 24 | static constexpr const char *ENV_CL_CONTEXT_COMPILER_MODE_INTELFPGA = 25 | "CL_CONTEXT_COMPILER_MODE_INTELFPGA"; 26 | static constexpr const char *ENV_CL_CONTEXT_COMPILER_MODE_ALTERA = 27 | "CL_CONTEXT_COMPILER_MODE_ALTERA"; 28 | static constexpr const char *ENV_CL_CONTEXT_PROGRAM_EXE_LIBRARY_ROOT_INTELFPGA = 29 | "CL_CONTEXT_PROGRAM_EXE_LIBRARY_ROOT_INTELFPGA"; 30 | static constexpr const char *ENV_CL_CONTEXT_COMPILE_COMMAND_INTELFPGA = 31 | "CL_CONTEXT_COMPILE_COMMAND_INTELFPGA"; 32 | static constexpr const char *ENV_ACL_CONTEXT_CALLBACK_DEBUG = 33 | "ACL_CONTEXT_CALLBACK_DEBUG"; 34 | 35 | // Update data structures in response to async msgs from devices. 36 | // Do this as part of a waiting loop, along with acl_hal_yield(). 37 | void acl_update_context(cl_context context); 38 | void acl_idle_update(cl_context context); 39 | 40 | int acl_context_uses_device(cl_context context, cl_device_id device); 41 | 42 | acl_kernel_invocation_wrapper_t * 43 | acl_get_unused_kernel_invocation_wrapper(cl_context context); 44 | 45 | void acl_context_print_hung_device_status(cl_context context); 46 | 47 | #ifdef __GNUC__ 48 | #pragma GCC visibility pop 49 | #endif 50 | 51 | #if defined(__cplusplus) 52 | } /* extern "C" */ 53 | #endif 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /include/acl_device_op.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_DEVICE_OP_H 5 | #define ACL_DEVICE_OP_H 6 | 7 | #include "acl_types.h" 8 | #include "acl_visibility.h" 9 | 10 | #ifdef __GNUC__ 11 | #pragma GCC visibility push(protected) 12 | #endif 13 | 14 | #if defined(__cplusplus) 15 | extern "C" { 16 | #endif 17 | 18 | void acl_init_device_op_queue(acl_device_op_queue_t *device_op_queue); 19 | void acl_init_device_op_queue_limited(acl_device_op_queue_t *device_op_queue, 20 | int max_allowed); 21 | 22 | // Get the next device op, and claim it as a proposed device operation. 23 | // Return NULL when there are no more. 24 | acl_device_op_t *acl_propose_device_op(acl_device_op_queue_t *device_op_queue, 25 | acl_device_op_type_t type, 26 | cl_event event); 27 | acl_device_op_t * 28 | acl_propose_indexed_device_op(acl_device_op_queue_t *device_op_queue, 29 | acl_device_op_type_t type, cl_event event, 30 | unsigned int index); 31 | int acl_first_proposed_device_op_idx(acl_device_op_queue_t *device_op_queue); 32 | 33 | void acl_commit_proposed_device_ops(acl_device_op_queue_t *device_op_queue); 34 | void acl_forget_proposed_device_ops(acl_device_op_queue_t *device_op_queue); 35 | 36 | // Update the queue to reflect asynchronous completion of operations. 37 | // Returns number of updates made. 38 | unsigned acl_update_device_op_queue(acl_device_op_queue_t *device_op_queue); 39 | 40 | // Set execution status. This is to be called by the HAL. 41 | void acl_set_device_op_execution_status(acl_device_op_t *op, cl_int new_status); 42 | 43 | ////////////////// 44 | // These functions are used only internally to the module, but are exposed 45 | // for test purposes. 46 | 47 | // This is the standard callback the HAL should use to communicate most updates. 48 | void acl_submit_device_op(acl_device_op_queue_t *device_op_queue, 49 | acl_device_op_t *op); 50 | void acl_post_status_to_owning_event(acl_device_op_t *op, int new_status); 51 | acl_device_op_conflict_type_t acl_device_op_conflict_type(acl_device_op_t *op); 52 | void acl_device_op_reset_device_op(acl_device_op_t *op); 53 | 54 | #if defined(__cplusplus) 55 | } /* extern "C" */ 56 | #endif 57 | 58 | #ifdef __GNUC__ 59 | #pragma GCC visibility pop 60 | #endif 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /include/acl_event.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_EVENT_H 5 | #define ACL_EVENT_H 6 | 7 | #include "acl.h" 8 | #include "acl_types.h" 9 | #include "acl_visibility.h" 10 | 11 | #if defined(__cplusplus) 12 | extern "C" { 13 | #endif 14 | 15 | #ifdef __GNUC__ 16 | #pragma GCC visibility push(protected) 17 | #endif 18 | 19 | void acl_reset_event(cl_event event); 20 | 21 | // Create an event that depends on the given events. 22 | // Execution status begins as CL_QUEUED. 23 | // Consider this a step in what would be an Event constructor. 24 | // 25 | // Return CL_SUCCESS if all is ok. 26 | // Can return 27 | // CL_OUT_OF_HOST_MEMORY when resources are exhausted 28 | // CL_INVALID_COMMAND_QUEUE if the command queue is invalid 29 | // CL_INVALID_CONTEXT if not all events are on the same context. 30 | cl_int acl_create_event(cl_command_queue command_queue, cl_uint num_events, 31 | const cl_event *events, // array of events to depend on 32 | cl_command_type command_type, cl_event *new_event_ret); 33 | 34 | // Return CL_SUCCESS if the list of events is non-empty and valid, 35 | // and all are associated with the given context. 36 | cl_int acl_check_events_in_context( 37 | cl_context context, cl_uint num_events, 38 | const cl_event *events // array of events to depend on 39 | ); 40 | // Return CL_SUCCESS if the list of events is non-empty and valid 41 | // and have consistent context. 42 | // Otherwise return CL_INVALID_VALUE or other error status. 43 | cl_int acl_check_events(cl_uint num_events, 44 | const cl_event *events // array of events to depend on 45 | ); 46 | 47 | // Delete an event if nothing else refers to it. 48 | // Returns non-zero if it was deleted, 0 if not. 49 | int acl_maybe_delete_event(cl_event event); 50 | 51 | // Remove this event from all the dependency lists of downstream events. 52 | // Returns number of notifications. 53 | int acl_notify_dependent_events(cl_event event); 54 | 55 | // Removes the dependency link between the given event 56 | // and the first event that depends on it 57 | // returns the dependent event removed 58 | cl_event acl_remove_first_event_dependency(cl_event event); 59 | 60 | // Is this event ready to be submitted? 61 | // Make this a macro so that in the common case we don't incur 62 | // a function call overhead. 63 | #define acl_event_is_ready_to_run(E) \ 64 | ((E)->late_link == ACL_OPEN && (E)->execution_status == CL_QUEUED && \ 65 | acl_event_resources_are_available(E)) 66 | 67 | // Are all the resources required by this command available? 68 | // This is used to make sure we don't run the same kernel simultaneously 69 | // from different command queues, because we only have one hardware 70 | // block for the given kernel. 71 | int acl_event_resources_are_available(cl_event event); 72 | 73 | // The function that will notify the callback event functions registered via 74 | // clSetEventCallback 75 | void acl_event_callback(cl_event event, cl_int event_command_exec_status); 76 | 77 | // This callback is used by the HAL to indicate progress from queued 78 | // to running, and from running to complete. 79 | ACL_EXPORT void acl_set_execution_status(cl_event event, int new_status); 80 | 81 | #ifdef __GNUC__ 82 | #pragma GCC visibility pop 83 | #endif 84 | 85 | #if defined(__cplusplus) 86 | } /* extern "C" */ 87 | #endif 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /include/acl_globals.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_GLOBALS_H 5 | #define ACL_GLOBALS_H 6 | 7 | #include "acl.h" 8 | #include "acl_types.h" 9 | 10 | #if defined(__cplusplus) 11 | extern "C" { 12 | #endif 13 | 14 | #ifdef __GNUC__ 15 | #pragma GCC visibility push(protected) 16 | #endif 17 | 18 | // Returns 0 if it's not valid. 19 | acl_system_def_t *acl_present_board_def(void); 20 | int acl_present_board_is_valid(void); 21 | 22 | // Can't use ACL after this. 23 | // Undoes acl_init(). 24 | void acl_reset(void); 25 | 26 | // Initializes the HAL and loads the builtin system definition. 27 | // 28 | // In normal flows this calls into the HAL to probe the device 29 | // to get the system definition. 30 | // 31 | // It also supports an "offline device" flow. 32 | // If environment variable CL_CONTEXT_OFFLINE_DEVICE_INTELFPGA 33 | // is set, then it names a device that we make sure will be available. 34 | // 35 | // If the device name is prefixed by "+" then that offline device 36 | // is made available in addition to devices found via HAL probing. 37 | // Otherwise, *only* the offline device is made available, and 38 | // we use a simple HAL that emulates interaction with the device. 39 | // The key differences are: 40 | // - device global memory is really in host memory 41 | // - kernels don't do computation: they just complete immediately. 42 | // 43 | // This function returns CL_TRUE if a hal is initialized and CL_FALSE 44 | // if it is not. 45 | cl_bool acl_init_from_hal_discovery(void); 46 | 47 | // Looks at environment variable CL_CONTEXT_OFFLINE_DEVICE_INTELFPGA. 48 | // If it exists and is prefixed by "+" then: 49 | // Return a pointer to the device name (without the "+" prefix). 50 | // Set *use_offline_ret_only = 1 51 | // If it exists and is not prefixed by "+" then 52 | // Return a pointer to the device name. 53 | // Set *use_offline_ret_only = 0 54 | #define ACL_CONTEXT_OFFLINE_AND_AUTODISCOVERY 0 55 | #define ACL_CONTEXT_OFFLINE_ONLY 1 56 | #define ACL_CONTEXT_MPSIM 4 57 | const char *acl_get_offline_device_user_setting(int *use_offline_only_ret); 58 | 59 | ACL_EXPORT 60 | extern struct _cl_platform_id acl_platform; 61 | 62 | #ifdef __GNUC__ 63 | #pragma GCC visibility pop 64 | #endif 65 | 66 | #if defined(__cplusplus) 67 | } /* extern "C" */ 68 | #endif 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /include/acl_hostch.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_HOSTCH_H 5 | #define ACL_HOSTCH_H 6 | 7 | #include "acl.h" 8 | #include "acl_types.h" 9 | #include "acl_visibility.h" 10 | 11 | #ifdef __GNUC__ 12 | #pragma GCC visibility push(protected) 13 | #endif 14 | 15 | #if defined(__cplusplus) 16 | extern "C" { 17 | #endif 18 | 19 | // Bind a cl_pipe to a channel on a particular device 20 | cl_int acl_bind_pipe_to_channel(cl_mem pipe, cl_device_id device, 21 | const acl_device_def_autodiscovery_t &devdef); 22 | // Process all the pending transactions on a cl_pipe 23 | void acl_process_pipe_transactions(cl_mem pipe); 24 | // Bind all cl_pipe in the context for the given device and process all the 25 | // pending transactions 26 | void acl_bind_and_process_all_pipes_transactions( 27 | cl_context context, cl_device_id device, 28 | const acl_device_def_autodiscovery_t &devdef); 29 | 30 | // Submit a program hostpipe read device operation to the device op queue 31 | // acl_read_program_hostpipe will be invoked when the read op is RUNNING 32 | cl_int acl_submit_read_program_hostpipe_device_op(cl_event event); 33 | // Submit a program hostpipe write device operation to the device op queue 34 | cl_int acl_submit_write_program_hostpipe_device_op(cl_event event); 35 | 36 | // Read from a program hostpipe 37 | void acl_read_program_hostpipe(void *user_data, acl_device_op_t *op); 38 | 39 | // Write into a program hostpipe 40 | // acl_write_program_hostpipe will be invoked when the write op is RUNNING 41 | void acl_write_program_hostpipe(void *user_data, acl_device_op_t *op); 42 | 43 | #define HOST_TO_DEVICE 1 44 | #define DEVICE_TO_HOST 0 45 | 46 | #if defined(__cplusplus) 47 | } /* extern "C" */ 48 | #endif 49 | 50 | #ifdef __GNUC__ 51 | #pragma GCC visibility pop 52 | #endif 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/acl_icd_dispatch.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_ICD_DISPATCH_H 5 | #define ACL_ICD_DISPATCH_H 6 | 7 | #ifdef _MSC_VER 8 | #pragma warning(push) 9 | // C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um\d3d11.h(1349): 10 | // warning C4365: '=': conversion from 'LONG' to 'UINT', signed/unsigned 11 | // mismatch 12 | #pragma warning(disable : 4365) 13 | // C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um\d3d11.h(3477): 14 | // warning C4061: enumerator 'D3D_SRV_DIMENSION_UNKNOWN' in switch of enum 15 | // 'D3D_SRV_DIMENSION' is not explicitly handled by a case label 16 | #pragma warning(disable : 4061) 17 | #endif 18 | #include 19 | #ifdef _MSC_VER 20 | #pragma warning(pop) 21 | #endif 22 | 23 | #ifdef __GNUC__ 24 | #pragma GCC visibility push(protected) 25 | #endif 26 | 27 | #if defined(__cplusplus) 28 | extern "C" { 29 | #endif 30 | 31 | extern cl_icd_dispatch acl_icd_dispatch; 32 | 33 | #if defined(__cplusplus) 34 | } /* extern "C" */ 35 | #endif 36 | 37 | #ifdef __GNUC__ 38 | #pragma GCC visibility pop 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /include/acl_kernel.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_KERNEL_H 5 | #define ACL_KERNEL_H 6 | 7 | #include "acl.h" 8 | #include "acl_types.h" 9 | #include "acl_visibility.h" 10 | 11 | #ifdef __GNUC__ 12 | #pragma GCC visibility push(protected) 13 | #endif 14 | 15 | #if defined(__cplusplus) 16 | extern "C" { 17 | #endif 18 | 19 | // Find the accelerator implementing the given kernel. 20 | const acl_accel_def_t * 21 | acl_find_accel_def(cl_program program, const std::string &kernel_name, 22 | const acl_device_binary_t *&dev_bin_ret, cl_int *errcode_ret, 23 | cl_context context, cl_device_id which_device); 24 | 25 | // Reset the contents of the kernel. 26 | void acl_reset_kernel(cl_kernel kernel); 27 | 28 | // Return number of non-null mem args. Exposed for unit testing purposes. 29 | int acl_num_non_null_mem_args(cl_kernel kernel); 30 | 31 | // Submit a set of ops to the device op queue, to launch a kernel. 32 | // This may also imply reprogramming the device and transferring buffers 33 | // to and from the device. 34 | // Return a positive number if we committed device ops, zero otherwise. 35 | int acl_submit_kernel_device_op(cl_event event); 36 | 37 | // Called by device op to start the kernel. 38 | // Export this on GCC because it's used as a function pointer. 39 | ACL_EXPORT 40 | void acl_launch_kernel(void *user_data, acl_device_op_t *op); 41 | 42 | // Called when we get a kernel interrupt indicating that profiling data is ready 43 | ACL_EXPORT 44 | void acl_profile_update(int activation_id); 45 | 46 | // This should be called by the HAL, to receive notification of RUNNING and 47 | // COMPLETE state transitions, and used printf buffer size 48 | ACL_EXPORT 49 | void acl_receive_kernel_update(int activation_id, cl_int status); 50 | 51 | // Used to check if one of the kernel arguments needs to be mapped to the device 52 | // When unmapping subbuffers we may transfer memory that is currently used 53 | // by another kernel. Command_queue uses this function to check if it is 54 | // safe to submit a kernel with subbuffers to the device_op_queue 55 | int acl_kernel_has_unmapped_subbuffers(acl_mem_migrate_t *mem_migration); 56 | 57 | // Checks if the program currently loaded on the passed-in device contains 58 | // any device globals with reprogram init mode. When a kernel is submitted 59 | // for the first time and this function returns true, a force reprogram will 60 | // be scheduled even when the kernel binary hash matches the hash of the 61 | // currently loaded program. 62 | bool acl_device_has_reprogram_device_globals(cl_device_id device); 63 | 64 | #if defined(__cplusplus) 65 | } /* extern "C" */ 66 | #endif 67 | 68 | #ifdef __GNUC__ 69 | #pragma GCC visibility pop 70 | #endif 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /include/acl_offline_hal.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_OFFLINE_HAL_H 5 | #define ACL_OFFLINE_HAL_H 6 | 7 | // An offline HAL, for use with offline devices. 8 | 9 | #ifdef __GNUC__ 10 | #pragma GCC visibility push(protected) 11 | #endif 12 | 13 | #if defined(__cplusplus) 14 | extern "C" { 15 | #endif 16 | 17 | #include "acl_hal.h" 18 | 19 | // Return a pointer to an HAL suitable for use with an offline device. 20 | const acl_hal_t *acl_get_offline_hal(void); 21 | 22 | #if defined(__cplusplus) 23 | } /* extern "C" */ 24 | #endif 25 | 26 | #ifdef __GNUC__ 27 | #pragma GCC visibility pop 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /include/acl_platform.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_PLATFORM_H 5 | #define ACL_PLATFORM_H 6 | 7 | #include 8 | 9 | #ifdef __GNUC__ 10 | #pragma GCC visibility push(protected) 11 | #endif 12 | 13 | #if defined(__cplusplus) 14 | extern "C" { 15 | #endif 16 | 17 | // ID of the thread that created platform. 18 | // Used to detect if user is doing mulithreading. 19 | extern int platform_owner_tid; 20 | 21 | void acl_init_platform(void); 22 | void acl_finalize_init_platform(unsigned int num_devices, 23 | const cl_device_id *devices); 24 | const char *acl_platform_extensions(void); 25 | 26 | #if defined(__cplusplus) 27 | } /* extern "C" */ 28 | #endif 29 | 30 | #ifdef __GNUC__ 31 | #pragma GCC visibility pop 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /include/acl_pll.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_PLL_H 5 | #define ACL_PLL_H 6 | 7 | #include 8 | 9 | #include "acl_bsp_io.h" 10 | 11 | // Settings for the Phase-Locked-Loop 12 | // note that we use double frequency of the kernel clock for some double-pumped 13 | // memories 14 | typedef struct { 15 | unsigned int freq_khz; /* output frequency in kHz */ 16 | unsigned int m; /* multiplier factor */ 17 | unsigned int n; /* 1st divider factor */ 18 | unsigned int k; /* 2nd divider factor */ 19 | unsigned int c0; /* output divider for kernel clock */ 20 | unsigned int c1; /* output divider for double kernel clock */ 21 | unsigned int r; /* lowpass filter setting */ 22 | unsigned int cp; /* charge pump gain setting */ 23 | unsigned int div; /* PLL mode */ 24 | } pll_setting_t; 25 | 26 | typedef struct { 27 | acl_bsp_io io; 28 | unsigned int curr_freq_khz; 29 | pll_setting_t *known_settings; 30 | unsigned int num_known_settings; 31 | unsigned int version_id; 32 | } acl_pll; 33 | 34 | // ********************************************************** 35 | // ******************** User Methods *********************** 36 | // ********************************************************** 37 | 38 | /* 39 | * Initialize PLL using the given IO accessors 40 | * Returns 0 on success, -ve on error 41 | */ 42 | int acl_pll_init(acl_pll *pll, acl_bsp_io bsp_io, 43 | const std::string &pkg_pll_config); 44 | 45 | void acl_pll_close(acl_pll *pll); 46 | 47 | // ********************************************************** 48 | // ********************** Advanced ************************* 49 | // ********************************************************** 50 | 51 | /* 52 | * Reconfigure the PLL with the given settings 53 | * Returns 0 on success, -ve on error 54 | */ 55 | int acl_pll_reconfigure(acl_pll *pll, pll_setting_t pllsettings); 56 | 57 | /* 58 | * Resets the pll - use this when you lose lock 59 | */ 60 | void acl_pll_reset(acl_pll *pll); 61 | 62 | /* 63 | * Check PLL lock. Returns 1 if locked, 0 not locked, -ve error 64 | */ 65 | int acl_pll_is_locked(acl_pll *pll); 66 | 67 | /* 68 | * Measure the kernel clock frequencies, returns MHz 69 | */ 70 | float acl_pll_get_kernel_freq(acl_pll *pll); 71 | float acl_pll_get_kernel2x_freq(acl_pll *pll); 72 | 73 | /* 74 | * Return the default pll setting. 75 | */ 76 | pll_setting_t acl_pll_get_default_settings(acl_pll *pll); 77 | 78 | int acl_pll_get_num_settings(acl_pll *pll); 79 | pll_setting_t acl_pll_get_setting(acl_pll *pll, int index); 80 | 81 | #endif // ACL_PLL 82 | -------------------------------------------------------------------------------- /include/acl_printf.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_PRINTF_H 5 | #define ACL_PRINTF_H 6 | 7 | #include "acl.h" 8 | #include "acl_types.h" 9 | #include "acl_visibility.h" 10 | 11 | #if defined(__cplusplus) 12 | extern "C" { 13 | #endif 14 | 15 | #ifdef __GNUC__ 16 | #pragma GCC visibility push(protected) 17 | #endif 18 | 19 | // Enqueue printf buffer dump 20 | ACL_EXPORT 21 | void acl_schedule_printf_buffer_pickup(int activation_id, int size, 22 | int overflow); 23 | 24 | // Print the printf data associated with the given deviced operation 25 | // and hence kernel execution instance. 26 | ACL_EXPORT 27 | void acl_process_printf_buffer(void *user_data, acl_device_op_t *op); 28 | 29 | #ifdef __GNUC__ 30 | #pragma GCC visibility pop 31 | #endif 32 | 33 | #if defined(__cplusplus) 34 | } /* extern "C" */ 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /include/acl_profiler.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_PROFILER_H 5 | #define ACL_PROFILER_H 6 | 7 | #include "acl.h" 8 | #include "acl_types.h" 9 | 10 | #ifdef __GNUC__ 11 | #pragma GCC visibility push(protected) 12 | #endif 13 | 14 | #if defined(__cplusplus) 15 | extern "C" { 16 | #endif 17 | 18 | #define ACL_PROFILE_AUTORUN_KERNEL_NAME \ 19 | "Intel_Internal_Collect_Autorun_Profiling" // Same as AlteraCLParams.h 20 | #define ACL_PROFILER_SHARED_COUNTER "ACL_INTERAL_SHARED_CONTROL_SETTING" 21 | 22 | void acl_init_profiler(); 23 | 24 | // Query whether profiling is enabled 25 | unsigned long is_profile_enabled(); 26 | 27 | // Query whether the profiler is on 28 | unsigned long is_profile_timer_on(); 29 | 30 | void acl_enable_profiler_scan_chain(acl_device_op_t *op); 31 | 32 | // Return non-zero when it actually read the scan chain, 0 when it doesn't do 33 | // anything. 34 | int acl_process_profiler_scan_chain(acl_device_op_t *op); 35 | 36 | // Return non-zero when it actually read the scan chain, 0 when it doesn't do 37 | // anything. 38 | int acl_process_autorun_profiler_scan_chain(unsigned int physical_device_id, 39 | unsigned int accel_id); 40 | 41 | // Sets the start timestamp for the autorun kernels 42 | void acl_set_autorun_start_time(); 43 | 44 | // Gets and sets the shared counter control value 45 | void set_env_shared_counter_val(); 46 | 47 | // Query what the shared counter control is set to 48 | // 0-3 => valid control setting (see ip/src/common/lsu_top.v.tmpl, 49 | // ip/src/common/hld_iord.sv.tmpl, & ip/src/common/hld_iowr.sv.tmpl for what 0-3 50 | // represents) -1 => shared counters are off 51 | int get_env_profile_shared_counter_val(); 52 | 53 | // Open the profiler output file 54 | // Return 1 if successful and 0 otherwise 55 | int acl_open_profiler_file(); 56 | 57 | // Close the profiler file 58 | int acl_close_profiler_file(); 59 | 60 | #if defined(__cplusplus) 61 | } /* extern "C" */ 62 | #endif 63 | 64 | #ifdef __GNUC__ 65 | #pragma GCC visibility pop 66 | #endif 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /include/acl_program.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_PROGRAM_H 5 | #define ACL_PROGRAM_H 6 | 7 | #include "acl.h" 8 | #include "acl_types.h" 9 | 10 | #ifdef __GNUC__ 11 | #pragma GCC visibility push(protected) 12 | #endif 13 | 14 | // Allocate a kernel in this program. 15 | cl_kernel acl_program_alloc_kernel(cl_program); 16 | 17 | // Forget a previously-allocated kernel. 18 | void acl_program_forget_kernel(cl_program program, cl_kernel kernel); 19 | 20 | // Invalidate all builds. Used for testing. 21 | void acl_program_invalidate_builds(cl_program program); 22 | 23 | // Schedule an eager programming of the device onto the device op queue. 24 | // Return a positive number if we succeeded, 0 otherwise. 25 | int acl_submit_program_device_op(cl_event event); 26 | 27 | // Program or reprogram the FPGA. 28 | ACL_EXPORT 29 | void acl_program_device(void *user_data, acl_device_op_t *op); 30 | 31 | std::string acl_compute_hash_dir_name(cl_context context, 32 | const std::string &hash); 33 | 34 | void acl_program_dump_dev_prog(acl_device_program_info_t *dev_prog); 35 | 36 | #ifdef __GNUC__ 37 | #pragma GCC visibility pop 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /include/acl_sampler.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_SAMPLER_H 5 | #define ACL_SAMPLER_H 6 | 7 | #ifdef __GNUC__ 8 | #pragma GCC visibility push(protected) 9 | #endif 10 | 11 | #if defined(__cplusplus) 12 | extern "C" { 13 | #endif 14 | 15 | // Defines to match bitfield in clang 16 | // cl_addressing_mode 17 | 18 | #define CLK_ADDRESS_NONE 0x00; 19 | 20 | #define CLK_ADDRESS_MIRRORED_REPEAT 0x01 21 | 22 | #define CLK_ADDRESS_REPEAT 0x02 23 | 24 | #define CLK_ADDRESS_CLAMP_TO_EDGE 0x03 25 | 26 | #define CLK_ADDRESS_CLAMP 0x04 27 | 28 | // cl_sampler_info 29 | 30 | #define CLK_NORMALIZED_COORDS_FALSE 0x00 31 | 32 | #define CLK_NORMALIZED_COORDS_TRUE 0x08 33 | 34 | // filter mode 35 | 36 | #define CLK_FILTER_NEAREST 0x00 37 | 38 | #define CLK_FILTER_LINEAR 0x10 39 | 40 | #if defined(__cplusplus) 41 | } /* extern "C" */ 42 | #endif 43 | 44 | #ifdef __GNUC__ 45 | #pragma GCC visibility pop 46 | #endif 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /include/acl_shared_aligned_ptr.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #pragma once 5 | 6 | // System headers. 7 | #include 8 | #include 9 | 10 | // External library headers. 11 | 12 | // Internal headers. 13 | #include "acl.h" 14 | 15 | // A type used to manage an aligned memory block allocation. 16 | // The memory is allocated if and only if m_raw is not nullptr. 17 | // The allocated memory is automatically freed when all 18 | // acl_shared_aligned_ptr objects owning it are destroyed. 19 | class acl_shared_aligned_ptr { 20 | public: 21 | acl_shared_aligned_ptr() = default; 22 | acl_shared_aligned_ptr(std::size_t size); 23 | 24 | // Return the allocated pointer aligned 25 | // to the requested alignment. 26 | inline void *get_aligned_ptr() const { return m_aligned_ptr; } 27 | 28 | // Return the requested alignment. 29 | inline std::size_t get_alignment() const { return m_alignment; } 30 | 31 | // Return the total allocated size in bytes after 32 | // adding padding required for the requested alignment. 33 | inline std::size_t get_size() const { return m_size; } 34 | 35 | // Return the total size in bytes that was requested 36 | // to be allocated. 37 | inline std::size_t get_requested_size() const { return m_requested_size; } 38 | 39 | private: 40 | void *m_aligned_ptr = nullptr; // This pointer is aligned as requested. 41 | std::shared_ptr m_raw; // The malloc base pointer returned 42 | // by the system. 43 | std::size_t m_alignment = ACL_MEM_ALIGN; 44 | std::size_t m_size = 0; // Actual allocated size after alignment. 45 | std::size_t m_requested_size = 0; // Requested allocation size. 46 | }; 47 | -------------------------------------------------------------------------------- /include/acl_shipped_board_cfgs.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | #include 4 | 5 | /* Format is std::array of struct containing board name and sys description */ 6 | struct shipped_board_cfg { 7 | const char *name; 8 | const char *cfg; 9 | }; 10 | 11 | static const std::array acl_shipped_board_cfgs = {{ 12 | {"a10gx", "23 16 sample40byterandomhash000000000000000000 a10gx 0 1 9 " 13 | "DDR 2 1 2 0 2147483648 0 - 0 0 0 0 0 "}, 14 | {"a10_ref_small", 15 | "23 16 sample40byterandomhash000000000000000000 a10_ref_small 0 1 9 " 16 | "DDR 2 1 2 0 134217728 0 - 0 0 0 0 0 "}, 17 | {"s10gx", "23 16 sample40byterandomhash000000000000000000 s10gx_ea 0 " 18 | "1 9 DDR 2 1 2 0 2147483648 0 - 0 0 0 0 0 "}, 19 | }}; 20 | -------------------------------------------------------------------------------- /include/acl_svm.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_SVM_H 5 | #define ACL_SVM_H 6 | 7 | #include 8 | 9 | #include "acl_types.h" 10 | 11 | #ifdef __GNUC__ 12 | #pragma GCC visibility push(protected) 13 | #endif 14 | 15 | #if defined(__cplusplus) 16 | extern "C" { 17 | #endif 18 | 19 | void acl_forcibly_release_all_svm_memory_for_context(cl_context context); 20 | 21 | // Get the information about this SVM pointer from the context. 22 | acl_svm_entry_t *acl_get_svm_entry(cl_context context, void *ptr); 23 | 24 | // Check if this SVM pointer is in the context. Can check if it exactly matches 25 | // an allocated pointer or if it is contained within an allocated block of 26 | // memory. 27 | cl_bool acl_ptr_is_exactly_in_context_svm(cl_context context, const void *ptr); 28 | cl_bool acl_ptr_is_contained_in_context_svm(cl_context context, 29 | const void *ptr); 30 | 31 | int acl_svm_op(cl_event event); 32 | 33 | cl_bool acl_svm_device_supports_any_svm(unsigned int physical_device_id); 34 | cl_bool 35 | acl_svm_device_supports_physical_memory(unsigned int physical_device_id); 36 | 37 | #if defined(__cplusplus) 38 | } /* extern "C" */ 39 | #endif 40 | 41 | #ifdef __GNUC__ 42 | #pragma GCC visibility pop 43 | #endif 44 | 45 | #endif // ACL_SVM_H 46 | -------------------------------------------------------------------------------- /include/acl_usm.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_USM_H 5 | #define ACL_USM_H 6 | 7 | #include 8 | 9 | #include "acl_types.h" 10 | 11 | #ifdef __GNUC__ 12 | #pragma GCC visibility push(protected) 13 | #endif 14 | 15 | #if defined(__cplusplus) 16 | extern "C" { 17 | #endif 18 | 19 | int acl_submit_usm_memcpy(cl_event event); 20 | void acl_usm_memcpy(void *user_data, acl_device_op_t *op); 21 | bool acl_usm_ptr_belongs_to_context(cl_context context, const void *ptr); 22 | acl_usm_allocation_t *acl_get_usm_alloc_from_ptr(cl_context context, 23 | const void *ptr); 24 | 25 | /** 26 | * Checks if the device provides CL_UNIFIED_SHARED_MEMORY_ACCESS_INTEL 27 | * capabilities for a given allocation query 28 | * @param device the device to query 29 | * @param query the type of capability that is being queried 30 | * @return true is that query has access capabilities 31 | */ 32 | bool acl_usm_has_access_capability(cl_device_id device, cl_device_info query); 33 | 34 | #if defined(__cplusplus) 35 | } /* extern "C" */ 36 | #endif 37 | 38 | #ifdef __GNUC__ 39 | #pragma GCC visibility pop 40 | #endif 41 | 42 | #endif // ACL_USM_H 43 | -------------------------------------------------------------------------------- /include/acl_version.h.in: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_VERSION_H 5 | #define ACL_VERSION_H 6 | 7 | #define ACL_GIT_COMMIT "@ACL_GIT_COMMIT@" 8 | #define ACL_BANNER \ 9 | "Intel(R) FPGA Runtime for OpenCL(TM) Software Technology, " \ 10 | "Commit " ACL_GIT_COMMIT ", Copyright (C) 2010-2022 Intel Corporation" 11 | 12 | #endif // ACL_VERSION_H 13 | -------------------------------------------------------------------------------- /include/acl_visibility.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_VISIBILITY_H 5 | #define ACL_VISIBILITY_H 6 | 7 | // These can be used to control visibility of the symbol at the library 8 | // boundary. 9 | // E.g. See use in hal/mmd/Makefile 10 | // 11 | // hidden: Symbol not visible outside the library 12 | // 13 | // default: Symbol always visible outside the library. 14 | // For ELF shared libarary, the symbol can also be "interposed", 15 | // i.e. replaced at runtime by the loader (e.g. via LD_PRELOAD) 16 | // 17 | // protected: Visible outside the library, but clients inside 18 | // the same ELF .so can't see any interposed value. 19 | // That is, you'll always get the definition internal to the same 20 | // library. 21 | // See http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Function-Attributes.html 22 | 23 | #if __GNUC__ 24 | #define ACL_VISIBILITY_DEFAULT __attribute__((visibility("default"))) 25 | #define ACL_VISIBILITY_HIDDEN __attribute__((visibility("hidden"))) 26 | #define ACL_VISIBILITY_PROTECTED __attribute__((visibility("protected"))) 27 | #else 28 | #define ACL_VISIBILITY_DEFAULT 29 | #define ACL_VISIBILITY_HIDDEN 30 | #define ACL_VISIBILITY_PROTECTED 31 | #endif 32 | 33 | // Use ACL_EXPORT for symbols we definitely want to export, or which are 34 | // used via function pointers. 35 | #ifndef ACL_EXPORT 36 | #define ACL_EXPORT ACL_VISIBILITY_DEFAULT 37 | #endif 38 | 39 | #endif // ACL_VISIBILITY_H 40 | -------------------------------------------------------------------------------- /lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | add_subdirectory(CppUTest) 5 | add_subdirectory(acl_check_sys_cmd) 6 | add_subdirectory(acl_hash) 7 | add_subdirectory(acl_threadsupport) 8 | add_subdirectory(pkg_editor) 9 | -------------------------------------------------------------------------------- /lib/CppUTest/.clang-format: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | DisableFormat: true 5 | SortIncludes: false 6 | -------------------------------------------------------------------------------- /lib/CppUTest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | add_library(CppUTest STATIC 5 | src/CommandLineArguments.cpp 6 | src/CommandLineTestRunner.cpp 7 | src/Failure.cpp 8 | src/JUnitTestOutput.cpp 9 | src/MemoryLeakAllocator.cpp 10 | src/MemoryLeakDetector.cpp 11 | src/MemoryLeakWarningPlugin.cpp 12 | src/SimpleString.cpp 13 | src/TestHarness_c.cpp 14 | src/TestOutput.cpp 15 | src/TestPlugin.cpp 16 | src/TestRegistry.cpp 17 | src/TestResult.cpp 18 | src/Utest.cpp 19 | src/UtestPlatformGcc.cpp 20 | src/UtestPlatformVisualCpp.cpp 21 | ) 22 | # These macros are used in CppUTest public headers 23 | target_compile_definitions(CppUTest PUBLIC 24 | UT_NEW_MACROS_DISABLED 25 | UT_NEW_OVERRIDES_DISABLED 26 | UT_MALLOC_MACROS_DISABLED 27 | ) 28 | target_link_libraries(CppUTest PRIVATE Threads::Threads) 29 | if(WIN32) 30 | target_link_libraries(CppUTest PRIVATE winmm) 31 | endif() 32 | target_include_directories(CppUTest PUBLIC include) 33 | set_property(TARGET CppUTest PROPERTY PUBLIC_HEADER 34 | include/CppUTest/CommandLineArguments.h 35 | include/CppUTest/CommandLineTestRunner.h 36 | include/CppUTest/Failure.h 37 | include/CppUTest/JUnitTestOutput.h 38 | include/CppUTest/MemoryLeakAllocator.h 39 | include/CppUTest/MemoryLeakDetector.h 40 | include/CppUTest/MemoryLeakWarningPlugin.h 41 | include/CppUTest/PlatformSpecificFunctions.h 42 | include/CppUTest/SimpleString.h 43 | include/CppUTest/Synchronization.h 44 | include/CppUTest/TestHarness.h 45 | include/CppUTest/TestHarness_c.h 46 | include/CppUTest/TestOutput.h 47 | include/CppUTest/TestPlugin.h 48 | include/CppUTest/TestRegistry.h 49 | include/CppUTest/TestResult.h 50 | include/CppUTest/TestTestingFixture.h 51 | include/CppUTest/Utest.h 52 | include/CppUTest/UtestMacros.h 53 | include/CppUTest/VirtualCall.h 54 | ) 55 | 56 | install(TARGETS CppUTest 57 | COMPONENT CppUTest 58 | EXCLUDE_FROM_ALL 59 | ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" 60 | PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/CppUTest" 61 | ) 62 | 63 | add_subdirectory(test) 64 | -------------------------------------------------------------------------------- /lib/CppUTest/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | Neither the name of the nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 9 | 10 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /lib/CppUTest/include/CppUTest/CommandLineArguments.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 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 the nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef D_CommandLineArguments_H 29 | #define D_CommandLineArguments_H 30 | 31 | /////////////////////////////////////////////////////////////////////////////// 32 | // 33 | // CommandLineArguments is responsible for ... 34 | // 35 | /////////////////////////////////////////////////////////////////////////////// 36 | #include "SimpleString.h" 37 | #include "TestOutput.h" 38 | 39 | class TestPlugin; 40 | 41 | class CommandLineArguments 42 | { 43 | public: 44 | explicit CommandLineArguments(int ac, const char** av, TestPlugin*); 45 | virtual ~CommandLineArguments(); 46 | 47 | bool parse(); 48 | bool isVerbose() const; 49 | int getNumThreads() const; 50 | int getRepeatCount() const; 51 | SimpleString getGroupFilter() const; 52 | SimpleString getNameFilter() const; 53 | bool isJUnitOutput() const; 54 | bool isEclipseOutput() const; 55 | const char* usage() const; 56 | 57 | private: 58 | 59 | enum OutputType 60 | { 61 | OUTPUT_ECLIPSE, OUTPUT_JUNIT 62 | }; 63 | int ac; 64 | const char** av; 65 | TestPlugin* plugin_; 66 | 67 | bool verbose_; 68 | int numThreads_; 69 | int repeat_; 70 | SimpleString groupFilter_; 71 | SimpleString nameFilter_; 72 | OutputType outputType_; 73 | 74 | SimpleString getParameterField(int ac, const char** av, int& i); 75 | void SetNumThreads(int ac, const char** av, int& index); 76 | void SetRepeatCount(int ac, const char** av, int& index); 77 | void SetGroupFilter(int ac, const char** av, int& index); 78 | void SetNameFilter(int ac, const char** av, int& index); 79 | bool SetOutputType(int ac, const char** av, int& index); 80 | 81 | CommandLineArguments(const CommandLineArguments&); 82 | CommandLineArguments& operator=(const CommandLineArguments&); 83 | 84 | }; 85 | 86 | #endif // D_CommandLineArguments_H 87 | -------------------------------------------------------------------------------- /lib/CppUTest/include/CppUTest/CommandLineTestRunner.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 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 the nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef D_CommandLineTestRunner_H 29 | #define D_CommandLineTestRunner_H 30 | 31 | #include "TestHarness.h" 32 | #include "TestOutput.h" 33 | #include "CommandLineArguments.h" 34 | 35 | /////////////////////////////////////////////////////////////////////////////// 36 | // 37 | // Main entry point for running a collection of unit tests 38 | // 39 | /////////////////////////////////////////////////////////////////////////////// 40 | 41 | class JUnitTestOutput; 42 | 43 | #define DEF_PLUGIN_MEM_LEAK "MemoryLeakPlugin" 44 | #define DEF_PLUGIN_SET_POINTER "SetPointerPlugin" 45 | 46 | class CommandLineTestRunner 47 | { 48 | public: 49 | enum OutputType 50 | { 51 | OUTPUT_NORMAL, OUTPUT_JUNIT 52 | }; 53 | 54 | static int RunAllTests(int ac, const char** av); 55 | static int RunAllTests(int ac, char** av); 56 | CommandLineTestRunner(int ac, const char** av, TestOutput*); 57 | 58 | virtual ~CommandLineTestRunner(); 59 | int runAllTestsMain(); 60 | 61 | private: 62 | 63 | int argc; 64 | const char** argv; 65 | TestOutput* output_; 66 | JUnitTestOutput* jUnitOutput; 67 | CommandLineArguments* arguments; 68 | 69 | bool parseArguments(TestPlugin*); 70 | int runAllTests(); 71 | void initializeTestRun(); 72 | bool isVerbose(); 73 | int getRepeatCount(); 74 | SimpleString getGroupFilter(); 75 | SimpleString getNameFilter(); 76 | }; 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /lib/CppUTest/include/CppUTest/Failure.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 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 the nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /////////////////////////////////////////////////////////////////////////////// 29 | // 30 | // FAILURE.H 31 | // 32 | // Failure is a class which holds information for a specific 33 | // test failure. It can be overriden for more complex failure messages 34 | // 35 | /////////////////////////////////////////////////////////////////////////////// 36 | 37 | 38 | #ifndef D_Failure_H 39 | #define D_Failure_H 40 | 41 | #include "SimpleString.h" 42 | 43 | class Utest; 44 | class TestOutput; 45 | 46 | class Failure 47 | { 48 | 49 | public: 50 | Failure(Utest*, const char* fileName, long lineNumber, 51 | const SimpleString& theMessage); 52 | Failure(Utest*, const SimpleString& theMessage); 53 | Failure(Utest*, const char* fileName, long lineNumber); 54 | Failure(const Failure&); 55 | virtual ~Failure(); 56 | 57 | virtual SimpleString getFileName() const; 58 | virtual SimpleString getTestName() const; 59 | virtual int getLineNumber() const; 60 | virtual SimpleString getMessage() const; 61 | 62 | protected: 63 | SimpleString testName; 64 | SimpleString fileName; 65 | long lineNumber; 66 | SimpleString message; 67 | 68 | Failure& operator=(const Failure&); 69 | 70 | }; 71 | 72 | class EqualsFailure: public Failure 73 | { 74 | public: 75 | 76 | EqualsFailure(Utest*, const char* fileName, long lineNumber, 77 | const SimpleString& expected, const SimpleString& actual); 78 | }; 79 | 80 | class ContainsFailure: public Failure 81 | { 82 | public: 83 | 84 | ContainsFailure(Utest*, const char* fileName, long lineNumber, 85 | const SimpleString& expected, const SimpleString& actual); 86 | }; 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /lib/CppUTest/include/CppUTest/JUnitTestOutput.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 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 the nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef D_JUnitTestOutput_h 29 | #define D_JUnitTestOutput_h 30 | 31 | #include "TestOutput.h" 32 | #include "SimpleString.h" 33 | 34 | struct JUnitTestOutputImpl; 35 | struct JUnitTestCaseResultNode; 36 | 37 | class JUnitTestOutput: public TestOutput 38 | { 39 | public: 40 | JUnitTestOutput(); 41 | virtual ~JUnitTestOutput(); 42 | 43 | virtual void printTestsStarted(); 44 | virtual void printTestsEnded(const TestResult& result); 45 | virtual void printCurrentTestStarted(const Utest& test); 46 | virtual void printCurrentTestEnded(const TestResult& res); 47 | virtual void printCurrentGroupStarted(const Utest& test); 48 | virtual void printCurrentGroupEnded(const TestResult& res); 49 | 50 | virtual void verbose(); 51 | virtual void print(const char*); 52 | virtual void print(long); 53 | virtual void print(const Failure& failure); 54 | virtual void printTestRun(int number, int total); 55 | 56 | virtual void flush(); 57 | 58 | protected: 59 | 60 | JUnitTestOutputImpl* impl_; 61 | void resetTestGroupResult(); 62 | 63 | virtual void openFileForWrite(const SimpleString& fileName); 64 | virtual void writeTestGroupToFile(); 65 | virtual void writeToFile(const SimpleString& buffer); 66 | virtual void closeFile(); 67 | 68 | virtual void writeXmlHeader(); 69 | virtual void writeTestSuiteSummery(); 70 | virtual void writeProperties(); 71 | virtual void writeTestCases(); 72 | virtual void writeFailure(JUnitTestCaseResultNode* node); 73 | virtual void writeFileEnding(); 74 | 75 | }; 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /lib/CppUTest/include/CppUTest/Synchronization.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde 3 | * Copyright (c) 2015, Intel Corporation 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY 18 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef D_Synchronization_h 30 | #define D_Synchronization_h 31 | 32 | class AtomicUInt 33 | { 34 | public: 35 | explicit AtomicUInt(unsigned int initialValue = 0) { value_ = initialValue; } 36 | void unsafeReset(unsigned int resetValue = 0) { value_ = resetValue; } 37 | unsigned int fetchAndAdd(unsigned int add_value = 1); 38 | operator unsigned int() { return value_; } 39 | 40 | private: 41 | volatile unsigned int value_; 42 | }; 43 | 44 | class ThreadBarrier 45 | { 46 | public: 47 | ThreadBarrier(); 48 | explicit ThreadBarrier(int numThreads); 49 | ~ThreadBarrier(); 50 | 51 | int numThreads(); 52 | void setNumThreads(int numThreads); 53 | void wait(); 54 | 55 | private: 56 | // non-copyable 57 | ThreadBarrier(const ThreadBarrier&); 58 | const ThreadBarrier& operator=(const ThreadBarrier&); 59 | 60 | struct Impl; 61 | Impl* impl_; 62 | }; 63 | 64 | class Mutex 65 | { 66 | public: 67 | Mutex(); 68 | ~Mutex(); 69 | 70 | void lock(); 71 | void unlock(); 72 | 73 | private: 74 | // non-copyable 75 | Mutex(const Mutex&); 76 | const Mutex& operator=(const Mutex&); 77 | 78 | struct Impl; 79 | Impl* impl_; 80 | }; 81 | 82 | class ScopedLock 83 | { 84 | public: 85 | ScopedLock(Mutex& mutex) : mutex_(mutex) 86 | { 87 | mutex_.lock(); 88 | } 89 | 90 | ~ScopedLock() 91 | { 92 | mutex_.unlock(); 93 | } 94 | 95 | private: 96 | // non-copyable 97 | ScopedLock(const ScopedLock&); 98 | const ScopedLock& operator=(const ScopedLock&); 99 | 100 | Mutex& mutex_; 101 | }; 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /lib/CppUTest/include/CppUTest/TestHarness.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde 3 | * Copyright (c) 2015, Intel Corporation 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY 18 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef D_TestHarness_h 30 | #define D_TestHarness_h 31 | 32 | /* Memory leak detector macros: 33 | * 34 | * UT_NEW_MACROS_ENABLED/DISABLED 35 | * Control the #define new. When DISABLED, new with not be #defined. 36 | * Without this, the memory leak detector will not know the file/line location of leaks. 37 | * UT_NEW_OVERRIDES_ENABLED/DISABLED 38 | * Controls the override of the global operator new/deleted. 39 | * Without this, there will be no memory leak detection in C++. 40 | * UT_MALLOC_MACROS_ENABLED/DISABLED 41 | * Controls the #define of malloc for enabling memory leak detection in C. 42 | */ 43 | 44 | #ifndef UT_NEW_MACROS_ENABLED 45 | #ifdef UT_NEW_MACROS_DISABLED 46 | #define UT_NEW_MACROS_ENABLED 0 47 | #else 48 | #define UT_NEW_MACROS_ENABLED 1 49 | #endif 50 | #endif 51 | 52 | #ifndef UT_NEW_OVERRIDES_ENABLED 53 | #ifdef UT_NEW_OVERRIDES_DISABLED 54 | #define UT_NEW_OVERRIDES_ENABLED 0 55 | #undef UT_NEW_MACROS_ENABLED 56 | #define UT_NEW_MACROS_ENABLED 0 57 | #else 58 | #define UT_NEW_OVERRIDES_ENABLED 1 59 | #endif 60 | #endif 61 | 62 | /* original value was 9973 which works will with large programs. Now set to smaller since it takes 63 | * a lot of memory in embedded apps. Change it if you experience the memory leak detector to be slow. 64 | */ 65 | 66 | #define MEMORY_LEAK_HASH_TABLE_SIZE 73 67 | 68 | /* 69 | * Lib C dependencies that are currently still left: 70 | * 71 | * stdarg.h -> We use formatting functions and va_list requires to include stdarg.h in SimpleString 72 | * stdlib.h -> The TestHarness_c.h includes this to try to avoid conflicts in its malloc #define. This dependency can 73 | * easily be removed by not enabling the MALLOC overrides. 74 | */ 75 | 76 | #include "Utest.h" 77 | #include "UtestMacros.h" 78 | #include "SimpleString.h" 79 | #include "TestResult.h" 80 | #include "Failure.h" 81 | #include "TestPlugin.h" 82 | #include "MemoryLeakWarningPlugin.h" 83 | #include "Synchronization.h" 84 | #endif 85 | -------------------------------------------------------------------------------- /lib/CppUTest/include/CppUTest/TestRegistry.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 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 the nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /////////////////////////////////////////////////////////////////////////////// 29 | // 30 | // TESTREGISTRY.H 31 | // 32 | // TestRegistry is a collection of tests that can be run 33 | // 34 | /////////////////////////////////////////////////////////////////////////////// 35 | 36 | #ifndef D_TestRegistry_h 37 | #define D_TestRegistry_h 38 | 39 | #include "SimpleString.h" 40 | 41 | class Utest; 42 | class TestResult; 43 | class TestPlugin; 44 | 45 | class TestRegistry 46 | { 47 | public: 48 | TestRegistry(); 49 | virtual ~TestRegistry(); 50 | 51 | virtual void addTest(Utest *test); 52 | virtual void unDoLastAddTest(); 53 | virtual int countTests(); 54 | virtual void runAllTests(TestResult& result); 55 | virtual void nameFilter(SimpleString); 56 | virtual void groupFilter(SimpleString); 57 | 58 | virtual void installPlugin(TestPlugin* plugin); 59 | virtual void resetPlugins(); 60 | virtual TestPlugin* getFirstPlugin(); 61 | virtual TestPlugin* getPluginByName(const SimpleString& name); 62 | virtual void removePluginByName(const SimpleString& name); 63 | 64 | SimpleString getGroupFilter(); 65 | SimpleString getNameFilter(); 66 | 67 | virtual Utest* getFirstTest(); 68 | virtual Utest* getLastTest(); 69 | virtual Utest* getTestWithNext(Utest* test); 70 | 71 | static TestRegistry* getCurrentRegistry(); 72 | virtual void setCurrentRegistry(TestRegistry* registry); 73 | void cleanup(); 74 | private: 75 | 76 | bool testShouldRun(Utest* test, TestResult& result); 77 | bool endOfGroup(Utest* test); 78 | 79 | Utest * tests; 80 | SimpleString* nameFilter_; 81 | SimpleString* groupFilter_; 82 | TestPlugin* firstPlugin_; 83 | static TestRegistry* currentRegistry_; 84 | 85 | }; 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /lib/CppUTest/include/CppUTest/TestTestingFixture.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 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 the nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef D_TestTestingFixture_H 29 | #define D_TestTestingFixture_H 30 | 31 | class TestTestingFixture 32 | { 33 | public: 34 | 35 | TestTestingFixture() 36 | { 37 | output = new StringBufferTestOutput(); 38 | result = new TestResult(*output); 39 | genTest = new ExecFunctionTest(); 40 | registry = new TestRegistry(); 41 | 42 | registry->setCurrentRegistry(registry); 43 | registry->addTest(genTest); 44 | } 45 | ; 46 | 47 | virtual ~TestTestingFixture() 48 | { 49 | registry->setCurrentRegistry(0); 50 | delete registry; 51 | delete result; 52 | delete output; 53 | delete genTest; 54 | } 55 | 56 | void setTestFunction(void(*testFunction)()) 57 | { 58 | genTest->_testFunction = testFunction; 59 | } 60 | 61 | void setSetup(void(*setupFunction)()) 62 | { 63 | genTest->setup_ = setupFunction; 64 | } 65 | 66 | void setTeardown(void(*teardownFunction)()) 67 | { 68 | genTest->teardown_ = teardownFunction; 69 | } 70 | 71 | void runAllTests() 72 | { 73 | registry->runAllTests(*result); 74 | } 75 | 76 | int getFailureCount() 77 | { 78 | return result->getFailureCount(); 79 | } 80 | 81 | void assertPrintContains(const SimpleString& contains) 82 | { 83 | assertPrintContains(output, contains); 84 | } 85 | 86 | static void assertPrintContains(StringBufferTestOutput* output, 87 | const SimpleString& contains) 88 | { 89 | if (output->getOutput().contains(contains)) return; 90 | SimpleString message("\tActual <"); 91 | message += output->getOutput().asCharString(); 92 | message += ">\n"; 93 | message += "\tdid not contain <"; 94 | message += contains.asCharString(); 95 | message += ">\n"; 96 | FAIL(message.asCharString()); 97 | 98 | } 99 | 100 | TestRegistry* registry; 101 | ExecFunctionTest* genTest; 102 | StringBufferTestOutput* output; 103 | TestResult * result; 104 | }; 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /lib/CppUTest/include/CppUTest/VirtualCall.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 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 the nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef D_VirtualCall_H 29 | #define D_VirtualCall_H 30 | 31 | #define send(obj,msg)\ 32 | ((obj)->msg(obj)) 33 | 34 | #define send1(obj,msg,arg0)\ 35 | ((obj)->msg((obj),(arg0))) 36 | 37 | #define send2(obj,msg,arg0,arg1)\ 38 | ((obj)->msg((obj),(arg0),(arg1))) 39 | 40 | #define send3(obj,msg,arg0,arg1,arg2)\ 41 | ((obj)->msg((obj),(arg0),(arg1),(arg2))) 42 | 43 | #define send4(obj,msg,arg0,arg1,arg2,arg3)\ 44 | ((obj)->msg((obj),(arg0),(arg1),(arg2),(arg3))) 45 | 46 | #define vBind(obj,msg,newMethod)\ 47 | (obj->msg=&newMethod) 48 | 49 | #define castToDestroyer(Class) (Class* (*)(Class*)) 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /lib/CppUTest/src/Failure.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 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 the nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "CppUTest/TestHarness.h" 29 | #include "CppUTest/Failure.h" 30 | #include "CppUTest/TestOutput.h" 31 | 32 | Failure::Failure(Utest* test, const char* fileName, long lineNumber, 33 | const SimpleString& theMessage) : 34 | testName(test->getFormattedName()), fileName(fileName), lineNumber( 35 | lineNumber), message(theMessage) 36 | { 37 | } 38 | 39 | Failure::Failure(Utest* test, const SimpleString& theMessage) : 40 | testName(test->getFormattedName()), fileName(test->getFile()), lineNumber( 41 | test->getLineNumber()), message(theMessage) 42 | { 43 | } 44 | 45 | Failure::Failure(Utest* test, const char* fileName, long lineNum) : 46 | testName(test->getFormattedName()), fileName(fileName), 47 | lineNumber(lineNum), message("no message") 48 | { 49 | } 50 | 51 | Failure::Failure(const Failure& f) : 52 | testName(f.testName), fileName(f.fileName), lineNumber(f.lineNumber), 53 | message(f.message) 54 | { 55 | } 56 | 57 | Failure::~Failure() 58 | { 59 | } 60 | 61 | SimpleString Failure::getFileName() const 62 | { 63 | return fileName; 64 | } 65 | 66 | SimpleString Failure::getTestName() const 67 | { 68 | return testName; 69 | } 70 | 71 | int Failure::getLineNumber() const 72 | { 73 | return lineNumber; 74 | } 75 | 76 | SimpleString Failure::getMessage() const 77 | { 78 | return message; 79 | } 80 | 81 | EqualsFailure::EqualsFailure(Utest* test, const char* fileName, 82 | long lineNumber, const SimpleString& expected, 83 | const SimpleString& actual) : 84 | Failure(test, fileName, lineNumber) 85 | { 86 | 87 | const char* format = "expected <%s>\n\tbut was <%s>"; 88 | message = StringFromFormat(format, expected.asCharString(), 89 | actual.asCharString()); 90 | } 91 | 92 | ContainsFailure::ContainsFailure(Utest* test, const char* fileName, 93 | long lineNumber, const SimpleString& expected, 94 | const SimpleString& actual) : 95 | Failure(test, fileName, lineNumber) 96 | { 97 | 98 | const char* format = "actual <%s>\n\tdid not contain <%s>"; 99 | message = StringFromFormat(format, actual.asCharString(), 100 | expected.asCharString()); 101 | } 102 | -------------------------------------------------------------------------------- /lib/CppUTest/test/AllTests.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 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 the nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "CppUTest/CommandLineTestRunner.h" 29 | 30 | int main(int ac, const char** av) 31 | { 32 | return CommandLineTestRunner::RunAllTests(ac, av); 33 | } 34 | 35 | -------------------------------------------------------------------------------- /lib/CppUTest/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | add_executable(CppUTestTests 5 | AllTests.cpp 6 | CommandLineArgumentsTest.cpp 7 | CommandLineTestRunnerTest.cpp 8 | FailureTest.cpp 9 | JUnitOutputTest.cpp 10 | MemoryLeakAllocatorTest.cpp 11 | MemoryLeakDetectorTest.cpp 12 | MemoryLeakWarningTest.cpp 13 | NullTestTest.cpp 14 | PluginTest.cpp 15 | SetPluginTest.cpp 16 | SimpleStringTest.cpp 17 | TestHarness_cTest.cpp 18 | TestInstallerTest.cpp 19 | TestOutputTest.cpp 20 | TestRegistryTest.cpp 21 | TestResultTest.cpp 22 | UtestTest.cpp 23 | ) 24 | target_link_libraries(CppUTestTests PRIVATE CppUTest) 25 | add_test(NAME CppUTestTests COMMAND CppUTestTests -v) 26 | -------------------------------------------------------------------------------- /lib/CppUTest/test/CommandLineTestRunnerTest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 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 the nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "CppUTest/TestHarness.h" 29 | #include "CppUTest/CommandLineTestRunner.h" 30 | #include "CppUTest/TestRegistry.h" 31 | #include "CppUTest/TestTestingFixture.h" 32 | #include "CppUTest/TestPlugin.h" 33 | 34 | TEST_GROUP(CommandLineTestRunner) 35 | { 36 | void setup() 37 | { 38 | } 39 | void teardown() 40 | { 41 | } 42 | }; 43 | 44 | IGNORE_TEST(CommandLineTestRunner, HmmmmWhatToWrite) 45 | { 46 | //TODO: maybe some tests are in order 47 | } 48 | -------------------------------------------------------------------------------- /lib/CppUTest/test/FailureTest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 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 the nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "CppUTest/TestHarness.h" 29 | #include "CppUTest/TestOutput.h" 30 | 31 | namespace 32 | { 33 | const int failLineNumber = 2; 34 | const char* failFileName = "fail.cpp"; 35 | } 36 | 37 | TEST_GROUP(Failure) 38 | { Utest* test; 39 | StringBufferTestOutput* printer; 40 | 41 | TEST_SETUP() 42 | { 43 | test = new NullTest(); 44 | printer = new StringBufferTestOutput(); 45 | } 46 | TEST_TEARDOWN() 47 | { 48 | delete test; 49 | delete printer; 50 | }; 51 | }; 52 | 53 | TEST(Failure, CreateFailure) 54 | { 55 | Failure f1(test, failFileName, failLineNumber, "the failure message"); 56 | Failure f2(test, "the failure message"); 57 | Failure f3(test, failFileName, failLineNumber); 58 | } 59 | 60 | TEST(Failure, CreatePassingEqualsFailure) 61 | { 62 | EqualsFailure f(test, failFileName, failLineNumber, "expected", "actual"); 63 | } 64 | -------------------------------------------------------------------------------- /lib/CppUTest/test/NullTestTest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 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 the nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "CppUTest/TestHarness.h" 29 | 30 | TEST_GROUP(NullTest) 31 | { NullTest* nullTest; 32 | 33 | TEST_SETUP() 34 | { 35 | nullTest = new NullTest(); 36 | } 37 | TEST_TEARDOWN() 38 | { 39 | delete nullTest; 40 | } 41 | }; 42 | 43 | TEST(NullTest, Create) 44 | { 45 | } 46 | 47 | TEST(NullTest, InstanceAlwaysTheSame) 48 | { 49 | NullTest& _instance = NullTest::instance(); 50 | CHECK(&_instance == &NullTest::instance()); 51 | } 52 | 53 | TEST(NullTest, NullTestsDontCount) 54 | { 55 | NullTest& _instance = NullTest::instance(); 56 | CHECK(_instance.countTests() == 0); 57 | } 58 | -------------------------------------------------------------------------------- /lib/CppUTest/test/TestInstallerTest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 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 the nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "CppUTest/TestHarness.h" 29 | #include "CppUTest/TestRegistry.h" 30 | 31 | // this is file scope because the test is installed 32 | // with all other tests, which also happen to be 33 | // created as static instances at file scope 34 | 35 | static NullTest nullTest; 36 | 37 | TEST_GROUP(TestInstaller) 38 | { TestInstaller* testInstaller; 39 | TestRegistry* myRegistry; 40 | void setup() 41 | { 42 | myRegistry = new TestRegistry(); 43 | myRegistry->setCurrentRegistry(myRegistry); 44 | testInstaller = new TestInstaller(&nullTest, "TestInstaller", 45 | "test", __FILE__, __LINE__); 46 | } 47 | void teardown() 48 | { 49 | myRegistry->setCurrentRegistry(0); 50 | testInstaller->unDo(); 51 | delete testInstaller; 52 | delete myRegistry; 53 | } 54 | }; 55 | 56 | TEST(TestInstaller, Create) 57 | { 58 | } 59 | 60 | -------------------------------------------------------------------------------- /lib/CppUTest/test/TestResultTest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 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 the nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "CppUTest/TestHarness.h" 29 | #include "CppUTest/PlatformSpecificFunctions.h" 30 | #include "CppUTest/TestOutput.h" 31 | 32 | static long MockGetPlatformSpecificTimeInMillis() 33 | { 34 | return 10; 35 | } 36 | 37 | TEST_GROUP(TestResult) 38 | { 39 | TestOutput* printer; 40 | StringBufferTestOutput* mock; 41 | 42 | TestResult* res; 43 | 44 | TEST_SETUP() 45 | { 46 | mock = new StringBufferTestOutput(); 47 | printer = mock; 48 | res = new TestResult(*printer); 49 | SetPlatformSpecificTimeInMillisMethod(MockGetPlatformSpecificTimeInMillis); 50 | } 51 | TEST_TEARDOWN() 52 | { 53 | SetPlatformSpecificTimeInMillisMethod(0); 54 | delete printer; 55 | delete res; 56 | } 57 | }; 58 | 59 | TEST(TestResult, TestEndedWillPrintResultsAndExecutionTime) 60 | { 61 | res->testsEnded(); 62 | CHECK(mock->getOutput().contains("10 ms")); 63 | } 64 | -------------------------------------------------------------------------------- /lib/acl_check_sys_cmd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | add_library(acl_check_sys_cmd STATIC src/acl_check_sys_cmd.c) 5 | target_include_directories(acl_check_sys_cmd PUBLIC include) 6 | set_target_properties(acl_check_sys_cmd PROPERTIES 7 | POSITION_INDEPENDENT_CODE ON 8 | ) 9 | set_property(TARGET acl_check_sys_cmd PROPERTY PUBLIC_HEADER 10 | include/acl_check_sys_cmd/acl_check_sys_cmd.h 11 | ) 12 | 13 | install(TARGETS acl_check_sys_cmd 14 | COMPONENT acl_check_sys_cmd 15 | EXCLUDE_FROM_ALL 16 | ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" 17 | PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/acl_check_sys_cmd" 18 | ) 19 | 20 | add_subdirectory(test) 21 | -------------------------------------------------------------------------------- /lib/acl_check_sys_cmd/include/acl_check_sys_cmd/acl_check_sys_cmd.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_CHECK_SYS_CMD_H 5 | #define ACL_CHECK_SYS_CMD_H 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | // Check whether "cmd" only contains the following characters: 12 | // letters, digits 13 | // '\t', '\n', ' ', '"', '&', '\'', '-', '.', '/', ':', ';', 14 | // '=', '>', '@', '\\', '_', '~' 15 | // If yes, return 1; otherwise, return 0; 16 | int system_cmd_is_valid(const char *cmd); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /lib/acl_check_sys_cmd/src/acl_check_sys_cmd.c: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #include "acl_check_sys_cmd/acl_check_sys_cmd.h" 5 | 6 | #define NUM_SPECIAL_CHAR 17 7 | 8 | static int binary_search(const char *arr, int l, int r, char x) { 9 | while (l <= r) { 10 | int m = l + (r - l) / 2; 11 | if (arr[m] == x) { 12 | return m; 13 | } 14 | 15 | if (arr[m] < x) { 16 | l = m + 1; 17 | } else { 18 | r = m - 1; 19 | } 20 | } 21 | return -1; 22 | } 23 | 24 | int system_cmd_is_valid(const char *cmd) { 25 | // Following special charaters are allowed. 26 | // Important: must store them in (ASCII) order 27 | const char valid_special_char[NUM_SPECIAL_CHAR] = { 28 | '\t', '\n', ' ', '"', '&', '\'', '-', '.', '/', 29 | ':', ';', '=', '>', '@', '\\', '_', '~'}; 30 | 31 | const char *c = cmd; 32 | while (*c != '\0') { 33 | if ((*c >= '0' && *c <= '9') || (*c >= 'A' && *c <= 'Z') || 34 | (*c >= 'a' && *c <= 'z') || 35 | binary_search(valid_special_char, 0, NUM_SPECIAL_CHAR - 1, *c) != -1) { 36 | c++; 37 | } else { 38 | return 0; 39 | } 40 | } 41 | return 1; 42 | } 43 | -------------------------------------------------------------------------------- /lib/acl_check_sys_cmd/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | add_executable(acl_check_sys_cmd_test acl_check_sys_cmd_test.cpp) 5 | target_link_libraries(acl_check_sys_cmd_test PRIVATE acl_check_sys_cmd) 6 | add_test(acl_check_sys_cmd_test acl_check_sys_cmd_test -v) 7 | -------------------------------------------------------------------------------- /lib/acl_check_sys_cmd/test/acl_check_sys_cmd_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | // Unit tests for system_cmd_is_valid() function 5 | 6 | #include "acl_check_sys_cmd/acl_check_sys_cmd.h" 7 | #include 8 | #include 9 | 10 | // Unit tests. 11 | #define CHECK(fn_test, good_value) \ 12 | std::cout << #fn_test << " = " << fn_test << "\n"; \ 13 | assert(fn_test == good_value) 14 | 15 | int main() { 16 | 17 | // these are example cmds that are ran via system()/popen() function calls 18 | 19 | // letters digits space > / _ 20 | CHECK(system_cmd_is_valid("ls /sys/class/aclpci_a10_ref 2>/dev/null"), 1); 21 | 22 | // . - 23 | CHECK(system_cmd_is_valid("quartus_stp -t /scripts/find_jtag_cable.tcl 0x02"), 24 | 1); 25 | 26 | // : '\' 27 | CHECK(system_cmd_is_valid( 28 | "quartus_stp -t D:\\scripts\\find_jtag_cable.tcl 0x02"), 29 | 1); 30 | 31 | // " ; @ 32 | CHECK(system_cmd_is_valid("quartus_pgm -c cable -m jtag -o \"P;file@16\""), 33 | 1); 34 | 35 | // & = \n 36 | CHECK(system_cmd_is_valid("aoc -tidy >build.log 2>&1 -board=arria10 " 37 | "-initial-dir=./mydir clfile -options\n"), 38 | 1); 39 | 40 | // ~ \t ' 41 | CHECK(system_cmd_is_valid("test ~ \t '"), 1); 42 | 43 | // invalid charaters 44 | CHECK(system_cmd_is_valid("test ` "), 0); 45 | CHECK(system_cmd_is_valid("test ! "), 0); 46 | CHECK(system_cmd_is_valid("test # "), 0); 47 | CHECK(system_cmd_is_valid("test $ "), 0); 48 | CHECK(system_cmd_is_valid("test % "), 0); 49 | CHECK(system_cmd_is_valid("test ^ "), 0); 50 | CHECK(system_cmd_is_valid("test * "), 0); 51 | CHECK(system_cmd_is_valid("test ( "), 0); 52 | CHECK(system_cmd_is_valid("test ) "), 0); 53 | CHECK(system_cmd_is_valid("test + "), 0); 54 | CHECK(system_cmd_is_valid("test { "), 0); 55 | CHECK(system_cmd_is_valid("test } "), 0); 56 | CHECK(system_cmd_is_valid("test [ "), 0); 57 | CHECK(system_cmd_is_valid("test ] "), 0); 58 | CHECK(system_cmd_is_valid("test | "), 0); 59 | CHECK(system_cmd_is_valid("test < "), 0); 60 | CHECK(system_cmd_is_valid("test , "), 0); 61 | CHECK(system_cmd_is_valid("test ? "), 0); 62 | 63 | std::cout << "All acl_check_sys_cmd tests completed successfully!\n"; 64 | return 0; 65 | } 66 | -------------------------------------------------------------------------------- /lib/acl_hash/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | add_library(acl_hash STATIC src/acl_hash.c) 5 | target_include_directories(acl_hash PUBLIC include) 6 | set_target_properties(acl_hash PROPERTIES POSITION_INDEPENDENT_CODE ON) 7 | set_property(TARGET acl_hash PROPERTY PUBLIC_HEADER 8 | include/acl_hash/acl_hash.h 9 | ) 10 | 11 | 12 | define_file_basename_for_sources(acl_hash) 13 | 14 | install(TARGETS acl_hash 15 | COMPONENT acl_hash 16 | EXCLUDE_FROM_ALL 17 | ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" 18 | PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/acl_hash" 19 | ) 20 | 21 | add_subdirectory(test) 22 | -------------------------------------------------------------------------------- /lib/acl_hash/include/acl_hash/acl_hash.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_HASH_H 5 | #define ACL_HASH_H 6 | 7 | // Hashing 8 | // ======= 9 | // 10 | // Compute SHA-1 digests for byte sequences of up to 2^64-9 bytes. 11 | // Beyond 2^64 - 9 bytes, it fails silently. 12 | // 13 | // References: 14 | // - RFC 3174. 15 | // - http://en.wikipedia.org/wiki/SHA-1 16 | // 17 | // Validated against Perl 5.8.8 Digest::SHA1 module, and sample 18 | // code in RFC 3174. 19 | // 20 | // Example: 21 | // 22 | // acl_hash_context_t ctx; 23 | // char digest[41]; 24 | // if ( acl_hash_init_sha1( &ctx ) 25 | // && acl_hash_add( &ctx, "abc", 3 ) 26 | // && acl_hash_add( &ctx, "defg", 4 ) 27 | // && acl_hash_hexdigest( &ctx, digest, 41 ) ) { 28 | // // Now I've got the hext digest! 29 | // } else { 30 | // // error somewhere along the way. 31 | // } 32 | 33 | #include 34 | 35 | #if defined(__cplusplus) 36 | extern "C" { 37 | #endif 38 | 39 | #ifdef _MSC_VER 40 | typedef unsigned __int64 uint64_t; 41 | typedef unsigned __int32 uint32_t; 42 | #else 43 | #include 44 | #endif 45 | 46 | /* The number of bytes required to store a NUL terminated hex string 47 | * representing an SHA-1 hash. 48 | * SHA-1 is 160 bits, so 40 hex chars plus a NUL terminator. 49 | */ 50 | #define ACL_HASH_SHA1_DIGEST_BUFSIZE 41 51 | 52 | typedef struct { 53 | // From SHA-1. http://en.wikipedia.org/wiki/SHA-1 54 | uint64_t len; // Number of bytes in the user data (so far) 55 | uint32_t h0, h1, h2, h3, h4; 56 | // The (len % 64) most recent bytes to be added. 57 | // tail[0] is the earliest data byte, and so on. 58 | unsigned char tail[64]; 59 | } acl_hash_sha1_context_t; 60 | 61 | typedef struct { 62 | int is_open; // Still accepting more additions? 63 | union { 64 | acl_hash_sha1_context_t sha1; 65 | } alg; 66 | } acl_hash_context_t; 67 | 68 | // Each of these returns 0 for failure, non-zero for success. 69 | int acl_hash_init_sha1(acl_hash_context_t *ctx); 70 | int acl_hash_add(acl_hash_context_t *ctx, const void *buf, size_t len); 71 | int acl_hash_add_file(acl_hash_context_t *ctx, const char *filename); 72 | 73 | // Get a digest. Once this is called, you can't further add data to be 74 | // digested. 75 | // Buf can be NULL, in which case no digest is written out. 76 | // Return true if we could compute the digest, and it fits in buf_size 77 | // characters (including the terminating NUL). 78 | int acl_hash_hexdigest(acl_hash_context_t *ctx, char *digest_buf, 79 | size_t digest_buf_size); 80 | 81 | #if defined(__cplusplus) 82 | } /* extern "C" */ 83 | #endif 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /lib/acl_hash/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | add_executable(acl_hash_test acl_test.cpp acl_hash_test.cpp) 5 | target_include_directories(acl_hash_test PUBLIC ../include ../src) 6 | target_link_libraries(acl_hash_test PRIVATE CppUTest) 7 | target_compile_definitions(acl_hash_test PRIVATE 8 | "ACL_TARGET_BIT=${ACL_TARGET_BIT}" 9 | ) 10 | add_test(acl_hash_test acl_hash_test -v) 11 | -------------------------------------------------------------------------------- /lib/acl_hash/test/acl_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #include "CppUTest/CommandLineTestRunner.h" 5 | #include "CppUTest/SimpleString.h" 6 | #include "CppUTest/TestHarness.h" 7 | 8 | #include "acl_hash/acl_hash.h" 9 | #include 10 | #include 11 | #include 12 | 13 | int main(int argc, const char **argv) { 14 | return CommandLineTestRunner::RunAllTests(argc, argv); 15 | } 16 | 17 | #ifdef _WIN32 18 | #define snprintf sprintf_s 19 | #endif 20 | 21 | SimpleString StringFrom(uint32_t x) { 22 | char buf[30]; // probably 12 will do 23 | snprintf(&buf[0], sizeof(buf) / sizeof(buf[0]), "%u", x); 24 | const char *start_of_buf = &buf[0]; 25 | return StringFrom(start_of_buf); 26 | } 27 | #if ACL_TARGET_BIT == 32 28 | SimpleString StringFrom(uint64_t x) { 29 | char buf[30]; // probably 12 will do 30 | snprintf(&buf[0], sizeof(buf) / sizeof(buf[0]), "%lu", x); 31 | const char *start_of_buf = &buf[0]; 32 | return StringFrom(start_of_buf); 33 | } 34 | #endif 35 | #ifdef _WIN64 36 | SimpleString StringFrom(intptr_t x) { 37 | char buf[30]; // probably 12 will do 38 | snprintf(&buf[0], sizeof(buf) / sizeof(buf[0]), "%lu", x); 39 | const char *start_of_buf = &buf[0]; 40 | return StringFrom(start_of_buf); 41 | } 42 | #endif 43 | // If ACL_TARGET_BIT is 32, then size_t == cl_ulong == cl_uint, and we've 44 | // already got a body for that. 45 | #if ACL_TARGET_BIT > 32 46 | SimpleString StringFrom(size_t x) { 47 | char buf[30]; // probably 12 will do 48 | snprintf(&buf[0], sizeof(buf) / sizeof(buf[0]), "%zd", 49 | x); // format string might be platform dependent..? 50 | const char *start_of_buf = &buf[0]; 51 | return StringFrom(start_of_buf); 52 | } 53 | #endif 54 | -------------------------------------------------------------------------------- /lib/acl_hash/test/acl_test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #include "CppUTest/SimpleString.h" 5 | #include "acl_hash/acl_hash.h" 6 | 7 | SimpleString StringFrom(uint32_t x); 8 | SimpleString StringFrom(uint64_t x); 9 | SimpleString StringFrom(intptr_t x); 10 | SimpleString StringFrom(size_t x); 11 | -------------------------------------------------------------------------------- /lib/acl_threadsupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | add_library(acl_threadsupport STATIC src/acl_threadsupport.c) 5 | target_include_directories(acl_threadsupport PUBLIC include) 6 | set_target_properties(acl_threadsupport PROPERTIES POSITION_INDEPENDENT_CODE ON) 7 | set_property(TARGET acl_threadsupport PROPERTY PUBLIC_HEADER 8 | include/acl_threadsupport/acl_threadsupport.h 9 | ) 10 | 11 | define_file_basename_for_sources(acl_threadsupport) 12 | 13 | install(TARGETS acl_threadsupport 14 | COMPONENT acl_threadsupport 15 | EXCLUDE_FROM_ALL 16 | ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" 17 | PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/acl_threadsupport" 18 | ) 19 | 20 | add_subdirectory(test) 21 | -------------------------------------------------------------------------------- /lib/acl_threadsupport/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | add_executable(acl_threadsupport_test acl_test.cpp acl_threadsupport_test.cpp) 5 | target_link_libraries(acl_threadsupport_test PRIVATE acl_threadsupport CppUTest) 6 | target_compile_definitions(acl_threadsupport_test PRIVATE 7 | "ACL_TARGET_BIT=${ACL_TARGET_BIT}" 8 | ) 9 | add_test(acl_threadsupport_test acl_threadsupport_test -v) 10 | -------------------------------------------------------------------------------- /lib/acl_threadsupport/test/acl_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #include "CppUTest/CommandLineTestRunner.h" 5 | #include "CppUTest/SimpleString.h" 6 | #include "CppUTest/TestHarness.h" 7 | 8 | #include "acl_test.h" 9 | #include 10 | #include 11 | #include 12 | 13 | int main(int argc, const char **argv) { 14 | return CommandLineTestRunner::RunAllTests(argc, argv); 15 | } 16 | 17 | #ifdef _WIN32 18 | #define snprintf sprintf_s 19 | #endif 20 | 21 | SimpleString StringFrom(uint32_t x) { 22 | char buf[30]; // probably 12 will do 23 | snprintf(&buf[0], sizeof(buf) / sizeof(buf[0]), "%u", x); 24 | const char *start_of_buf = &buf[0]; 25 | return StringFrom(start_of_buf); 26 | } 27 | #if ACL_TARGET_BIT == 32 28 | SimpleString StringFrom(uint64_t x) { 29 | char buf[30]; // probably 12 will do 30 | snprintf(&buf[0], sizeof(buf) / sizeof(buf[0]), "%lu", x); 31 | const char *start_of_buf = &buf[0]; 32 | return StringFrom(start_of_buf); 33 | } 34 | #endif 35 | #ifdef _WIN64 36 | SimpleString StringFrom(intptr_t x) { 37 | char buf[30]; // probably 12 will do 38 | snprintf(&buf[0], sizeof(buf) / sizeof(buf[0]), "%lu", x); 39 | const char *start_of_buf = &buf[0]; 40 | return StringFrom(start_of_buf); 41 | } 42 | #endif 43 | // If ACL_TARGET_BIT is 32, then size_t == cl_ulong == cl_uint, and we've 44 | // already got a body for that. 45 | #if ACL_TARGET_BIT > 32 46 | SimpleString StringFrom(size_t x) { 47 | char buf[30]; // probably 12 will do 48 | snprintf(&buf[0], sizeof(buf) / sizeof(buf[0]), "%zd", x); 49 | const char *start_of_buf = &buf[0]; 50 | return StringFrom(start_of_buf); 51 | } 52 | #endif 53 | -------------------------------------------------------------------------------- /lib/acl_threadsupport/test/acl_test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #include "CppUTest/SimpleString.h" 5 | 6 | #ifdef _WIN32 7 | typedef unsigned __int64 uint64_t; 8 | typedef unsigned __int32 uint32_t; 9 | #else 10 | #include 11 | #endif 12 | 13 | SimpleString StringFrom(uint32_t x); 14 | SimpleString StringFrom(uint64_t x); 15 | SimpleString StringFrom(intptr_t x); 16 | SimpleString StringFrom(size_t x); 17 | -------------------------------------------------------------------------------- /lib/pkg_editor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | add_library(pkg_editor STATIC src/pkg_editor.c) 5 | target_link_libraries(pkg_editor PRIVATE "${CMAKE_DL_LIBS}") # dl for dl_open 6 | target_link_libraries(pkg_editor PRIVATE Elf::Elf) 7 | target_include_directories(pkg_editor PUBLIC include) 8 | set_target_properties(pkg_editor PROPERTIES POSITION_INDEPENDENT_CODE ON) 9 | set_property(TARGET pkg_editor PROPERTY PUBLIC_HEADER 10 | include/pkg_editor/pkg_editor.h 11 | ) 12 | 13 | if(ZLIB_FOUND) 14 | target_compile_definitions(pkg_editor PRIVATE USE_ZLIB) 15 | # Customers need to install zlib on windows when using stand-alone runtime. 16 | if (WIN32) 17 | get_filename_component(WINDOWS_ZLIB_DLL_PATH "${ZLIB_LIBRARY}" DIRECTORY) 18 | set(WINDOWS_ZLIB_DLL_PATH "${WINDOWS_ZLIB_DLL_PATH}/zlib1.dll") 19 | string(REPLACE "/" "\\\\" WINDOWS_ZLIB_DLL_PATH "${WINDOWS_ZLIB_DLL_PATH}") 20 | target_compile_definitions(pkg_editor PRIVATE WINDOWS_ZLIB_PATH="${WINDOWS_ZLIB_DLL_PATH}") 21 | endif() 22 | target_link_libraries(pkg_editor PRIVATE ZLIB::ZLIB) 23 | endif() 24 | 25 | define_file_basename_for_sources(pkg_editor) 26 | 27 | install(TARGETS pkg_editor 28 | COMPONENT pkg_editor 29 | EXCLUDE_FROM_ALL 30 | ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" 31 | PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/pkg_editor" 32 | ) 33 | 34 | add_subdirectory(test) 35 | -------------------------------------------------------------------------------- /lib/pkg_editor/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | add_executable(pkg_editor_test pkg_editor_test.cpp) 5 | target_link_libraries(pkg_editor_test PRIVATE CppUTest pkg_editor) 6 | 7 | # This section can be removed once the minimum required version of GCC has been raised to 9 8 | if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") 9 | target_link_libraries(pkg_editor_test PRIVATE stdc++fs) 10 | endif() 11 | 12 | add_test(pkg_editor_test pkg_editor_test -v) 13 | 14 | if(ZLIB_FOUND) 15 | target_compile_definitions(pkg_editor_test PRIVATE USE_ZLIB) 16 | endif() 17 | 18 | # Copy some (but not all) source files to the binary test directory that 19 | # are used as test inputs. The copying is retriggered as part of the 20 | # build whenever the source files are updated. This could be done in the 21 | # tests once the minimum supported compilers implement std::filesystem. 22 | foreach(path 23 | include/pkg_editor/pkg_editor.h 24 | src/pkg_editor.c 25 | test/pkg_editor_test.cpp 26 | ) 27 | configure_file("../${path}" "${path}" COPYONLY) 28 | endforeach() 29 | -------------------------------------------------------------------------------- /scripts/changelog-link-pr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (C) 2022 Intel Corporation 3 | # SPDX-License-Identifier: BSD-3-Clause 4 | 5 | # Read changelog entries from standard input and print each 6 | # occurrence of a pull-request reference, e.g., [#123] to 7 | # standard output, along with the link to the pull request. 8 | 9 | set -eu -o pipefail 10 | 11 | grep -o '\[#[0-9]\+\]' | sed 's,\[#\([0-9]\+\)\],&: https://github.com/intel/fpga-runtime-for-opencl/pull/\1,' | sort -V 12 | -------------------------------------------------------------------------------- /scripts/clang-format.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (C) 2021 Intel Corporation 3 | # SPDX-License-Identifier: BSD-3-Clause 4 | 5 | set -eu -o pipefail 6 | 7 | find . -regex '.*\.\(c\|cpp\|h\)' | sort | xargs clang-format -i "$@" 8 | -------------------------------------------------------------------------------- /scripts/install_libelf.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | # Install Libelf library by Michael Riepe 5 | # https://web.archive.org/web/20190223180146/http://www.mr511.de/software/english.html 6 | 7 | Param( 8 | [Parameter(Mandatory)]$installdir, 9 | $version="0.8.13", 10 | $builddir="libelf-$version", 11 | $archive="libelf-$version.tar.gz", 12 | $archive_url="https://ftp.netbsd.org/pub/pkgsrc/distfiles/$archive", 13 | $sha256="591a9b4ec81c1f2042a97aa60564e0cb79d041c52faa7416acb38bc95bd2c76d" 14 | ) 15 | 16 | $ErrorActionPreference = "Stop" 17 | 18 | Invoke-WebRequest $archive_url -OutFile $archive 19 | 20 | $download_sha256 = (Get-FileHash $archive -Algorithm SHA256).Hash 21 | if ($download_sha256 -ne $sha256) { 22 | throw "SHA256 $download_sha256 of downloaded file does not match expected SHA256 $sha256" 23 | } 24 | 25 | tar -xzf $archive 26 | 27 | # Patch DEF file to ensure the DLL exports the non-deprecated 28 | # versions of the functions, which are used by pkg_editor. 29 | (Get-Content "$builddir\lib\libelf.def") ` 30 | -replace "elf_getphnum","elf_getphdrnum" ` 31 | -replace "elf_getshnum","elf_getshdrnum" ` 32 | -replace "elf_getshstrndx","elf_getshdrstrndx" ` 33 | | Set-Content "$builddir\lib\libelf.def" 34 | 35 | Push-Location "$builddir\lib" 36 | .\build.bat 37 | Pop-Location 38 | 39 | New-Item "$installdir\include\libelf","$installdir\lib" -ItemType Directory 40 | Copy-Item "$builddir\lib\elf_repl.h","$builddir\lib\libelf.h","$builddir\lib\sys_elf.h" "$installdir\include\libelf" 41 | Copy-Item "$builddir\lib\libelf.lib","$builddir\lib\libelf.dll" "$installdir\lib" 42 | -------------------------------------------------------------------------------- /scripts/install_ninja.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | # Install Ninja build system 5 | # https://ninja-build.org/ 6 | 7 | Param( 8 | [Parameter(Mandatory)]$installdir, 9 | $version="1.10.2", 10 | $archive="ninja-win.zip", 11 | $archive_url="https://github.com/ninja-build/ninja/releases/download/v$version/$archive", 12 | $sha256="bbde850d247d2737c5764c927d1071cbb1f1957dcabda4a130fa8547c12c695f" 13 | ) 14 | 15 | $ErrorActionPreference = "Stop" 16 | 17 | Invoke-WebRequest $archive_url -OutFile $archive 18 | 19 | $download_sha256 = (Get-FileHash $archive -Algorithm SHA256).Hash 20 | if ($download_sha256 -ne $sha256) { 21 | throw "SHA256 $download_sha256 of downloaded file does not match expected SHA256 $sha256" 22 | } 23 | 24 | Expand-Archive $archive $installdir 25 | -------------------------------------------------------------------------------- /scripts/install_zlib.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | # Install zlib compression library 5 | # https://zlib.net/ 6 | 7 | Param( 8 | [Parameter(Mandatory)]$installdir, 9 | $version="1.2.13", 10 | $builddir="zlib-$version", 11 | $archive="zlib-$version.tar.gz", 12 | $archive_url="https://zlib.net/fossils/$archive", 13 | $sha256="b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30" 14 | ) 15 | 16 | $ErrorActionPreference = "Stop" 17 | 18 | Invoke-WebRequest $archive_url -OutFile $archive 19 | 20 | $download_sha256 = (Get-FileHash $archive -Algorithm SHA256).Hash 21 | if ($download_sha256 -ne $sha256) { 22 | throw "SHA256 $download_sha256 of downloaded file does not match expected SHA256 $sha256" 23 | } 24 | 25 | tar -xzf $archive 26 | 27 | Push-Location $builddir 28 | nmake /F win32\Makefile.msc 29 | Pop-Location 30 | 31 | New-Item "$installdir\include","$installdir\lib" -ItemType Directory 32 | Copy-Item "$builddir\zlib.h","$builddir\zconf.h" "$installdir\include" 33 | Copy-Item "$builddir\zdll.lib","$builddir\zlib1.dll" "$installdir\lib" 34 | -------------------------------------------------------------------------------- /security.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | Intel is committed to rapidly addressing security vulnerabilities affecting our customers and providing clear guidance on the solution, impact, severity and mitigation. 3 | 4 | ## Reporting a Vulnerability 5 | Please report any security vulnerabilities in this project [utilizing the guidelines here](https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html). 6 | -------------------------------------------------------------------------------- /src/acl_bsp_io.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | // Internal headers. 5 | #include 6 | #include 7 | 8 | int acl_bsp_io_is_valid(acl_bsp_io *bsp_io) { 9 | acl_assert_locked_or_sig(); 10 | return ((bsp_io) && (bsp_io->read) && (bsp_io->write) && 11 | (bsp_io->get_time_ns)) 12 | ? 1 13 | : 0; 14 | } 15 | -------------------------------------------------------------------------------- /src/acl_shared_aligned_ptr.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | // System headers. 5 | #include 6 | 7 | // Internal headers. 8 | #include 9 | 10 | acl_shared_aligned_ptr::acl_shared_aligned_ptr(const std::size_t size) { 11 | const auto alloc_size = size + ACL_MEM_ALIGN; 12 | if (alloc_size < size) 13 | return; // watch for wraparound! 14 | 15 | m_raw = std::shared_ptr(new char[alloc_size], 16 | std::default_delete()); 17 | if (m_raw == nullptr) 18 | return; 19 | 20 | auto raw_uint = reinterpret_cast(m_raw.get()); 21 | auto offset = raw_uint & (ACL_MEM_ALIGN - 1); 22 | if (offset) 23 | offset = ACL_MEM_ALIGN - offset; 24 | m_aligned_ptr = reinterpret_cast(raw_uint + offset); 25 | m_requested_size = size; 26 | m_size = alloc_size; 27 | } 28 | -------------------------------------------------------------------------------- /src/check_copy_overlap.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef CHECK_COPY_OVERLAP_H 5 | #define CHECK_COPY_OVERLAP_H 6 | 7 | #include 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | // Use internal visibility since this symbol is never called from another 14 | // dynamic shared object, neither directly nor through a function pointer. 15 | #ifdef __GNUC__ 16 | #pragma GCC visibility push(internal) 17 | #endif 18 | 19 | unsigned int check_copy_overlap(const size_t src_origin[], 20 | const size_t dst_origin[], 21 | const size_t region[], const size_t row_pitch, 22 | const size_t slice_pitch); 23 | 24 | #ifdef __GNUC__ 25 | #pragma GCC visibility pop 26 | #endif 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif // CHECK_COPY_OVERLAP_H 33 | -------------------------------------------------------------------------------- /src/unref.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef __unref_h__ 5 | #define __unref_h__ 6 | 7 | #ifndef UNREFERENCED_PARAMETER 8 | #define UNREFERENCED_PARAMETER(p) (void)(p) 9 | #endif 10 | 11 | #endif // __unref_h__ 12 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | add_library(test_acl_test_header INTERFACE) 5 | target_include_directories(test_acl_test_header INTERFACE .) 6 | 7 | add_executable(acl_test 8 | $ 9 | acl_auto_configure_test.cpp 10 | acl_command_queue_test.cpp 11 | acl_context_test.cpp 12 | acl_device_op_test.cpp 13 | acl_device_test.cpp 14 | acl_event_test.cpp 15 | acl_globals_test.cpp 16 | acl_hal_mmd_test.cpp 17 | acl_hal_test.cpp 18 | acl_kernel_test.cpp 19 | acl_mem_test.cpp 20 | acl_platform_test.cpp 21 | acl_profiler_test.cpp 22 | acl_program_test.cpp 23 | acl_sampler_test.cpp 24 | acl_support_test.cpp 25 | acl_svm_test.cpp 26 | acl_test.cpp 27 | acl_thread_test.cpp 28 | acl_usm_test.cpp 29 | acl_mem_device_global_test.cpp 30 | ) 31 | set_target_properties(acl_test PROPERTIES CXX_EXTENSIONS OFF) 32 | target_compile_features(acl_test PRIVATE cxx_std_11) 33 | target_compile_definitions(acl_test PRIVATE 34 | "ACL_TARGET_BIT=${ACL_TARGET_BIT}" 35 | CL_USE_DEPRECATED_OPENCL_1_0_APIS=1 36 | CL_USE_DEPRECATED_OPENCL_1_1_APIS=1 37 | CL_USE_DEPRECATED_OPENCL_1_2_APIS=1 38 | CL_TARGET_OPENCL_VERSION=300 39 | ) 40 | target_include_directories(acl_test PRIVATE 41 | "${CMAKE_BINARY_DIR}/include" 42 | "${CMAKE_SOURCE_DIR}/src" 43 | ) 44 | target_link_libraries(acl_test PRIVATE 45 | acl_headers 46 | acl_check_sys_cmd 47 | acl_hash 48 | acl_threadsupport 49 | CppUTest 50 | pkg_editor 51 | ) 52 | add_test(NAME acl_test COMMAND acl_test -v) 53 | set_property(TEST acl_test PROPERTY ENVIRONMENT 54 | "\ 55 | AOCL_BOARD_PACKAGE_ROOT=${CMAKE_CURRENT_SOURCE_DIR}/board/a10_ref;\ 56 | ACL_TEST_EXAMPLE_BINARY=${CMAKE_CURRENT_SOURCE_DIR}/example_binary\ 57 | " 58 | ) 59 | 60 | add_subdirectory(fake_bsp) 61 | -------------------------------------------------------------------------------- /test/acl_device_op_test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_DEVICE_OP_TEST_H 5 | #define ACL_DEVICE_OP_TEST_H 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | struct acl_device_op_test_ctx_t { 13 | enum { MAX_OPS = 1000 }; 14 | void (*launch_kernel)(void *, acl_device_op_t *); 15 | void (*transfer_buffer)(void *, acl_device_op_t *); 16 | void (*process_printf)(void *, acl_device_op_t *); 17 | void (*program_device)(void *, acl_device_op_t *); 18 | void (*log_update)(void *, acl_device_op_t *, int); 19 | void *sub_user_data; 20 | acl_device_op_t before[MAX_OPS]; 21 | acl_device_op_t after[MAX_OPS]; 22 | int num_ops; 23 | }; 24 | 25 | void acl_dot_push(acl_device_op_test_ctx_t *ctx, acl_device_op_queue_t *doq); 26 | 27 | void acl_dot_launch_kernel(void *, acl_device_op_t *); 28 | void acl_dot_transfer_buffer(void *, acl_device_op_t *); 29 | void acl_dot_process_printf(void *, acl_device_op_t *); 30 | void acl_dot_program_device(void *, acl_device_op_t *); 31 | void acl_dot_log_update(void *, acl_device_op_t *, int); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /test/acl_globals_test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_GLOBALS_TEST_H 5 | #define ACL_GLOBALS_TEST_H 6 | 7 | #include 8 | 9 | const acl_system_def_t *acl_test_get_complex_system_def(); 10 | const acl_system_def_t *acl_test_get_empty_system_def(); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /test/acl_hal_mmd_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifdef _MSC_VER 5 | #pragma warning(push) 6 | #pragma warning(disable : 4100) // unreferenced formal parameter 7 | #endif 8 | #include 9 | #ifdef _MSC_VER 10 | #pragma warning(pop) 11 | #endif 12 | 13 | #include 14 | #include 15 | 16 | #include "acl_test.h" 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | TEST_GROUP(acl_hal_mmd){void setup(){acl_mutex_wrapper.lock(); 23 | acl_hal_test_setup_generic_system(); 24 | this->load(); 25 | } 26 | void teardown() { 27 | this->unload(); 28 | acl_hal_test_teardown_generic_system(); 29 | acl_mutex_wrapper.unlock(); 30 | acl_test_run_standard_teardown_checks(); 31 | } 32 | 33 | void load(void) {} 34 | 35 | void unload(void) {} 36 | 37 | protected: 38 | } 39 | ; 40 | 41 | TEST(acl_hal_mmd, load_library) { 42 | acl_system_def_t sysdef; 43 | acl_mmd_library_names_t _libraries_to_load; 44 | // Making a static array to avoid having to malloc in unit test 45 | const acl_hal_t *test_hal = nullptr; 46 | #ifdef _WIN32 47 | char library_fullpath[MAX_PATH]; 48 | GetFullPathName("fake_bsp/fakegoodbsp.dll", MAX_PATH, library_fullpath, 0); 49 | _libraries_to_load.library_name = library_fullpath; 50 | #else 51 | _libraries_to_load.library_name = "fake_bsp/libfakegoodbsp.so"; 52 | #endif 53 | _libraries_to_load.next = nullptr; 54 | test_hal = acl_mmd_get_system_definition(&sysdef, &_libraries_to_load); 55 | CHECK(test_hal != nullptr); 56 | CHECK_EQUAL(128, sysdef.num_devices); 57 | 58 | #ifdef _WIN32 59 | GetFullPathName("fake_bsp/invalidbsp.dll", MAX_PATH, library_fullpath, 0); 60 | _libraries_to_load.library_name = library_fullpath; 61 | #else 62 | _libraries_to_load.library_name = "fake_bsp/libinvalidbsp.so"; 63 | #endif 64 | _libraries_to_load.next = nullptr; 65 | test_hal = acl_mmd_get_system_definition(&sysdef, &_libraries_to_load); 66 | CHECK(test_hal == nullptr); 67 | 68 | #ifdef _WIN32 69 | GetFullPathName("fake_bsp/missingfuncbsp.dll", MAX_PATH, library_fullpath, 0); 70 | _libraries_to_load.library_name = library_fullpath; 71 | #else 72 | _libraries_to_load.library_name = "fake_bsp/libmissingfuncbsp.so"; 73 | #endif 74 | _libraries_to_load.next = nullptr; 75 | test_hal = acl_mmd_get_system_definition(&sysdef, &_libraries_to_load); 76 | CHECK(test_hal == nullptr); 77 | } 78 | -------------------------------------------------------------------------------- /test/acl_hal_test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_HAL_TEST_H 5 | #define ACL_HAL_TEST_H 6 | 7 | // A simple HAL for testing. 8 | 9 | const acl_hal_t *acl_test_get_simple_hal(void); 10 | 11 | void acltest_hal_teardown(void); 12 | 13 | // Make sure that all these device addresses have host storage representing 14 | // them. And translate them into a host pointer. It's transient though! 15 | void *acltest_translate_device_address(const void *device_ptr, size_t offset); 16 | 17 | void acl_test_hal_set_svm_memory_support(int value); 18 | void acl_test_hal_set_physical_memory_support(bool value); 19 | void acl_test_hal_set_buffer_location_support(bool value); 20 | 21 | extern bool acltest_hal_emulate_device_mem; 22 | 23 | void acltest_call_event_update_callback(cl_event event, int new_status); 24 | void acltest_call_kernel_update_callback(int activation_id, cl_int status); 25 | void acltest_call_printf_buffer_callback(int activation_id, int size, 26 | int stalled); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /test/acl_support_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifdef _MSC_VER 5 | #pragma warning(push) 6 | #pragma warning(disable : 4100) // unreferenced formal parameter 7 | #endif 8 | #include 9 | #ifdef _MSC_VER 10 | #pragma warning(pop) 11 | #endif 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include "acl_test.h" 18 | 19 | #include 20 | #include 21 | #include 22 | #ifndef _WIN32 23 | #include 24 | #endif 25 | 26 | TEST_GROUP(support){void setup(){acl_mutex_wrapper.lock(); 27 | acl_test_setup_generic_system(); 28 | } 29 | void teardown() { 30 | acl_test_teardown_generic_system(); 31 | acl_mutex_wrapper.unlock(); 32 | acl_test_run_standard_teardown_checks(); 33 | } 34 | 35 | std::string myrealpath(const std::string &path) { 36 | auto result = acl_realpath_existing(path); 37 | acl_print_debug_msg("acl_realpath_existing('%s') -> '%s'\n", path.c_str(), 38 | result.c_str()); 39 | 40 | if (result != "") { 41 | #ifndef _WIN32 42 | CHECK_EQUAL('/', result[0]); 43 | #endif 44 | } 45 | return result; 46 | } 47 | } 48 | ; 49 | 50 | TEST(support, make_path_to_dir) { 51 | CHECK_EQUAL(0, acl_make_path_to_dir("")); 52 | CHECK_EQUAL(1, acl_make_path_to_dir("/")); 53 | #ifdef _WIN32 54 | // Console device 55 | CHECK_EQUAL(0, acl_make_path_to_dir("CON")); 56 | #else 57 | // This is a special file on Linux 58 | CHECK_EQUAL(0, acl_make_path_to_dir("/dev/mem")); 59 | CHECK_EQUAL(0, acl_make_path_to_dir("///not-there")); 60 | #endif 61 | CHECK_EQUAL(1, acl_make_path_to_dir(".")); 62 | 63 | CHECK_EQUAL(0, system("rm -rf ./.not-there")); 64 | CHECK_EQUAL(1, acl_make_path_to_dir("./.not-there")); 65 | CHECK_EQUAL(1, acl_make_path_to_dir("./.not-there/or/there")); // deep 66 | 67 | CHECK_EQUAL(1, acl_make_path_to_dir("./.not-there/or/there///")); 68 | CHECK_EQUAL(1, acl_make_path_to_dir("./.not-there/either////here")); 69 | 70 | #ifdef _WIN32 71 | CHECK_EQUAL(1, acl_make_path_to_dir("c:\\")); 72 | #else 73 | CHECK_EQUAL(1, acl_make_path_to_dir("///")); 74 | #endif 75 | 76 | // An existing plain file. Should fail to make dir. 77 | CHECK_EQUAL(0, system("rm -rf .is-here")); 78 | CHECK_EQUAL(0, system("touch .is-here")); 79 | CHECK_EQUAL(0, acl_make_path_to_dir(".is-here")); 80 | 81 | // Try an example of a path without a directory component in its name at 82 | // all. 83 | CHECK_EQUAL(0, system("rm -rf .not-here")); 84 | CHECK_EQUAL(1, acl_make_path_to_dir(".not-here")); 85 | } 86 | 87 | TEST(support, realpath) { 88 | 89 | CHECK(myrealpath(".") != ""); 90 | CHECK(myrealpath("..") != ""); 91 | 92 | CHECK_EQUAL(0, system("touch realpath_test.txt")); 93 | std::string this_file = "realpath_test.txt"; 94 | auto rp = myrealpath(this_file); 95 | CHECK(this_file == rp.substr(rp.length() - this_file.length())); 96 | 97 | #ifdef __linux__ 98 | // And the something before ends in a pathsep. 99 | CHECK_EQUAL('/', rp[rp.length() - this_file.length() - 1]); 100 | #endif 101 | } 102 | 103 | TEST(support, glob) { 104 | CHECK_EQUAL(0, system("rm -rf *.globtest")); 105 | 106 | // No hit 107 | auto result = acl_glob("*.globtest"); 108 | CHECK(result.empty()); 109 | 110 | // simple case. One 111 | CHECK_EQUAL(0, system("touch firstone.globtest")); 112 | result = acl_glob("*.globtest"); 113 | CHECK_EQUAL(1, result.size()); 114 | CHECK("firstone.globtest" == result[0]); 115 | 116 | // Multiple 117 | CHECK_EQUAL(0, system("touch another.globtest")); 118 | 119 | result = acl_glob("*.globtest"); 120 | CHECK_EQUAL(2, result.size()); 121 | CHECK((result[0] == "firstone.globtest" && result[1] == "another.globtest") || 122 | (result[0] == "another.globtest" && result[1] == "firstone.globtest")); 123 | 124 | CHECK_EQUAL(0, system("rm -rf *.globtest")); 125 | } 126 | -------------------------------------------------------------------------------- /test/acl_test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2021 Intel Corporation 2 | // SPDX-License-Identifier: BSD-3-Clause 3 | 4 | #ifndef ACL_TEST_H 5 | #define ACL_TEST_H 6 | 7 | #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) 8 | 9 | #include 10 | 11 | #include 12 | 13 | #include 14 | 15 | #include 16 | 17 | // Use the default board for the SDK, but with less memory for unit test 18 | // purposes. Must also update the table of hashes in acl_program_test.cpp 19 | #if ACDS_PRO == 0 20 | #define ACLTEST_DEFAULT_BOARD "s5_net_small" 21 | #else 22 | #define ACLTEST_DEFAULT_BOARD "a10_ref_small" 23 | #endif 24 | 25 | // Default setup and teardown. 26 | void acl_test_setup_generic_system(); 27 | void acl_test_setup_empty_system(); 28 | void acl_test_setup_sample_default_board_system(void); 29 | void acl_test_teardown_generic_system(void); 30 | void acl_test_teardown_system(void); 31 | void acl_test_teardown_sample_default_board_system(void); 32 | void acl_hal_test_setup_generic_system(void); 33 | void acl_hal_test_teardown_generic_system(void); 34 | void acl_test_run_standard_teardown_checks(); 35 | 36 | void acl_test_unsetenv(const char *var); 37 | void acl_test_setenv(const char *var, const char *value); 38 | 39 | cl_context_properties *acl_test_context_prop_preloaded_binary_only(void); 40 | 41 | const unsigned char *acl_test_get_example_binary(size_t *binary_len); 42 | 43 | SimpleString StringFrom(cl_uint x); 44 | SimpleString StringFrom(cl_ulong x); 45 | SimpleString StringFrom(size_t x); 46 | 47 | #ifdef _WIN32 48 | SimpleString StringFrom(intptr_t x); 49 | #endif 50 | 51 | // Context error notify callback function. 52 | void CL_CALLBACK acl_test_notify_print(const char *errinfo, 53 | const void *private_info, size_t cb, 54 | void *user_data); 55 | 56 | #define ACL_LOCKED(...) \ 57 | do { \ 58 | std::scoped_lock lock{acl_mutex_wrapper}; \ 59 | { __VA_ARGS__; } \ 60 | } while (0) 61 | 62 | /* CAUTION. These are only used in self-tests. 63 | * The runtime does not use these constants any more. 64 | */ 65 | #define ACL_MAX_EVENT (1024 * 16) 66 | #define ACL_MAX_COMMAND \ 67 | ACL_MAX_EVENT /* each event refers to a command. if same number of them, \ 68 | then there is less worry about running out of commands when \ 69 | creating an event */ 70 | 71 | typedef struct mem_data_s mem_data_t; 72 | 73 | typedef struct mem_data_s { 74 | int mmd_interface; 75 | size_t offset; 76 | size_t size; 77 | void *data; 78 | mem_data_t *next; 79 | } mem_data_t; 80 | typedef struct { 81 | cl_bool is_active; 82 | mem_data_t *mem_data; 83 | aocl_mmd_interrupt_handler_fn kernel_interrupt; 84 | void *interrupt_user_data; 85 | aocl_mmd_status_handler_fn kernel_status; 86 | void *status_user_data; 87 | } acl_hal_device_test; 88 | 89 | // Default mem_org address. 90 | // Runtime is now using one loaded from autodiscovery, 91 | // rather than hard coded value. 92 | // For tests, autodiscovery will still have the default value. 93 | #define OFFSET_MEM_ORG ((dev_addr_t)0x0018) 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /test/board/a10_ref/README.md: -------------------------------------------------------------------------------- 1 | `a10_ref_small` is a tiny board package for testing. 2 | It's the same as the default board but with 2 banks of 128MB each. 3 | This is much better for unit testing, so we don't take up gobs of memory. 4 | -------------------------------------------------------------------------------- /test/board/a10_ref/board_env.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | %b/linux64/lib/libaltera_a10_ref_mmd.so 11 | -L%b/linux64/lib 12 | -laltera_a10_ref_mmd 13 | %b/linux64/libexec 14 | 15 | 16 | 17 | %b/windows64/bin/altera_a10_ref_mmd.dll 18 | /libpath:%b/windows64/lib 19 | altera_a10_ref_mmd.lib 20 | %b/windows64/libexec 21 | 22 | 23 | -------------------------------------------------------------------------------- /test/board/a10_ref/hardware/a10_ref_small/board_spec.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /test/example_binary/README.md: -------------------------------------------------------------------------------- 1 | # Precompiled Binaries for Runtime Unit Tests 2 | 3 | This directory contains precompiled binaries that the runtime unit tests could use. 4 | 5 | When the environment variable `ACL_TEST_EXAMPLE_BINARY` is set, precompiled binaries 6 | will be used for the unit tests, instead of compiling with aoc in-time. The environment 7 | variable is set to this directory by default by the unit test CMake configuration. 8 | 9 | ## Unit Tests Using AOC compiler 10 | 11 | During setup, the runtime loads an example binary that may be obtained and used by 12 | any runtime unit tests. The loading is done in the function `l_load_example_binary` 13 | of acl_test.cpp, and the loaded binary can be obtained by calling the function 14 | `acl_test_get_example_binary`. 15 | 16 | Other than this, the program `from_source` test group contains two tests that either 17 | requires the aoc compiler, or the precompiled binaries to be present: 18 | 19 | - `make_prog_dir_and_build_command` 20 | - `online_mode` 21 | 22 | ## Overriding the Binaries to be Used 23 | 24 | To use precompiled binaries contained in another directory, set `ACL_TEST_EXAMPLE_BINARY` 25 | to the root of that directory, and make sure there is a `linux` subdirectory for linux 26 | precompiled binaries and a `windows` subdirectory for windows precompile binaries. 27 | 28 | ## Updating the Binaries 29 | 30 | In case binaries have to be updated, make sure the aoc compiler is available, and 31 | run the compile scripts contained in each of the corresponding OS subdirectories: 32 | 33 | ``` 34 | # On Linux 35 | sh linux/compile_aocr.sh 36 | # On Windows 37 | windows\compile_aocr.sh 38 | ``` 39 | -------------------------------------------------------------------------------- /test/example_binary/linux/compile_aocr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (C) 2021 Intel Corporation 3 | # SPDX-License-Identifier: BSD-3-Clause 4 | 5 | set -eux -o pipefail 6 | 7 | if ! command -v aoc &> /dev/null 8 | then 9 | echo "Error: aoc could not be found on PATH" 10 | exit 1 11 | fi 12 | 13 | scripthome=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) 14 | AOCL_BOARD_PACKAGE_ROOT=$(readlink -f "$scripthome/../../board/a10_ref") 15 | export AOCL_BOARD_PACKAGE_ROOT 16 | 17 | # First compile example.cl 18 | kernel='example' 19 | board='a10_ref_small' 20 | compile_arg='-cl-kernel-arg-info' 21 | compute_hash='f3effd06c681436a828f7e11c6c1b037807ddba0' 22 | src=$(readlink -f "$scripthome/../src/$kernel.cl") 23 | dest="$scripthome/$kernel.aocr" 24 | 25 | aoc -rtl -tidy -board="$board" -hash="$compute_hash" "$src" "$compile_arg" -o "$dest" 26 | 27 | # Then compile foo.cl 28 | kernel='foo' 29 | board='a10_ref_small' 30 | compile_arg='' 31 | compute_hash='7128ac1c937694f5b54a12229f19e4ca3a494c16' 32 | src=$(readlink -f "$scripthome/../src/$kernel.cl") 33 | dest="$scripthome/$kernel.aocr" 34 | 35 | aoc -rtl -tidy -board="$board" -hash="$compute_hash" "$src" "$compile_arg" -o "$dest" 36 | 37 | # Clean up 38 | rm -rf "$scripthome"/*.temp "$scripthome"/*.bc 39 | -------------------------------------------------------------------------------- /test/example_binary/linux/example.aocr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/fpga-runtime-for-opencl/32a36fe51d3bab2c7caff98e744e7ee3dd55da7d/test/example_binary/linux/example.aocr -------------------------------------------------------------------------------- /test/example_binary/linux/foo.aocr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/fpga-runtime-for-opencl/32a36fe51d3bab2c7caff98e744e7ee3dd55da7d/test/example_binary/linux/foo.aocr -------------------------------------------------------------------------------- /test/example_binary/src/example.cl: -------------------------------------------------------------------------------- 1 | kernel void vecaccum(global int*A, global int*B) { 2 | size_t gid = get_global_id(0); 3 | A[gid] += B[gid]; 4 | }; 5 | kernel void vecsum(global int*A, constant int*B, constant int*C) { 6 | size_t gid = get_global_id(0); 7 | A[gid] = B[gid] + C[gid]; 8 | }; 9 | kernel void printit(global int*A) { 10 | printf("Hello world! %d\n", A[0]); 11 | }; 12 | -------------------------------------------------------------------------------- /test/example_binary/src/foo.cl: -------------------------------------------------------------------------------- 1 | kernel void foo(){} 2 | -------------------------------------------------------------------------------- /test/example_binary/windows/compile_aocr.cmd: -------------------------------------------------------------------------------- 1 | REM Copyright (C) 2021 Intel Corporation 2 | REM SPDX-License-Identifier: BSD-3-Clause 3 | 4 | WHERE /q aoc 5 | IF ERRORLEVEL 1 ( 6 | ECHO Error: aoc could not be found on PATH 7 | EXIT /B 8 | ) 9 | 10 | SET scripthome=%~dp0 11 | SET OLD_BOARD_PACKAGE_ROOT=%AOCL_BOARD_PACKAGE_ROOT% 12 | SET AOCL_BOARD_PACKAGE_ROOT=%scripthome%/../../board/a10_ref 13 | 14 | REM First compile example.cl 15 | SET kernel=example 16 | SET board=a10_ref_small 17 | SET compile_arg=-cl-kernel-arg-info 18 | SET compute_hash=f3effd06c681436a828f7e11c6c1b037807ddba0 19 | SET src=%scripthome%\..\src\%kernel%.cl 20 | SET dest=%scripthome%\%kernel%.aocr 21 | 22 | aoc -rtl -tidy -board=%board% -hash=%compute_hash% %src% %compile_arg% -o %dest% 23 | 24 | REM Then compile foo.cl 25 | SET kernel=foo 26 | SET board=a10_ref_small 27 | SET compile_arg= 28 | SET compute_hash=7128ac1c937694f5b54a12229f19e4ca3a494c16 29 | SET src=%scripthome%/../src/%kernel%.cl 30 | SET dest=%scripthome%/%kernel%.aocr 31 | 32 | aoc -rtl -tidy -board=%board% -hash=%compute_hash% %src% %compile_arg% -o %dest% 33 | 34 | REM Clean up 35 | DEL /f %scripthome%\*.temp %scripthome%\*.bc 36 | 37 | REM Unset variables 38 | SET AOCL_BOARD_PACKAGE_ROOT=%OLD_BOARD_PACKAGE_ROOT% 39 | SET scripthome= 40 | SET kernel= 41 | SET board= 42 | SET compile_arg= 43 | SET compute_hash= 44 | SET src= 45 | SET dest= 46 | -------------------------------------------------------------------------------- /test/example_binary/windows/example.aocr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/fpga-runtime-for-opencl/32a36fe51d3bab2c7caff98e744e7ee3dd55da7d/test/example_binary/windows/example.aocr -------------------------------------------------------------------------------- /test/example_binary/windows/foo.aocr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/fpga-runtime-for-opencl/32a36fe51d3bab2c7caff98e744e7ee3dd55da7d/test/example_binary/windows/foo.aocr -------------------------------------------------------------------------------- /test/fake_bsp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Intel Corporation 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | add_library(fakegoodbsp SHARED fakegoodbsp.cpp) 5 | target_include_directories(fakegoodbsp PRIVATE "${CMAKE_SOURCE_DIR}/src") 6 | target_link_libraries(fakegoodbsp PRIVATE acl_headers CppUTest test_acl_test_header) 7 | target_compile_definitions(fakegoodbsp PRIVATE 8 | CL_TARGET_OPENCL_VERSION=300 9 | ) 10 | if(WIN32) 11 | target_compile_definitions(fakegoodbsp PRIVATE AOCL_MMD_CALL=__declspec\(dllexport\)) 12 | endif() 13 | 14 | add_library(missingfuncbsp SHARED missingfuncbsp.cpp) 15 | target_include_directories(missingfuncbsp PRIVATE "${CMAKE_SOURCE_DIR}/src") 16 | target_link_libraries(missingfuncbsp PRIVATE acl_headers CppUTest test_acl_test_header) 17 | target_compile_definitions(missingfuncbsp PRIVATE 18 | CL_TARGET_OPENCL_VERSION=300 19 | ) 20 | if(WIN32) 21 | target_compile_definitions(missingfuncbsp PRIVATE AOCL_MMD_CALL=__declspec\(dllexport\)) 22 | endif() 23 | --------------------------------------------------------------------------------