Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
58 changes: 36 additions & 22 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# ~~~~ General flags ~~~~

# Common flags
common --announce_rc
common --experimental_repo_remote_exec
common --verbose_failures

Expand All @@ -25,25 +24,20 @@ common --enable_platform_specific_config

build:linux --copt=-std=c++17
build:linux --cxxopt=-std=c++17
build:linux --per_file_copt="googletest/.*@-Xassembler,-W"
build:linux --copt=-O3

build:macos --copt=-std=c++17
build:macos --cxxopt=-std=c++17
build:macos --copt=-O3

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
build:windows --copt=/O2

# 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 All @@ -56,9 +50,11 @@ test --test_timeout=600
# Configs for verbose builds & tests
common:verbose --announce_rc
common:verbose --auto_output_filter=none
build:verbose --show_progress_rate_limit=1
common:verbose --subcommands
test:verbose --test_summary=detailed

# Flags to silence warnings we can't do anything about.
build:linux --per_file_copt="googletest/.*@-Xassembler,-W"

# ~~~~ Sanitizers (choose one, or nosan for none) ~~~~

Expand All @@ -81,23 +77,41 @@ build:msan --linkopt=-fsanitize=leak
build:nosan --


# ~~~~ Instruction set options (choose one) ~~~~
# ~~~~ Instruction set options (can be combined) ~~~~

# Build with AVX
build:avx --define=qsim_avx=true
build:avx --build_tag_filters=
test:avx --test_tag_filters=

# Build with AVX2 + FMA
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 with AVX2
build:avx2 --define=qsim_avx2=true
build:avx2 --build_tag_filters=
test:avx2 --test_tag_filters=

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

# Build with 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 --define=qsim_sse=true
build:sse --build_tag_filters=
test:sse --test_tag_filters=

# Build with BMI
build:bmi --config=bmi2

# Build with BMI2
build:bmi2 --define=qsim_bmi2=true

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

# Build without AVX or SSE
build:basic --copt=-O3
build:basic --


# ~~~~ Parallelization (choose one, or nopenmp for none) ~~~~
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: [avx, sse, native, basic]
# Optimizers for parallelism.
parallel_opt: [openmp, nopenmp]
steps:
Expand Down
76 changes: 76 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# 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_config", "qsim_validate_host")

qsim_validate_host(
name = "validate_host",
visibility = ["//visibility:public"],
)

qsim_print_config(name = "print_config")

# Define configurations for build with AVX, SSE, and BMI 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 = "sse_requested",
values = {"define": "qsim_sse=true"},
)

config_setting(
name = "bmi_requested",
values = {"define": "qsim_bmi=true"},
)

config_setting(
name = "bmi2_requested",
values = {"define": "qsim_bmi2=true"},
)

config_setting(
name = "native_requested",
values = {"define": "qsim_native=true"},
)

config_setting(
name = "native_on_linux",
constraint_values = ["@platforms//os:linux"],
values = {"define": "qsim_native=true"},
)

config_setting(
name = "native_on_macos",
constraint_values = ["@platforms//os:macos"],
values = {"define": "qsim_native=true"},
)

config_setting(
name = "verbose_requested",
values = {"define": "qsim_verbose=true"},
)
33 changes: 5 additions & 28 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,29 +41,9 @@ cc_binary(
cc_binary(
name = "qsim_amplitudes",
srcs = ["qsim_amplitudes.cc"],
copts = gsframe_copts,
copts = qsim_copts,
deps = [
"//lib:bitstring",
"//lib:run_qsim_lib",
],
)

cc_binary(
name = "qsimh_base",
srcs = ["qsimh_base.cc"],
copts = gsframe_copts,
deps = [
"//lib:bitstring",
"//lib:run_qsimh_lib",
],
)

cc_binary(
name = "qsimh_amplitudes",
srcs = ["qsimh_amplitudes.cc"],
copts = gsframe_copts,
deps = [
"//lib:bitstring",
"//lib:run_qsimh_lib",
],
)
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