### Installation Rule Source: https://github.com/memryx/mxaccl/blob/release/tools/acclBench/CMakeLists.txt Installs the built executable to the specified binary directory. ```cmake install(TARGETS ${app_name} DESTINATION ${CMAKE_INSTALL_BINDIR}) ``` -------------------------------- ### Run Example Script Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/pymodule/README.md Executes a Python example script, such as 'cartoonizer.py', with the '--show' flag to display results. ```bash cd examples python cartoonizer.py --show ``` -------------------------------- ### Install Library and Headers Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/CMakeLists.txt Installs the built dynamic library and its public headers to the appropriate locations based on CMAKE_INSTALL_LIBDIR and CMAKE_INSTALL_INCLUDEDIR. ```cmake install(TARGETS ${MXACCL_DYNAMIC} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) install(DIRECTORY ${MX_API_DIR}/include/memx/ DESTINATION include/memx) ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/pymodule/CMakeLists.txt Initializes CMake, sets the project name, enables verbose Makefiles, and defines the C++ standard. ```cmake cmake_minimum_required(VERSION 3.14) project(mxapi) set(CMAKE_VERBOSE_MAKEFILE ON) set(CMAKE_CXX_STANDARD 17) ``` -------------------------------- ### Activate Virtual Environment and Install Dependencies Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/pymodule/README.md Activates a Python virtual environment and installs necessary packages including the memryx package, numpy, and pytest. ```bash python3 -m venv ~/mx . ~/mx/bin/activate pip install --upgrade pip wheel pip install --extra-index-url https://developer.memryx.com/pip memryx pip install numpy==1.26.4 pip install pytest==8.2.2 ``` -------------------------------- ### Basic CMake Configuration Source: https://github.com/memryx/mxaccl/blob/release/tools/acclBench/CMakeLists.txt Sets the minimum CMake version, gets the application name from the directory, and sets the C++ standard to 17. ```cmake cmake_minimum_required(VERSION 3.10) get_filename_component(app_name ${CMAKE_CURRENT_SOURCE_DIR} NAME) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) ``` -------------------------------- ### Import mxapi Modules Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/pymodule/README.md Demonstrates how to import the mxapi module, showing both the version installed via pip and the locally built version for testing. ```python # Using the memryx package installed via pip: from memryx import mxapi # Using the locally built MX_API Python module for testing: import mxapi ``` -------------------------------- ### Select Tests by Class Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/pymodule/README.md Runs all tests within a specific test class, for example, 'TestAccl'. ```bash pytest test_accl.py::TestAccl ``` -------------------------------- ### Build Python Bindings for MxAccl Source: https://github.com/memryx/mxaccl/blob/release/README.md Build the Python bindings for MxAccl. This requires activating a Python virtual environment with necessary dependencies like numpy installed. ```bash # activate your Python venv with numpy, etc. installed cd ../mx_accl/pymodule mkdir build && cd build cmake .. make -j$(nproc) ``` -------------------------------- ### Get NumPy Include Directory Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/pymodule/CMakeLists.txt Executes a Python command to find and retrieve the include directory for the NumPy library in the current Python environment. ```cmake # find the path to the site-packages/numpy/core/include/ directory for the currently # active Python environment, and add that to the target_include_directories execute_process( COMMAND python3 -c "import numpy; print(numpy.get_include())" OUTPUT_VARIABLE PYTHON_NUMPY_INCLUDE_DIR OUTPUT_STRIP_TRAILING_WHITESPACE ) ``` -------------------------------- ### Set Compile Options and Include Directories Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/CMakeLists.txt Configures compile-time options and private include directories for the dynamic library. Includes directories from MX API, Asio, and Spdlog. ```cmake target_compile_options(${MXACCL_DYNAMIC} PRIVATE -Werror) target_include_directories(${MXACCL_DYNAMIC} PRIVATE ${MX_API_DIR}/mx_accl/include) target_include_directories(${MXACCL_DYNAMIC} PRIVATE ${MX_API_HOME_DIR}/extern/asio) target_include_directories(${MXACCL_DYNAMIC} PRIVATE ${MX_API_HOME_DIR}/extern/spdlog) ``` -------------------------------- ### Run acclBench for Model Performance Source: https://github.com/memryx/mxaccl/blob/release/README.md Benchmark a DFP model file using the acclBench tool. This command measures inference performance by running a specified number of frames. ```bash acclBench -d mobilenet.dfp -f 1000 ``` -------------------------------- ### Build MxAccl Library Source: https://github.com/memryx/mxaccl/blob/release/README.md Build the MxAccl library using CMake and make. Ensure you are in the build directory after cloning the repository. ```bash mkdir build && cd build cmake .. make -j$(nproc) ``` -------------------------------- ### Configure cpuinfo Library Settings Source: https://github.com/memryx/mxaccl/blob/release/CMakeLists.txt Sets the build type for the cpuinfo library and its runtime. Also configures the minimum logging level for cpuinfo. ```cmake SET(CPUINFO_LIBRARY_TYPE "static" CACHE STRING "Type of cpuinfo library to build (static or shared)") SET(CPUINFO_RUNTIME_TYPE "static" CACHE STRING "Type of runtime library (shared, static, or default) to use") SET(CPUINFO_LOG_LEVEL "fatal" CACHE STRING "Minimum logging level (info with lower severity will be ignored)") ``` -------------------------------- ### Run Basic Tests Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/pymodule/README.md Executes basic tests using pytest. Navigate to the 'tests' directory and run 'pytest test_accl.py'. ```bash cd tests pytest test_accl.py ``` -------------------------------- ### Include Directories and Source Files Source: https://github.com/memryx/mxaccl/blob/release/tools/acclBench/CMakeLists.txt Includes the necessary header directory and finds all C/C++ source files in the current directory. ```cmake include_directories(${MX_API_DIR}/include) file(GLOB local_src "*.c" "*.cpp" ) ``` -------------------------------- ### Default MX_API_HOME_DIR if not set Source: https://github.com/memryx/mxaccl/blob/release/mxa_manager/CMakeLists.txt Sets the MX_API_HOME_DIR to the parent directory if it's not defined externally. Logs the default path. ```cmake if (NOT DEFINED MX_API_HOME_DIR) set(MX_API_HOME_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..") message(STATUS "MX_API_HOME_DIR not defined: defaulting to ${MX_API_HOME_DIR}") endif() ``` -------------------------------- ### Target Include Directories Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/pymodule/CMakeLists.txt Specifies the include directories for the 'mxapi' target, including NumPy, spdlog, and local headers. ```cmake # Include directories target_include_directories(mxapi PRIVATE ${PYTHON_NUMPY_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../../extern/spdlog ${CMAKE_CURRENT_SOURCE_DIR}/../include) ``` -------------------------------- ### Enable/Disable Build Options Source: https://github.com/memryx/mxaccl/blob/release/CMakeLists.txt Configures various build options for the project, including command-line tools, unit tests, mock tests, benchmarks, and pkg-config manifests. ```cmake OPTION(CPUINFO_BUILD_TOOLS "Build command-line tools" OFF) OPTION(CPUINFO_BUILD_UNIT_TESTS "Build cpuinfo unit tests" OFF) OPTION(CPUINFO_BUILD_MOCK_TESTS "Build cpuinfo mock tests" OFF) OPTION(CPUINFO_BUILD_BENCHMARKS "Build cpuinfo micro-benchmarks" OFF) OPTION(CPUINFO_BUILD_PKG_CONFIG "Build pkg-config manifest" OFF) ``` -------------------------------- ### Configure System Library Usage Source: https://github.com/memryx/mxaccl/blob/release/CMakeLists.txt Determines whether to use system-provided libraries instead of downloading and building them internally. This applies to general libraries, Google Benchmark, and Google Test. ```cmake OPTION(USE_SYSTEM_LIBS "Use system libraries instead of downloading and building them" OFF) OPTION(USE_SYSTEM_GOOGLEBENCHMARK "Use system Google Benchmark library instead of downloading and building it" OFF) OPTION(USE_SYSTEM_GOOGLETEST "Use system Google Test library instead of downloading and building it" OFF) ``` -------------------------------- ### Select Specific Test Case Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/pymodule/README.md Executes a single, specific test case, such as 'test_basic' within the 'TestAccl' class. ```bash pytest test_accl.py::TestAccl::test_basic ``` -------------------------------- ### Default MX_API_DIR if not set Source: https://github.com/memryx/mxaccl/blob/release/mxa_manager/CMakeLists.txt Sets the MX_API_DIR to the parent directory if it's not defined externally. Logs the default path. ```cmake if (NOT DEFINED MX_API_DIR) set(MX_API_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..") message(STATUS "MX_API_DIR not defined: defaulting to ${MX_API_DIR}") endif() ``` -------------------------------- ### Link Libraries on Windows Source: https://github.com/memryx/mxaccl/blob/release/mxa_manager/CMakeLists.txt Links necessary libraries for the mxa_manager executable on Windows, including ws2_32, advapi32, and found dynamic libraries. ```cmake target_link_libraries(mxa_manager PRIVATE ws2_32 advapi32 ${MXACCL_DYNAMIC} ${UDRIVER_LIB} ) ``` -------------------------------- ### Build MX_API pymodule Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/pymodule/README.md Builds the MX_API Python module from source. Navigate to the pymodule directory and use CMake and Make for the build process. ```bash cd MX_API/mx_accl/pymodule mkdir build && cd build cmake .. make -j$(nproc) ``` -------------------------------- ### Run Verbose Tests with Debug Logging Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/pymodule/README.md Runs tests with verbose output and enables debug-level logging to the console. Useful for detailed troubleshooting. ```bash pytest test_accl.py -s -x -v -o log_cli=true --log-cli-level=DEBUG ``` -------------------------------- ### Find MXACCL Dynamic Library on Windows Source: https://github.com/memryx/mxaccl/blob/release/mxa_manager/CMakeLists.txt Locates the memx-accl dynamic library in a specific path on Windows. Fails if not found. ```cmake find_library(MXACCL_DYNAMIC NAMES memx-accl PATHS "C:/Program Files/MemryX/lib" NO_DEFAULT_PATH ) if (NOT MXACCL_DYNAMIC) message(FATAL_ERROR "Cannot find memx-accl.lib") endif() ``` -------------------------------- ### Link Libraries on Linux Source: https://github.com/memryx/mxaccl/blob/release/mxa_manager/CMakeLists.txt Links necessary libraries for the mxa_manager executable on Linux. ```cmake target_link_libraries(mxa_manager PRIVATE ${MXACCL_DYNAMIC} memx cpuinfo ) ``` -------------------------------- ### Register Windows Service and Event Source Source: https://github.com/memryx/mxaccl/blob/release/mxa_manager/CMakeLists.txt Custom target to register the mxa_manager service and its event source in the Windows registry. Requires administrator privileges. ```cmake if (WIN32) set(SVC_NAME "MxaManagerSvc") set(SVC_EXE_PATH "$") set(EVENT_SOURCE_KEY "HKLM\SYSTEM\CurrentControlSet\Services\EventLog\Application\${SVC_NAME}") # Target to register the service AND its event source in the registry add_custom_target(register_service # Create the service COMMAND sc.exe create ${SVC_NAME} binPath= "\"${SVC_EXE_PATH}\"" start= auto # Add the registry key for the event source COMMAND reg.exe add "${EVENT_SOURCE_KEY}" /v EventMessageFile /t REG_SZ /d "${SVC_EXE_PATH}" /f # Add the supported event types value COMMAND reg.exe add "${EVENT_SOURCE_KEY}" /v TypesSupported /t REG_DWORD /d 7 /f COMMENT "Registering Windows service '${SVC_NAME}' and its Event Source." VERBATIM ) # Target to unregister the service AND remove its event source from the registry add_custom_target(unregister_service # Stop the service if it's running (ignore errors if it's not) COMMAND sc.exe stop ${SVC_NAME} # Delete the service COMMAND sc.exe delete ${SVC_NAME} # Delete the registry key for the event source COMMAND reg.exe delete "${EVENT_SOURCE_KEY}" /f COMMENT "Unregistering Windows service '${SVC_NAME}' and its Event Source." VERBATIM ) # Target to start the service add_custom_target(start_service COMMAND sc.exe start ${SVC_NAME} COMMENT "Starting Windows service '${SVC_NAME}'" VERBATIM ) endif() ``` -------------------------------- ### Add External Subdirectory Source: https://github.com/memryx/mxaccl/blob/release/CMakeLists.txt Includes the external cpuinfo library as a subdirectory in the build process. ```cmake add_subdirectory(extern/cpuinfo) ``` -------------------------------- ### Set Include Directories Source: https://github.com/memryx/mxaccl/blob/release/mxa_manager/CMakeLists.txt Adds common include directories for the mxa_manager target. ```cmake target_include_directories(mxa_manager PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include ${MX_API_DIR}/include ${MX_API_DIR}/mx_accl/include ${MX_API_HOME_DIR}/extern/spdlog ${MX_API_HOME_DIR}/extern/asio ${MX_API_HOME_DIR}/extern/cpuinfo/include ) ``` -------------------------------- ### Define and Build Dynamic Library Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/CMakeLists.txt Defines the dynamic library for mx_accl, specifying source files and linking against other libraries. Sets the SOVERSION for the library. ```cmake include_directories("${MX_API_DIR}/include/") file(GLOB local_src src/*.cpp src/utils/*.cpp) add_library(${MXACCL_DYNAMIC} SHARED ${local_src}) target_link_libraries(${MXACCL_DYNAMIC} memx pthread dl cpuinfo) set_target_properties(${MXACCL_DYNAMIC} PROPERTIES SOVERSION 2) ``` -------------------------------- ### Executable Definition and Linking Source: https://github.com/memryx/mxaccl/blob/release/tools/acclBench/CMakeLists.txt Adds an executable target using the found source files and links it against the 'mx_accl' library. ```cmake add_executable(${app_name} ${local_src}) target_link_libraries(${app_name} mx_accl ) ``` -------------------------------- ### Select Tests by Expression Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/pymodule/README.md Runs tests that match a given expression, useful for selecting tests across different classes that share a naming pattern. ```bash pytest test_accl.py -k "test_basic" ``` -------------------------------- ### Glob Source Files Source: https://github.com/memryx/mxaccl/blob/release/mxa_manager/CMakeLists.txt Collects all .cpp files from the src directory recursively. ```cmake file(GLOB_RECURSE mgr_src_files src/*.cpp) ``` -------------------------------- ### Add Pybind11 Python Module Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/pymodule/CMakeLists.txt Creates a Python extension module named 'mxapi' using Pybind11 and the specified binding file. ```cmake # This will automatically name the output module "mxapi..so" pybind11_add_module(mxapi bindings.cpp) ``` -------------------------------- ### Create Symlink for Python Extension Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/pymodule/README.md Creates a symbolic link to the built Python extension module. Ensure the Python version in the link path (e.g., '310') matches your environment. ```bash cd pymodule/examples # or cd pymodule/tests # Link the built Python extension and the memryx binary. # The "310" substring reflects your Python version (e.g., 3.10). # Update it accordingly (e.g., use "311" for Python 3.11). # # Example: # ln -sv ../build/mxapi.cpython--x86_64-linux-gnu.so ln -sv ../build/mxapi.cpython-310-x86_64-linux-gnu.so ``` -------------------------------- ### Clone MxAccl Repository Source: https://github.com/memryx/mxaccl/blob/release/README.md Clone the MxAccl source code repository from GitHub. This is the first step for building from source. ```bash git clone https://github.com/memryx/MxAccl.git ``` -------------------------------- ### Add Pybind11 Subdirectory Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/pymodule/CMakeLists.txt Includes the Pybind11 library by adding its directory as a subdirectory. Assumes Pybind11 is cloned locally. ```cmake add_subdirectory(pybind11) # Clone from https://github.com/pybind/pybind11 ``` -------------------------------- ### Advanced Pytest Options for Test Execution Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/pymodule/README.md Demonstrates advanced pytest flags for detailed test execution and debugging, including local mode execution. ```bash pytest test_accl.py -s -x -v -o log_cli=true --log-cli-level=DEBUG --local ``` -------------------------------- ### Windows Executable and Compile Definitions Source: https://github.com/memryx/mxaccl/blob/release/mxa_manager/CMakeLists.txt Defines the mxa_manager executable for Windows, including main_win.cpp and source files. Sets platform-specific compile definitions. ```cmake add_executable(mxa_manager main_win.cpp ${mgr_src_files} ) target_compile_definitions(mxa_manager PRIVATE PLATFORM_WINDOWS WIN32_LEAN_AND_MEAN ) ``` -------------------------------- ### Set C++ Standard Source: https://github.com/memryx/mxaccl/blob/release/mxa_manager/CMakeLists.txt Configures the C++ standard to C++17 and ensures it's required. ```cmake set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) ``` -------------------------------- ### Release Build Flags for x86 Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/pymodule/CMakeLists.txt Applies common, x86 base, and AVX2 flags for release builds on x86 architectures. ```cmake set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_COMMON_CFLAGS} ${CMAKE_X86_FLAGS_BASE} ${CMAKE_X86_FLAGS_AVX2}" ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_COMMON_CFLAGS} ${CMAKE_X86_FLAGS_BASE} ${CMAKE_X86_FLAGS_AVX2}" ) ``` -------------------------------- ### Set Minimum CMake Version and Project Name Source: https://github.com/memryx/mxaccl/blob/release/mxa_manager/CMakeLists.txt Specifies the minimum required CMake version and defines the project name. ```cmake cmake_minimum_required(VERSION 3.15) project(mxa_manager) ``` -------------------------------- ### Run Tests in Local Mode Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/pymodule/README.md Executes tests specifically in local mode. If this flag is not specified, tests run in shared mode. ```bash pytest test_accl.py --local ``` -------------------------------- ### Linux Executable and Compile Definitions Source: https://github.com/memryx/mxaccl/blob/release/mxa_manager/CMakeLists.txt Defines the mxa_manager executable for Linux, including main_linux.cpp and source files. Sets PLATFORM_LINUX compile definition. ```cmake else() add_executable(mxa_manager main_linux.cpp ${mgr_src_files} ) target_compile_definitions(mxa_manager PRIVATE PLATFORM_LINUX) ``` -------------------------------- ### Target Link Libraries Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/pymodule/CMakeLists.txt Links the 'mxapi' target against the 'mx_accl' library. ```cmake target_link_libraries(mxapi PRIVATE mx_accl) ``` -------------------------------- ### Collect Manager Sources and Common Includes Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/CMakeLists.txt Collects source files for the manager and defines common include directories used across test targets. ```cmake # Collect manager sources once for use in both test targets file(GLOB MANAGER_SRCS "${MX_API_HOME_DIR}/mxa_manager/src/*.cpp") # Common include directories used by all tests set(COMMON_INCLUDES ${MX_API_HOME_DIR}/mxa_manager/include ${MX_API_HOME_DIR}/extern/asio ${MX_API_HOME_DIR}/extern/spdlog ) ``` -------------------------------- ### Release Build Flags for RISC-V 64 Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/pymodule/CMakeLists.txt Applies common flags and RISC-V GC ZBA ZBB ZBS extensions for release builds on RISC-V 64 architectures. ```cmake set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_COMMON_CFLAGS} -march=rv64gc_zba_zbb_zbs" ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_COMMON_CFLAGS} -march=rv64gc_zba_zbb_zbs" ) ``` -------------------------------- ### Find and Add Subdirectories in CMake Source: https://github.com/memryx/mxaccl/blob/release/tools/CMakeLists.txt This snippet finds all subdirectories matching a pattern and conditionally adds them as subdirectories to the build if they contain a CMakeLists.txt file. Use this to manage modular components of your project. ```cmake SUBDIRLIST(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR} "*") FOREACH(subdir ${SUBDIRS}) if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/CMakeLists.txt) ADD_SUBDIRECTORY(${subdir}) endif() ENDFOREACH() ``` -------------------------------- ### Release Build Flags for RISC-V 64 Architecture Source: https://github.com/memryx/mxaccl/blob/release/CMakeLists.txt Sets common C and C++ flags for RISC-V 64-bit architectures during release builds, specifying a comprehensive set of extensions. ```cmake set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_COMMON_CFLAGS} -march=rv64gc_zicntr_ziccif_ziccrse_ziccamoa_za64rs_zba_zbb_zbs_zihpm_zihintpause_zic64b_zicbom_zicbop_zicboz_zkt_zfh_zicond_zbc" ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_COMMON_CFLAGS} -march=rv64gc_zicntr_ziccif_ziccrse_ziccamoa_za64rs_zba_zbb_zbs_zihpm_zihintpause_zic64b_zicbom_zicbop_zicboz_zkt_zfh_zicond_zbc" ) ``` -------------------------------- ### Release Build Flags for ARM64 Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/pymodule/CMakeLists.txt Applies common flags and ARMv8-A SIMD flags for release builds on ARM64 architectures. ```cmake set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_COMMON_CFLAGS} -march=armv8-a+simd -mtune=cortex-a76" ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_COMMON_CFLAGS} -march=armv8-a+simd -mtune=cortex-a76" ) ``` -------------------------------- ### x86 Architecture Flags Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/pymodule/CMakeLists.txt Defines base and AVX2 specific flags for x86 architectures. ```cmake set(CMAKE_X86_FLAGS_BASE "-mpopcnt -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mfxsr -mcx16 -msahf -mpclmul -mfsgsbase -mmovbe -mprfchw -mxsave -mxsaveopt -mtune=generic") set(CMAKE_X86_FLAGS_AVX2 "-mavx -mavx2 -mfma -mbmi -mbmi2 -maes -mf16c -mlzcnt -madx -mxsavec -mxsaves -mclflushopt") ``` -------------------------------- ### Set Compile Options for cpuinfo Target Source: https://github.com/memryx/mxaccl/blob/release/CMakeLists.txt Applies specific compile-time warning suppression options to the 'cpuinfo' target. ```cmake target_compile_options(cpuinfo PRIVATE -Wno-unused-parameter -Wno-unused-function -Wno-unused-variable -Wno-implicit-fallthrough) ``` -------------------------------- ### Find UDRIVER Library on Windows Source: https://github.com/memryx/mxaccl/blob/release/mxa_manager/CMakeLists.txt Locates the udriver library in a specific path on Windows. Fails if not found. ```cmake find_library(UDRIVER_LIB NAMES udriver PATHS "C:/Program Files/MemryX/lib" NO_DEFAULT_PATH ) if (NOT UDRIVER_LIB) message(FATAL_ERROR "Cannot find udriver.lib") endif() ``` -------------------------------- ### MSVC Specific Compile Option Source: https://github.com/memryx/mxaccl/blob/release/mxa_manager/CMakeLists.txt Adds the /utf-8 compile option for MSVC compiler on Windows. ```cmake if (MSVC) target_compile_options(mxa_manager PRIVATE /utf-8) endif() ``` -------------------------------- ### Set Build Type Source: https://github.com/memryx/mxaccl/blob/release/CMakeLists.txt Configures the build type (e.g., Release, Debug) for the project. It sets a cache variable and ensures CMAKE_BUILD_TYPE is defined. ```cmake set(BUILD_TYPE "Release" CACHE STRING "Build type (Release or Debug or Packaging or Regression)") if(NOT CMAKE_BUILD_TYPE) message(STATUS "Setting build type to '${BUILD_TYPE}' as none was specified.") set(CMAKE_BUILD_TYPE "${BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE) endif() ``` -------------------------------- ### Optimization Flags for Non-Debug Builds (MSVC) Source: https://github.com/memryx/mxaccl/blob/release/mxa_manager/CMakeLists.txt Enables Link-Time Code Generation (/GL) for MSVC compiler and linker in non-debug builds. ```cmake if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") if (MSVC) # Enable Link-Time Code Generation on MSVC target_compile_options(mxa_manager PRIVATE /GL) target_link_options(mxa_manager PRIVATE /LTCG) else() # Enable LTO on GCC/Clang target_compile_options(mxa_manager PRIVATE -fno-pic -fPIE -flto -fno-semantic-interposition) target_link_options(mxa_manager PRIVATE -fno-pic -fPIE -flto -fno-semantic-interposition) endif() endif() ``` -------------------------------- ### Set Compile Options for cpuinfo_internals Target Source: https://github.com/memryx/mxaccl/blob/release/CMakeLists.txt Applies specific compile-time warning suppression options to the 'cpuinfo_internals' target. ```cmake target_compile_options(cpuinfo_internals PRIVATE -Wno-unused-parameter -Wno-unused-function -Wno-unused-variable -Wno-implicit-fallthrough) ``` -------------------------------- ### Debug Build Flags Configuration Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/pymodule/CMakeLists.txt Sets C and C++ compiler flags for debug builds, including sanitizers and debug symbols. ```cmake set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -fPIC -O0 -g -fopenmp -fno-omit-frame-pointer -fsanitize=null -fsanitize=bounds -fsanitize=bounds-strict -Wno-unused-variable" ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fPIC -O0 -g -fopenmp -fno-omit-frame-pointer -fsanitize=null -fsanitize=bounds -fsanitize=bounds-strict -Wno-unused-variable" ) ``` -------------------------------- ### Set RPATH for Build Tree Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/pymodule/CMakeLists.txt Configures the RPATH for the 'mxapi' target to include the build directory of 'mx_accl', allowing runtime loading without manual LD_LIBRARY_PATH. ```cmake # Set RPATH for the build tree so the executable can find # the 'mx_accl' shared library without manual LD_LIBRARY_PATH exports. set_target_properties(mxapi PROPERTIES BUILD_RPATH "${CMAKE_CURRENT_SOURCE_DIR}/../../build/mx_accl" ) ``` -------------------------------- ### Conditional Link Options for Debug Builds Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/CMakeLists.txt Applies specific link options to the dynamic library when the build type is 'Debug'. ```cmake if(CMAKE_BUILD_TYPE MATCHES "Debug") target_link_options(${MXACCL_DYNAMIC} BEFORE PUBLIC PUBLIC ) endif() ``` -------------------------------- ### Debug Build Flags Source: https://github.com/memryx/mxaccl/blob/release/CMakeLists.txt Sets basic debug and common compilation flags for C and C++ when the build type is Debug. Includes options for enabling sanitizers if not disabled. ```cmake set(BASIC_DEBUG_FLAGS "-Wall -Wextra -fPIC -O0 -g -fopenmp -fno-omit-frame-pointer -Wno-unused-variable") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${BASIC_DEBUG_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${BASIC_DEBUG_FLAGS}") if(NOT DISABLE_SAN) set(SAN_FLAGS "-fsanitize=address -fsanitize=leak -fsanitize=null -fsanitize=bounds -fsanitize=bounds-strict -fsanitize=pointer-overflow") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SAN_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SAN_FLAGS}") endif() ``` -------------------------------- ### Add Subdirectories Conditionally Source: https://github.com/memryx/mxaccl/blob/release/CMakeLists.txt Iterates through found subdirectories, adding them as subdirectories to the build. It includes a condition to exclude the 'tools' directory if BUILD_TOOLS is OFF. ```cmake set(MXACCL_DYNAMIC "mx_accl") SUBDIRLIST(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR} "*") FOREACH(subdir ${SUBDIRS}) if(${subdir} STREQUAL "tools" AND NOT BUILD_TOOLS) message(STATUS "Excluding 'tools' directory from build due to BUILD_TOOLS=OFF.") elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/CMakeLists.txt) ADD_SUBDIRECTORY(${subdir}) endif() ENDFOREACH() ``` -------------------------------- ### Define SUBDIRLIST Macro Source: https://github.com/memryx/mxaccl/blob/release/CMakeLists.txt Defines a CMake macro to recursively find all subdirectories within a given directory. It uses FILE(GLOB) to list contents and checks if each item is a directory. ```cmake MACRO(SUBDIRLIST result curdir) FILE(GLOB children RELATIVE ${curdir} ${curdir}/*) SET(dirlist "") FOREACH(child ${children}) IF(IS_DIRECTORY ${curdir}/${child}) LIST(APPEND dirlist ${child}) ENDIF() ENDFOREACH() SET(${result} ${dirlist}) ENDMACRO() ``` -------------------------------- ### Common CFLAGS Definition Source: https://github.com/memryx/mxaccl/blob/release/mx_accl/pymodule/CMakeLists.txt Defines a set of common C compiler flags used for optimization and warnings. ```cmake set(CMAKE_COMMON_CFLAGS "-Wall -Wextra -pipe -fPIC -O2 -fvect-cost-model=dynamic -fsimd-cost-model=unlimited -floop-unroll-and-jam -ftree-loop-if-convert -ftree-loop-im -ftree-loop-ivcanon -funswitch-loops -fgcse-after-reload -fipa-cp-clone -ftree-loop-distribution -ftree-partial-pre -fsplit-paths -fpredictive-commoning -fno-math-errno -funsafe-math-optimizations -ffinite-math-only -fno-signed-zeros -fno-trapping-math -fno-signaling-nans -fcx-limited-range -fopenmp -Wno-unused-variable -Wno-alloc-size-larger-than") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.