Skip to content

Commit

Permalink
Merge pull request #168 from frasercrmck/spirv-ll-version-features
Browse files Browse the repository at this point in the history
[spirv-ll] Improve spirv-as version tracking for test features
  • Loading branch information
frasercrmck authored Oct 18, 2023
2 parents 1f06f84 + f734daa commit c74aadd
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 28 deletions.
34 changes: 25 additions & 9 deletions modules/compiler/spirv-ll/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,32 @@ if(CA_ASSEMBLE_SPIRV_LL_LIT_TESTS_OFFLINE)

find_package(SpirvTools COMPONENTS spirv-as)
if(TARGET spirv::spirv-as)
# Get the found spirv-as version, takes the form: v<year>.<release>
# Get the found spirv-as version, takes the form: v<year>.<point>(-dev)?
# We treat 'dev' as the previous point release: see below.
execute_process(
COMMAND ${SpirvTools_spirv-as_EXECUTABLE} --version
OUTPUT_VARIABLE SpirvAsVersionOutput)
string(REGEX MATCH "v20[0-9][0-9].[0-9]+"
SpirvAsVersion ${SpirvAsVersionOutput})
string(REGEX MATCH "20[0-9][0-9]"
SpirvAsVersionYear ${SpirvAsVersion})
string(REGEX MATCH "[0-9]+$"
SpirvAsVersionRelease ${SpirvAsVersion})
message(STATUS "spirv-as: v${SpirvAsVersionYear}.${SpirvAsVersionRelease}")
string(REGEX MATCH "v(20[0-9][0-9]).([0-9]+)(-dev)?" Tmp ${SpirvAsVersionOutput})
set(SpirvAsVersionYear "${CMAKE_MATCH_1}")
set(SpirvAsVersionPoint "${CMAKE_MATCH_2}")
set(SpirvAsVersionDev "${CMAKE_MATCH_3}")
message(STATUS "spirv-as: v${SpirvAsVersionYear}.${SpirvAsVersionPoint}${SpirvAsVersionDev}")
# If we have a 'development' version, canonicalize the internal version as
# the previous version:
# * Decrement the 'point release' by one
# * If that would result in a negative number, decrement the year and set
# the 'point release' to 9 (an arbitrarily high version number)
if(SpirvAsVersionDev)
if(SpirvAsVersionPoint STREQUAL "0")
set(SpirvAsVersionPoint "9")
MATH(EXPR SpirvAsVersionYear "${SpirvAsVersionYear}-1")
else()
MATH(EXPR SpirvAsVersionPoint "${SpirvAsVersionPoint}-1")
endif()
message(STATUS "Detected 'dev' spirv-as version - tracking version "
"internally as: v${SpirvAsVersionYear}.${SpirvAsVersionPoint}")
endif()
set(SpirvAsVersion "${SpirvAsVersionYear}.${SpirvAsVersionPoint}")
else()
set(SPVASM_UNSUPPORTED True)
message(WARNING "${SUITE} spvasm lit tests unsupported: spirv-as not found")
Expand All @@ -65,7 +80,8 @@ add_ca_configure_lit_site_cfg(
CA_ASSEMBLE_SPIRV_LL_LIT_TESTS_OFFLINE=${CA_ASSEMBLE_SPIRV_LL_LIT_TESTS_OFFLINE}
GLSL_UNSUPPORTED=${GLSL_UNSUPPORTED}
SPVASM_UNSUPPORTED=${SPVASM_UNSUPPORTED}
SPIRV_AS_VERSION_YEAR=${SpirvAsVersionYear})
SPIRV_AS_VERSION_YEAR=${SpirvAsVersionYear}
SPIRV_AS_VERSION_POINT=${SpirvAsVersionPoint})

