Skip to content
Draft
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
4407461
Remove setting `_GLIBCXX_USE_CXX11_ABI`
mhucka May 7, 2026
27f2b3f
chore: merge branch
mhucka May 9, 2026
41a092b
Perform build-time probing of host capabilities
mhucka May 9, 2026
1495b86
Add unit tests for compiler_probe.bzl
mhucka May 9, 2026
e2767fe
Add support for `--config=native`
mhucka May 10, 2026
e9e1bba
Remove incorrect ui filter
mhucka May 10, 2026
aba0eb3
Print debug messages about flags being used
mhucka May 10, 2026
f7b6922
Improve options-handling
mhucka May 10, 2026
6ff42dc
Add the ability to specify avx2 and avx512 independently
mhucka May 10, 2026
11d3cdd
Refactor dev_tools/test_libs.sh
mhucka May 10, 2026
d7df1c7
Remove no-longer-needed py-cpuinfo
mhucka May 10, 2026
226318d
Add more hardware tests to ci.yaml
mhucka May 10, 2026
7843dc4
Update comment
mhucka May 10, 2026
942a85f
Overhaul implementation
mhucka May 11, 2026
7728532
Merge branch 'main' into improve-bazelrc
mhucka May 11, 2026
e72c031
Merge branch 'main' into improve-bazelrc
mhucka May 11, 2026
2fda88d
Update docs/bazel.md to explain new flags
mhucka May 11, 2026
e6de141
Remove flag that is never used
mhucka May 11, 2026
60fb3b3
Remove qsimh from bazel build & test targets
mhucka May 11, 2026
36c1483
Can't use avx512 on GitHub runners
mhucka May 11, 2026
53bd3cd
Adjust for Windows differences
mhucka May 11, 2026
e825993
chore: merge branch
mhucka May 17, 2026
e5a3349
Fix merge screw-up
mhucka May 18, 2026
996ac53
Fix a couple of platform bugs
mhucka May 18, 2026
c54686b
Fix inconsistency in unpacking results from get_feature_booleans
mhucka May 18, 2026
27784c6
Remove unused `using Gate`
mhucka May 18, 2026
a15dcc4
Try another fix
mhucka May 18, 2026
0174e0e
Try to streamline the the compiler detection code
mhucka May 18, 2026
ede3ce5
In CI, use more modern cmake build arguments
mhucka May 18, 2026
1730218
Seems the problem may have been in Operation.h
mhucka May 18, 2026
7c40b5d
Try again to fix Windows build issues
mhucka May 18, 2026
c384b1c
Fix build dir naming problem
mhucka May 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 25 additions & 15 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,10 @@ build:macos --cxxopt=-std=c++17
build:windows --copt=/std:c++17
build:windows --cxxopt=/std:c++17

build --copt=-D_GLIBCXX_USE_CXX11_ABI=1
build --cxxopt=-D_GLIBCXX_USE_CXX11_ABI=1

# The default for vector instruction sets is to exclude them.
# Config options later in this file can be layered to enable them.
build --build_tag_filters=-avx,-sse
test --test_tag_filters=-avx,-sse
# "bazel run" inherits options from "build". Our run targets don't have tags,
# so we must clear the filter explicitly or we get "No targets found to run".
run:sse --build_tag_filters=
run:avx --build_tag_filters=

# CUDA options
build:cuda --@local_config_cuda//:enable_cuda
Expand Down Expand Up @@ -83,18 +76,35 @@ build:nosan --

# ~~~~ Instruction set options (choose one) ~~~~

# Build with AVX2 + FMA
# Build with AVX
build:avx --define=qsim_avx=true --define=cpu_features=AVX
build:avx --copt=-O3
build:avx --copt=-mavx2
build:avx --copt=-mfma
build:avx --build_tag_filters=avx --ui_event_filters=-WARNING
test:avx --test_tag_filters=avx --ui_event_filters=-WARNING
build:avx --build_tag_filters=
test:avx --test_tag_filters=

# Build with AVX2
build:avx2 --define=qsim_avx2=true --define=cpu_features=AVX2
build:avx2 --copt=-O3
build:avx2 --build_tag_filters=
test:avx2 --test_tag_filters=

# Build with AVX512
build:avx512 --define=qsim_avx512=true --define=cpu_features=AVX512
build:avx512 --copt=-O3
build:avx512 --build_tag_filters=
test:avx512 --test_tag_filters=

# Build with SSE
build:sse --define=qsim_sse=true --define=cpu_features=SSE
build:sse --copt=-O3
build:sse --copt=-msse4
build:sse --build_tag_filters=sse --ui_event_filters=-WARNING
test:sse --test_tag_filters=sse --ui_event_filters=-WARNING
build:sse --build_tag_filters=
test:sse --test_tag_filters=

