diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 598b43e..b1efb80 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,15 +19,25 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + include: + - os: ubuntu-latest + optional_args: -pt + - os: windows-latest + optional_args: -pt --cmake_gen ninja + - os: macos-latest steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - name: Checkout sources + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - name: Setup Fortran compiler + uses: fortran-lang/setup-fortran@8821f57b53846d35d62632eb51c60ac6c4bff4ce # v1.6.1 with: - submodules: recursive + compiler: intel - name: Build C library - # TODO: Ubuntu is phasing out support for 32-bit packages (e.g., `apt install gcc-multilib` - # fails on GitHub's runner); only build the 64-bit version for now. - run: python buildall.py --force_bits 64 + # 1. Force to only build the 64-bit version since ITT API 32-bit support will be discontinued soon + # 2. Disable PT support for MacOS since we have x86 specific assembly instructions + # 3. Switch to use Ninja CMake Generator for Windows since setup-fortran action + # doesn't work in case of CMake + VS (https://github.com/fortran-lang/setup-fortran/issues/45) + run: python buildall.py --force_bits 64 -ft ${{ matrix.optional_args }} rust_format: name: Check Rust formatting diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index caddc26..0762086 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,22 +15,33 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + include: + - os: ubuntu-latest + optional_args: -pt + - os: windows-latest + optional_args: -pt --cmake_gen ninja + - os: macos-latest steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - with: - submodules: recursive + - name: Checkout sources + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Config environment if: runner.os == 'Linux' - run: sudo apt-get install gcc-multilib + run: sudo apt-get update && sudo apt-get install gcc-multilib + - name: Setup Fortran compiler + uses: fortran-lang/setup-fortran@8821f57b53846d35d62632eb51c60ac6c4bff4ce # v1.6.1 + with: + compiler: intel - name: Build C library - run: python buildall.py ${{ runner.os != 'macOS' && '-pt -v' || '-v' }} + run: python buildall.py -ft ${{ matrix.optional_args }} - name: Display structure of files run: ls -R - - uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0 + - name: Upload artifact + uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0 with: name: build-artifacts-${{ matrix.os }} - path: build*/**/bin + path: | + build*/**/bin + build*/**/fortran create_release: permissions: @@ -39,9 +50,9 @@ jobs: runs-on: ubuntu-latest needs: build steps: - - name: Chechout sources + - name: Checkout sources uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - name: Create Release + - name: Create release id: create_release uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # v1.1.4 env: @@ -51,7 +62,7 @@ jobs: release_name: release ${{ github.ref_name }} draft: false prerelease: false - - name: Download Artifacts + - name: Download artifacts uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 with: path: build-artifacts @@ -61,11 +72,11 @@ jobs: run: ls -R - name: Zip files run: | - zip -r ittapi_build_${{ github.ref_name }}.zip include && - cd build-artifacts && - zip -rg ../ittapi_build_${{ github.ref_name }}.zip build*/**/bin && + zip -r ittapi_build_${{ github.ref_name }}.zip include && + cd build-artifacts && + zip -rg ../ittapi_build_${{ github.ref_name }}.zip build*/**/bin build*/**/fortran && cd - - - name: Upload Release Asset + - name: Upload release asset id: upload-release-asset uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5 # v1.0.2 env: diff --git a/CMakeLists.txt b/CMakeLists.txt index aaa2f16..7b56b06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,9 +4,9 @@ # SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause # -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.5) -if (POLICY CMP0048) +if(POLICY CMP0048) # The `project()` command manages `VERSION` variables cmake_policy(SET CMP0048 NEW) endif() @@ -23,19 +23,25 @@ endif() project(ittapi) -OPTION(FORCE_32 "Force a 32bit compile on 64bit" OFF) -OPTION(ITT_API_IPT_SUPPORT "ptmarks support" OFF) -OPTION(ITT_API_FORTRAN_SUPPORT "fortran support" OFF) +option(FORCE_32 "Force a 32-bit compile on 64-bit" OFF) +option(ITT_API_IPT_SUPPORT "ptmarks support" OFF) +option(ITT_API_FORTRAN_SUPPORT "fortran support" OFF) -IF(FORCE_32 AND UNIX) +if(FORCE_32 AND UNIX) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") -ENDIF() +endif() if(CMAKE_SIZEOF_VOID_P MATCHES "8" AND NOT(FORCE_32)) set(ARCH_64 ON) endif() +if(FORCE_32 AND ITT_API_FORTRAN_SUPPORT) + # ifx dropped 32-bit support + message(WARNING "Fortran support for 32-bit has been discontinued") + set(ITT_API_FORTRAN_SUPPORT OFF) +endif() + if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$") # override default -O3 string(REPLACE "-O3" "-O2" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") @@ -48,10 +54,10 @@ endif() set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) -foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} ) - string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG ) - set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${LIBRARY_OUTPUT_PATH} ) -endforeach( ) +foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${LIBRARY_OUTPUT_PATH}) +endforeach() set(ITT_PUBLIC_HDRS include/ittnotify.h @@ -61,21 +67,21 @@ set(ITT_PUBLIC_HDRS file(GLOB ITT_SRCS "src/ittnotify/*.c" "src/ittnotify/*.h") -if (ITT_API_IPT_SUPPORT) +if(ITT_API_IPT_SUPPORT) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DITT_API_IPT_SUPPORT") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DITT_API_IPT_SUPPORT") - if (NOT WIN32) + if(NOT WIN32) enable_language(ASM) - if (ARCH_64) + if(ARCH_64) set(ITT_PT src/ittnotify/ittptmark64.S) else() set(ASM_OPTIONS "-m32") set(ITT_PT src/ittnotify/ittptmark32.S) endif() - set(CMAKE_ASM_FLAGS "${CFLAGS} ${ASM_OPTIONS}" ) + set(CMAKE_ASM_FLAGS "${CFLAGS} ${ASM_OPTIONS}") else() enable_language(ASM_MASM) - if (ARCH_64) + if(ARCH_64) set(ITT_PT src/ittnotify/ittptmark64.asm) else() set(ITT_PT src/ittnotify/ittptmark32.asm) @@ -83,7 +89,7 @@ if (ITT_API_IPT_SUPPORT) endif() endif() -if (NOT WIN32) +if(NOT WIN32) set(PLATFORM_PATH "posix") set(PLATFORM_EXT "o") else() @@ -91,15 +97,36 @@ else() set(PLATFORM_EXT "obj") endif() -if (ARCH_64) - set(ARCH_PATH "x86_64") -else() - set(ARCH_PATH "x86") -endif() - if(ITT_API_FORTRAN_SUPPORT) - set(ITT_FORTRAN include/fortran/${PLATFORM_PATH}/${ARCH_PATH}/ittfortran.${PLATFORM_EXT}) - set(ADVISOR_ANNOTATION include/fortran/${PLATFORM_PATH}/${ARCH_PATH}/advisor_annotate.${PLATFORM_EXT}) + enable_language(Fortran) + + set(FORTRAN_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/fortran) + file(MAKE_DIRECTORY ${FORTRAN_BINARY_DIR}) + + set(ITT_FORTRAN_SRC ${CMAKE_CURRENT_SOURCE_DIR}/include/fortran/${PLATFORM_PATH}/ittnotify.f90) + set(ADVISOR_ANNOTATION_SRC ${CMAKE_CURRENT_SOURCE_DIR}/include/fortran/advisor_annotate.f90) + set(ITT_FORTRAN ${FORTRAN_BINARY_DIR}/ittfortran.${PLATFORM_EXT}) + set(ADVISOR_ANNOTATION ${FORTRAN_BINARY_DIR}/advisor_annotate.${PLATFORM_EXT}) + + if(WIN32) + set(FORTRAN_BUILD_CMD ${CMAKE_Fortran_COMPILER} /Z7 /nologo /libdir:noauto /c /O2 /module:${FORTRAN_BINARY_DIR}) + set(ITT_FORTRAN_BUILD_CMD ${FORTRAN_BUILD_CMD} /object:${ITT_FORTRAN} ${ITT_FORTRAN_SRC}) + set(ADVISOR_ANNOTATION_BUILD_CMD ${FORTRAN_BUILD_CMD} /object:${ADVISOR_ANNOTATION} ${ADVISOR_ANNOTATION_SRC}) + else() + set(FORTRAN_BUILD_CMD ${CMAKE_Fortran_COMPILER} -g -c -fPIC -O2 -module ${FORTRAN_BINARY_DIR}) + set(ITT_FORTRAN_BUILD_CMD ${FORTRAN_BUILD_CMD} -o ${ITT_FORTRAN} ${ITT_FORTRAN_SRC}) + set(ADVISOR_ANNOTATION_BUILD_CMD ${FORTRAN_BUILD_CMD} -o ${ADVISOR_ANNOTATION} ${ADVISOR_ANNOTATION_SRC}) + endif() + + add_custom_command(OUTPUT ${ITT_FORTRAN} + COMMAND ${ITT_FORTRAN_BUILD_CMD} + DEPENDS ${ITT_FORTRAN_SRC} + COMMENT "Building ITT Fortran") + + add_custom_command(OUTPUT ${ADVISOR_ANNOTATION} + COMMAND ${ADVISOR_ANNOTATION_BUILD_CMD} + DEPENDS ${ADVISOR_ANNOTATION_SRC} + COMMENT "Building Advisor Annotation") add_library(ittnotify STATIC ${ITT_SRCS} ${ITT_PUBLIC_HDRS} ${ITT_PT} ${ITT_FORTRAN}) add_library(advisor STATIC ${ADVISOR_ANNOTATION}) @@ -111,24 +138,24 @@ set(JITPROFILING_SRC "src/ittnotify/jitprofiling.c") add_library(jitprofiling STATIC ${JITPROFILING_SRC}) if(WIN32) - SET_TARGET_PROPERTIES(ittnotify PROPERTIES OUTPUT_NAME libittnotify) - SET_TARGET_PROPERTIES(jitprofiling PROPERTIES OUTPUT_NAME libjitprofiling) + set_target_properties(ittnotify PROPERTIES OUTPUT_NAME libittnotify) + set_target_properties(jitprofiling PROPERTIES OUTPUT_NAME libjitprofiling) if(ITT_API_FORTRAN_SUPPORT) - SET_TARGET_PROPERTIES(advisor PROPERTIES OUTPUT_NAME libadvisor) + set_target_properties(advisor PROPERTIES OUTPUT_NAME libadvisor) endif() else() - SET_TARGET_PROPERTIES(ittnotify PROPERTIES OUTPUT_NAME ittnotify) - SET_TARGET_PROPERTIES(jitprofiling PROPERTIES OUTPUT_NAME jitprofiling) + set_target_properties(ittnotify PROPERTIES OUTPUT_NAME ittnotify) + set_target_properties(jitprofiling PROPERTIES OUTPUT_NAME jitprofiling) if(ITT_API_FORTRAN_SUPPORT) - SET_TARGET_PROPERTIES(advisor PROPERTIES OUTPUT_NAME advisor) + set_target_properties(advisor PROPERTIES OUTPUT_NAME advisor) endif() endif() -TARGET_LINK_LIBRARIES(ittnotify PRIVATE ${CMAKE_DL_LIBS}) +target_link_libraries(ittnotify PRIVATE ${CMAKE_DL_LIBS}) -SET_TARGET_PROPERTIES(ittnotify PROPERTIES LINKER_LANGUAGE C) +set_target_properties(ittnotify PROPERTIES LINKER_LANGUAGE C) if(ITT_API_FORTRAN_SUPPORT) - SET_TARGET_PROPERTIES(advisor PROPERTIES LINKER_LANGUAGE C) + set_target_properties(advisor PROPERTIES LINKER_LANGUAGE C) endif() target_include_directories(ittnotify diff --git a/README.md b/README.md index 4e631dc..36820cf 100644 --- a/README.md +++ b/README.md @@ -21,9 +21,10 @@ a BSD/GPLv2 dual license with every tool supporting ITT API. To build the library: - On Windows, Linux, FreeBSD and OSX: requires [cmake](https://cmake.org) to be set in `PATH` - Windows: requires Visual Studio installed or requires [Ninja](https://github.com/ninja-build/ninja/releases) to be set in `PATH` + - To enable fortran support requires [Intel Fortran Compiler](https://www.intel.com/content/www/us/en/docs/fortran-compiler/get-started-guide/current/overview.html) installed - To list available build options execute: `python buildall.py -h` ``` -usage: buildall.py [-h] [-d] [-c] [-v] [-pt] [--force_bits] [-ft] +usage: buildall.py [-h] [-d] [-c] [-v] [-pt] [-ft] [--force_bits] optional arguments: -h, --help show this help message and exit @@ -31,8 +32,10 @@ optional arguments: -c, --clean delete any intermediate and output files -v, --verbose enable verbose output from build process -pt, --ptmark enable anomaly detection support - --force_bits specify bit version for the target -ft, --fortran enable fortran support + --force_bits specify bit version for the target + --vs specify visual studio version (Windows only) + --cmake_gen specify cmake build generator (Windows only) ``` ### License diff --git a/buildall.py b/buildall.py index 430e0f6..a85cb7f 100755 --- a/buildall.py +++ b/buildall.py @@ -115,13 +115,15 @@ def main(): "-v", "--verbose", help="enable verbose output from build process", action="store_true") parser.add_argument( "-pt", "--ptmark", help="enable anomaly detection support", action="store_true") + parser.add_argument( + "-ft", "--fortran", help="enable fortran support", action="store_true") parser.add_argument( "--force_bits", choices=["32", "64"], help="specify bit version for the target") - parser.add_argument("-ft", "--fortran", - help="enable fortran support", action="store_true") if sys.platform == 'win32' and vs_versions: parser.add_argument( "--vs", help="specify visual studio version {default}", choices=vs_versions, default=vs_versions[0]) + parser.add_argument( + "--cmake_gen", choices=["vs", "ninja"], help="specify cmake build generator") args = parser.parse_args() if args.force_bits: @@ -157,7 +159,9 @@ def main(): return if sys.platform == 'win32': - if vs_versions: + # ninja does not support platform bit specification + use_ninja = args.cmake_gen == 'ninja' and bits =='64' + if vs_versions and not use_ninja: generator = 'Visual Studio {}'.format(args.vs) generator_args = '-A {}'.format('x64' if bits == '64' else 'Win32') @@ -177,7 +181,7 @@ def main(): ]))) if sys.platform == 'win32': - target_project = 'ALL_BUILD' + target_project = 'ALL_BUILD' if not use_ninja else 'all' run_shell('%s --build . --config %s --target %s' % (cmake, ('Debug' if args.debug else 'Release'), target_project)) else: diff --git a/include/fortran/posix/x86/advisor_annotate.mod b/include/fortran/posix/x86/advisor_annotate.mod deleted file mode 100644 index d087af0..0000000 Binary files a/include/fortran/posix/x86/advisor_annotate.mod and /dev/null differ diff --git a/include/fortran/posix/x86/advisor_annotate.o b/include/fortran/posix/x86/advisor_annotate.o deleted file mode 100644 index 5eeabfc..0000000 Binary files a/include/fortran/posix/x86/advisor_annotate.o and /dev/null differ diff --git a/include/fortran/posix/x86/ittfortran.o b/include/fortran/posix/x86/ittfortran.o deleted file mode 100644 index 2e31afe..0000000 Binary files a/include/fortran/posix/x86/ittfortran.o and /dev/null differ diff --git a/include/fortran/posix/x86/ittnotify.mod b/include/fortran/posix/x86/ittnotify.mod deleted file mode 100644 index 80e31c2..0000000 Binary files a/include/fortran/posix/x86/ittnotify.mod and /dev/null differ diff --git a/include/fortran/posix/x86_64/advisor_annotate.mod b/include/fortran/posix/x86_64/advisor_annotate.mod deleted file mode 100644 index b4b6a10..0000000 Binary files a/include/fortran/posix/x86_64/advisor_annotate.mod and /dev/null differ diff --git a/include/fortran/posix/x86_64/advisor_annotate.o b/include/fortran/posix/x86_64/advisor_annotate.o deleted file mode 100644 index 43f50f0..0000000 Binary files a/include/fortran/posix/x86_64/advisor_annotate.o and /dev/null differ diff --git a/include/fortran/posix/x86_64/ittfortran.o b/include/fortran/posix/x86_64/ittfortran.o deleted file mode 100644 index 3ae63b8..0000000 Binary files a/include/fortran/posix/x86_64/ittfortran.o and /dev/null differ diff --git a/include/fortran/posix/x86_64/ittnotify.mod b/include/fortran/posix/x86_64/ittnotify.mod deleted file mode 100644 index d77c0d1..0000000 Binary files a/include/fortran/posix/x86_64/ittnotify.mod and /dev/null differ diff --git a/include/fortran/win32/x86/advisor_annotate.mod b/include/fortran/win32/x86/advisor_annotate.mod deleted file mode 100644 index a23a3e7..0000000 Binary files a/include/fortran/win32/x86/advisor_annotate.mod and /dev/null differ diff --git a/include/fortran/win32/x86/advisor_annotate.obj b/include/fortran/win32/x86/advisor_annotate.obj deleted file mode 100644 index 9dbbee1..0000000 Binary files a/include/fortran/win32/x86/advisor_annotate.obj and /dev/null differ diff --git a/include/fortran/win32/x86/ittfortran.obj b/include/fortran/win32/x86/ittfortran.obj deleted file mode 100644 index 4e9acc8..0000000 Binary files a/include/fortran/win32/x86/ittfortran.obj and /dev/null differ diff --git a/include/fortran/win32/x86/ittnotify.mod b/include/fortran/win32/x86/ittnotify.mod deleted file mode 100644 index f8b871f..0000000 Binary files a/include/fortran/win32/x86/ittnotify.mod and /dev/null differ diff --git a/include/fortran/win32/x86_64/advisor_annotate.mod b/include/fortran/win32/x86_64/advisor_annotate.mod deleted file mode 100644 index d4fc8b1..0000000 Binary files a/include/fortran/win32/x86_64/advisor_annotate.mod and /dev/null differ diff --git a/include/fortran/win32/x86_64/advisor_annotate.obj b/include/fortran/win32/x86_64/advisor_annotate.obj deleted file mode 100644 index 6086a86..0000000 Binary files a/include/fortran/win32/x86_64/advisor_annotate.obj and /dev/null differ diff --git a/include/fortran/win32/x86_64/ittfortran.obj b/include/fortran/win32/x86_64/ittfortran.obj deleted file mode 100644 index 0912f96..0000000 Binary files a/include/fortran/win32/x86_64/ittfortran.obj and /dev/null differ diff --git a/include/fortran/win32/x86_64/ittnotify.mod b/include/fortran/win32/x86_64/ittnotify.mod deleted file mode 100644 index ea5eeab..0000000 Binary files a/include/fortran/win32/x86_64/ittnotify.mod and /dev/null differ