add_subdirectory(glsl)
add_subdirectory(spvasm)
Expand Down
23 changes: 20 additions & 3 deletions modules/compiler/spirv-ll/test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,19 @@ if (config.explicitly_online_offline == True
subst_path = config.substitutions[idx][1]
output = str(check_output([subst_path, '--version']))

m = re.search(r'SPIRV-Tools v(20\d{2,})\.(\d+)', output)
m = re.search(r'SPIRV-Tools v(20\d{2,})\.(\d+)(-dev)?', output)
if m:
config.spirv_as_version_year = int(m.group(1))
config.spirv_as_version_point = int(m.group(2))
if m.group(3):
# If decrementing the point would result in a negative
# point release, decrement the year instead, and set the
# point at 9.
if config.spirv_as_version_point != 0:
config.spirv_as_version_point -= 1
else:
config.spirv_as_version_point = 9
config.spirv_as_version_year -= 1

if not extra_tools[1].was_resolved:
config.available_features.add('no-glsl')
Expand All @@ -86,5 +96,12 @@ if 'spirv_as_version_year' not in vars(config) or not config.spirv_as_version_ye
lit_config.note("spirv-as version could not be determined: some tests may be disabled")
else:
config.available_features.add(f'spirv-as-v{config.spirv_as_version_year}-only')
for year in range(2016, config.spirv_as_version_year + 1):
config.available_features.add(f'spirv-as-v{year}+')
# Add all of the previous years maj.point releases. We arbitrarily assume 9
# as the max point release. We have to include them all as these are LIT
# features, not actual version strings that can be programatically checked.
for year in range(2016, config.spirv_as_version_year):
for point in range(0, 10):
config.available_features.add(f'spirv-as-v{year}.{point}+')
# Add all of this year's maj.point releases
for point in range(0, config.spirv_as_version_point + 1):
config.available_features.add(f'spirv-as-v{config.spirv_as_version_year}.{point}+')
2 changes: 2 additions & 0 deletions modules/compiler/spirv-ll/test/lit.site.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ if @SPVASM_UNSUPPORTED@ and (config.offline and config.explicitly_online_offline

if '@SPIRV_AS_VERSION_YEAR@' and (config.offline and config.explicitly_online_offline != True):
config.spirv_as_version_year = int(@SPIRV_AS_VERSION_YEAR@)
if '@SPIRV_AS_VERSION_POINT@' and (config.offline and config.explicitly_online_offline != True):
config.spirv_as_version_point = int(@SPIRV_AS_VERSION_POINT@)

# Defer to the common lit configuration to set up the bulk of the config.
common_lit_cfg_path = os.path.join('@CA_COMMON_LIT_BINARY_PATH@', 'lit.common.cfg')
Expand Down
11 changes: 5 additions & 6 deletions modules/compiler/spirv-ll/test/spvasm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2365,14 +2365,14 @@ set(SPVASM_FILES
invalid_storage_class.spvasm
)

if(SpirvAsVersionYear GREATER 2019)
if(SpirvAsVersion VERSION_GREATER_EQUAL "2020.0")
list(APPEND SPVASM_FILES
op_execution_mode_max_work_dim.spvasm
opencl_group_async_copy_2d2d.spvasm
opencl_group_async_copy_3d3d.spvasm)
endif()

if (SpirvAsVersionYear GREATER_EQUAL 2022)
if (SpirvAsVersion VERSION_GREATER_EQUAL "2021.3")
list(APPEND SPVASM_FILES
intel_opt_none.spvasm
subgroup_shuffle_intel.spvasm
Expand All @@ -2382,12 +2382,11 @@ if (SpirvAsVersionYear GREATER_EQUAL 2022)
)
endif()

if (SpirvAsVersionYear GREATER 2022)
list(APPEND SPVASM_FILES
intel_memory_access_aliasing.spvasm)
if (SpirvAsVersion VERSION_GREATER_EQUAL "2022.2")
list(APPEND SPVASM_FILES intel_memory_access_aliasing.spvasm)
endif()

if (SpirvAsVersionYear GREATER 2023)
if (SpirvAsVersion VERSION_GREATER_EQUAL "2023.5")
list(APPEND SPVASM_FILES op_group_f_mul.spvasm)
endif()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
; under the License.
;
; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
; REQUIRES: spirv-as-v2023+
; REQUIRES: spirv-as-v2022.2+
; RUN: spirv-as --version
; RUN: %if online-spirv-as %{ spirv-as --target-env %spv_tgt_env -o %spv_file_s %s %}
; RUN: spirv-ll-tool -a OpenCL -b 64 -e SPV_INTEL_memory_access_aliasing %spv_file_s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
;
; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

; REQUIRES: spirv-as-v2022+
; REQUIRES: spirv-as-v2021.3+
; RUN: %if online-spirv-as %{ spirv-as --target-env %spv_tgt_env -o %spv_file_s %s %}
; RUN: spirv-ll-tool -a OpenCL -b 64 %spv_file_s | FileCheck %s
OpCapability Addresses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
;
; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

; REQUIRES: spirv-as-v2020+
; REQUIRES: spirv-as-v2020.0+
; RUN: %if online-spirv-as %{ spirv-as --target-env %spv_tgt_env -o %spv_file_s %s %}
; RUN: spirv-ll-tool -a OpenCL -b 64 %spv_file_s | FileCheck %s

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
;
; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

; REQUIRES: spirv-as-v2024+
; REQUIRES: spirv-as-v2023.5+
; RUN: %if online-spirv-as %{ spirv-as --target-env %spv_tgt_env -o %spv_file_s %s %}
; RUN: spirv-ll-tool -a OpenCL -b 64 -c GroupUniformArithmeticKHR %spv_file_s | FileCheck %s

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
;
; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

; REQUIRES: spirv-as-v2020+
; REQUIRES: spirv-as-v2020.0+
; RUN: %if online-spirv-as %{ spirv-as --target-env %spv_tgt_env -o %spv_file_s %s %}
; RUN: %pp-llvm-ver -o %t < %s --llvm-ver %LLVMVER
; RUN: spirv-ll-tool -a OpenCL -b 64 %spv_file_s | FileCheck %t
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
;
; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

; REQUIRES: spirv-as-v2020+
; REQUIRES: spirv-as-v2020.0+
; RUN: %if online-spirv-as %{ spirv-as --target-env %spv_tgt_env -o %spv_file_s %s %}
; RUN: %pp-llvm-ver -o %t < %s --llvm-ver %LLVMVER
; RUN: spirv-ll-tool -a OpenCL -b 64 %spv_file_s | FileCheck %t
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
;
; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

; REQUIRES: spirv-as-v2022+
; REQUIRES: spirv-as-v2021.3+
; RUN: %if online-spirv-as %{ spirv-as --target-env %spv_tgt_env -o %spv_file_s %s %}
; RUN: spirv-ll-tool -a OpenCL -b 64 -c Float64 -c Int64 -c SubgroupShuffleINTEL \
; RUN: -e SPV_INTEL_subgroups %spv_file_s | FileCheck %s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
;
; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

; REQUIRES: spirv-as-v2022+
; REQUIRES: spirv-as-v2021.3+
; RUN: %if online-spirv-as %{ spirv-as --target-env %spv_tgt_env -o %spv_file_s %s %}
; RUN: spirv-ll-tool -a OpenCL -b 64 -c Float64 -c Int64 -c SubgroupShuffleINTEL \
; RUN: -e SPV_INTEL_subgroups %spv_file_s | FileCheck %s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
;
; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

; REQUIRES: spirv-as-v2022+
; REQUIRES: spirv-as-v2021.3+
; RUN: %if online-spirv-as %{ spirv-as --target-env %spv_tgt_env -o %spv_file_s %s %}
; RUN: spirv-ll-tool -a OpenCL -b 64 -c Float64 -c Int64 -c SubgroupShuffleINTEL \
; RUN: -e SPV_INTEL_subgroups %spv_file_s | FileCheck %s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
;
; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

; REQUIRES: spirv-as-v2022+
; REQUIRES: spirv-as-v2021.3+
; RUN: %if online-spirv-as %{ spirv-as --target-env %spv_tgt_env -o %spv_file_s %s %}
; RUN: spirv-ll-tool -a OpenCL -b 64 -c Float64 -c Int64 \
; RUN: -c GenericPointer -c SubgroupShuffleINTEL \
Expand Down

0 comments on commit c74aadd

Please sign in to comment.