# Let the compiler pick the best combination for the native architecture.
build:native --define=qsim_native=true --define=cpu_features=Native
build:native --copt=-O3
build:native --build_tag_filters=
test:native --test_tag_filters=

# Build without AVX or SSE
build:basic --copt=-O3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ jobs:
strategy:
matrix:
# Hardware optimizers.
hardware_opt: [avx, sse, basic]
hardware_opt: [avx512, avx2, avx, sse, native, basic]
# Optimizers for parallelism.
parallel_opt: [openmp, nopenmp]
steps:
Expand Down
89 changes: 89 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("//dev_tools:bazel_utils.bzl", "qsim_print_flags", "qsim_select_copts")

qsim_print_flags(
name = "show_flags",
flags = qsim_select_copts(target_level = "avx"),
visibility = ["//visibility:public"],
)

# Define configurations for build with AVX and/or SSE support.

config_setting(
name = "avx_requested",
values = {"define": "qsim_avx=true"},
)

config_setting(
name = "avx2_requested",
values = {"define": "qsim_avx2=true"},
)

config_setting(
name = "avx512_requested",
values = {"define": "qsim_avx512=true"},
)

config_setting(
name = "avx_and_avx2_requested",
define_values = {
"qsim_avx": "true",
"qsim_avx2": "true",
},
)

config_setting(
name = "avx_and_avx512_requested",
define_values = {
"qsim_avx": "true",
"qsim_avx512": "true",
},
)

config_setting(
name = "avx512_and_avx2_requested",
define_values = {
"qsim_avx512": "true",
"qsim_avx2": "true",
},
)

config_setting(
name = "avx_all_requested",
define_values = {
"qsim_avx": "true",
"qsim_avx2": "true",
"qsim_avx512": "true",
},
)

config_setting(
name = "avx_and_sse_requested",
define_values = {
"qsim_avx": "true",
"qsim_sse": "true",
},
)

config_setting(
name = "sse_requested",
values = {"define": "qsim_sse=true"},
)

config_setting(
name = "native_requested",
values = {"define": "qsim_native=true"},
)
17 changes: 7 additions & 10 deletions apps/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,15 @@

# TODO: remove reliance on getopt (unistd.h) to allow apps to run on Windows.

load("@local_compiler_config//:compiler_config.bzl", "SUPPORTS_GSFRAME")
load("@rules_cc//cc:defs.bzl", "cc_binary")
load("//dev_tools:bazel_utils.bzl", "qsim_select_copts")

gsframe_copts = select({
"@platforms//os:linux": ["-Wa,--gsframe=no"] if SUPPORTS_GSFRAME else [],
"//conditions:default": [],
})
qsim_copts = qsim_select_copts(target_level = "avx")

cc_binary(
name = "qsim_base",
srcs = ["qsim_base.cc"],
copts = gsframe_copts,
copts = qsim_copts,
data = ["//circuits:circuit_q24"],
deps = [
"//lib:run_qsim_lib",
Expand All @@ -35,7 +32,7 @@ cc_binary(
cc_binary(
name = "qsim_von_neumann",
srcs = ["qsim_von_neumann.cc"],
copts = gsframe_copts,
copts = qsim_copts,
deps = [
"//lib:run_qsim_lib",
],
Expand All @@ -44,7 +41,7 @@ cc_binary(
cc_binary(
name = "qsim_amplitudes",
srcs = ["qsim_amplitudes.cc"],
copts = gsframe_copts,
copts = qsim_copts,
deps = [
"//lib:bitstring",
"//lib:run_qsim_lib",
Expand All @@ -54,7 +51,7 @@ cc_binary(
cc_binary(
name = "qsimh_base",
srcs = ["qsimh_base.cc"],
copts = gsframe_copts,
copts = qsim_copts,
deps = [
"//lib:bitstring",
"//lib:run_qsimh_lib",
Expand All @@ -64,7 +61,7 @@ cc_binary(
cc_binary(
name = "qsimh_amplitudes",
srcs = ["qsimh_amplitudes.cc"],
copts = gsframe_copts,
copts = qsim_copts,
deps = [
"//lib:bitstring",
"//lib:run_qsimh_lib",
Expand Down
18 changes: 17 additions & 1 deletion dev_tools/BUILD
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
# Empty BUILD file to make dev_tools a package.
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load(":compiler_probe_test.bzl", "compiler_probe_test_suite")

compiler_probe_test_suite(name = "compiler_probe_tests")
Loading
Loading