Move src/benchmark to src/bench
The current directory and namespace collides quite spectacularly with the google benchmark include directory and namespace. This becomes very hard to work around when there's a .cc file in src/ that wants to include "benchmark/benchmark.h", as MSVC appears to resolve this to the relative path, while GCC and Clang resolve to the compiler specified include directory. Bug: tint:1383 Change-Id: Icc8891718d1d8a1b55c2ac4b2bb1487e8d09e629 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78740 Kokoro: Kokoro <noreply+kokoro@google.com> Auto-Submit: Ben Clayton <bclayton@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
parent
3e80ae68ee
commit
f67b6373a6
|
@ -1160,7 +1160,7 @@ if(TINT_BUILD_BENCHMARKS)
|
|||
endif()
|
||||
|
||||
set(TINT_BENCHMARK_SRC
|
||||
"benchmark/benchmark.cc"
|
||||
"bench/benchmark.cc"
|
||||
"reader/wgsl/parser_bench.cc"
|
||||
)
|
||||
|
||||
|
|
|
@ -12,14 +12,14 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/benchmark/benchmark.h"
|
||||
#include "src/bench/benchmark.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <sstream>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace tint::benchmark {
|
||||
namespace tint::bench {
|
||||
namespace {
|
||||
|
||||
std::filesystem::path kInputFileDir;
|
||||
|
@ -96,8 +96,8 @@ std::variant<tint::Source::File, Error> LoadInputFile(std::string name) {
|
|||
}
|
||||
|
||||
std::variant<ProgramAndFile, Error> LoadProgram(std::string name) {
|
||||
auto res = benchmark::LoadInputFile(name);
|
||||
if (auto err = std::get_if<benchmark::Error>(&res)) {
|
||||
auto res = bench::LoadInputFile(name);
|
||||
if (auto err = std::get_if<bench::Error>(&res)) {
|
||||
return *err;
|
||||
}
|
||||
auto& file = std::get<Source::File>(res);
|
||||
|
@ -108,16 +108,16 @@ std::variant<ProgramAndFile, Error> LoadProgram(std::string name) {
|
|||
return ProgramAndFile{std::move(program), std::move(file)};
|
||||
}
|
||||
|
||||
} // namespace tint::benchmark
|
||||
} // namespace tint::bench
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::benchmark::Initialize(&argc, argv);
|
||||
if (::benchmark::ReportUnrecognizedArguments(argc, argv)) {
|
||||
benchmark::Initialize(&argc, argv);
|
||||
if (benchmark::ReportUnrecognizedArguments(argc, argv)) {
|
||||
return 1;
|
||||
}
|
||||
if (!tint::benchmark::FindBenchmarkInputDir()) {
|
||||
if (!tint::bench::FindBenchmarkInputDir()) {
|
||||
std::cerr << "failed to locate benchmark input files" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
::benchmark::RunSpecifiedBenchmarks();
|
||||
benchmark::RunSpecifiedBenchmarks();
|
||||
}
|
|
@ -12,8 +12,8 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef SRC_BENCHMARK_BENCHMARK_H_
|
||||
#define SRC_BENCHMARK_BENCHMARK_H_
|
||||
#ifndef SRC_BENCH_BENCHMARK_H_
|
||||
#define SRC_BENCH_BENCHMARK_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
@ -23,7 +23,7 @@
|
|||
#include "src/utils/concat.h"
|
||||
#include "tint/tint.h"
|
||||
|
||||
namespace tint::benchmark {
|
||||
namespace tint::bench {
|
||||
|
||||
/// Error indicates an operation did not complete successfully.
|
||||
struct Error {
|
||||
|
@ -71,6 +71,6 @@ std::variant<ProgramAndFile, Error> LoadProgram(std::string name);
|
|||
TINT_BENCHMARK_WGSL_PROGRAM(FUNC, "skinned-shadowed-pbr-fragment.wgsl"); \
|
||||
TINT_BENCHMARK_WGSL_PROGRAM(FUNC, "skinned-shadowed-pbr-vertex.wgsl");
|
||||
|
||||
} // namespace tint::benchmark
|
||||
} // namespace tint::bench
|
||||
|
||||
#endif // SRC_BENCHMARK_BENCHMARK_H_
|
||||
#endif // SRC_BENCH_BENCHMARK_H_
|
|
@ -14,14 +14,14 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "src/benchmark/benchmark.h"
|
||||
#include "src/bench/benchmark.h"
|
||||
|
||||
namespace tint::reader::wgsl {
|
||||
namespace {
|
||||
|
||||
void ParseWGSL(::benchmark::State& state, std::string input_name) {
|
||||
auto res = benchmark::LoadInputFile(input_name);
|
||||
if (auto err = std::get_if<benchmark::Error>(&res)) {
|
||||
void ParseWGSL(benchmark::State& state, std::string input_name) {
|
||||
auto res = bench::LoadInputFile(input_name);
|
||||
if (auto err = std::get_if<bench::Error>(&res)) {
|
||||
state.SkipWithError(err->msg.c_str());
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -15,18 +15,18 @@
|
|||
#include <string>
|
||||
|
||||
#include "src/ast/module.h"
|
||||
#include "src/benchmark/benchmark.h"
|
||||
#include "src/bench/benchmark.h"
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
void GenerateGLSL(::benchmark::State& state, std::string input_name) {
|
||||
auto res = benchmark::LoadProgram(input_name);
|
||||
if (auto err = std::get_if<benchmark::Error>(&res)) {
|
||||
void GenerateGLSL(benchmark::State& state, std::string input_name) {
|
||||
auto res = bench::LoadProgram(input_name);
|
||||
if (auto err = std::get_if<bench::Error>(&res)) {
|
||||
state.SkipWithError(err->msg.c_str());
|
||||
return;
|
||||
}
|
||||
auto& program = std::get<benchmark::ProgramAndFile>(res).program;
|
||||
auto& program = std::get<bench::ProgramAndFile>(res).program;
|
||||
std::vector<std::string> entry_points;
|
||||
for (auto& fn : program.AST().Functions()) {
|
||||
if (fn->IsEntryPoint()) {
|
||||
|
|
|
@ -14,18 +14,18 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "src/benchmark/benchmark.h"
|
||||
#include "src/bench/benchmark.h"
|
||||
|
||||
namespace tint::writer::hlsl {
|
||||
namespace {
|
||||
|
||||
void GenerateHLSL(::benchmark::State& state, std::string input_name) {
|
||||
auto res = benchmark::LoadProgram(input_name);
|
||||
if (auto err = std::get_if<benchmark::Error>(&res)) {
|
||||
void GenerateHLSL(benchmark::State& state, std::string input_name) {
|
||||
auto res = bench::LoadProgram(input_name);
|
||||
if (auto err = std::get_if<bench::Error>(&res)) {
|
||||
state.SkipWithError(err->msg.c_str());
|
||||
return;
|
||||
}
|
||||
auto& program = std::get<benchmark::ProgramAndFile>(res).program;
|
||||
auto& program = std::get<bench::ProgramAndFile>(res).program;
|
||||
for (auto _ : state) {
|
||||
auto res = Generate(&program, {});
|
||||
if (!res.error.empty()) {
|
||||
|
|
|
@ -14,18 +14,18 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "src/benchmark/benchmark.h"
|
||||
#include "src/bench/benchmark.h"
|
||||
|
||||
namespace tint::writer::msl {
|
||||
namespace {
|
||||
|
||||
void GenerateMSL(::benchmark::State& state, std::string input_name) {
|
||||
auto res = benchmark::LoadProgram(input_name);
|
||||
if (auto err = std::get_if<benchmark::Error>(&res)) {
|
||||
void GenerateMSL(benchmark::State& state, std::string input_name) {
|
||||
auto res = bench::LoadProgram(input_name);
|
||||
if (auto err = std::get_if<bench::Error>(&res)) {
|
||||
state.SkipWithError(err->msg.c_str());
|
||||
return;
|
||||
}
|
||||
auto& program = std::get<benchmark::ProgramAndFile>(res).program;
|
||||
auto& program = std::get<bench::ProgramAndFile>(res).program;
|
||||
for (auto _ : state) {
|
||||
auto res = Generate(&program, {});
|
||||
if (!res.error.empty()) {
|
||||
|
|
|
@ -14,18 +14,18 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "src/benchmark/benchmark.h"
|
||||
#include "src/bench/benchmark.h"
|
||||
|
||||
namespace tint::writer::spirv {
|
||||
namespace {
|
||||
|
||||
void GenerateSPIRV(::benchmark::State& state, std::string input_name) {
|
||||
auto res = benchmark::LoadProgram(input_name);
|
||||
if (auto err = std::get_if<benchmark::Error>(&res)) {
|
||||
void GenerateSPIRV(benchmark::State& state, std::string input_name) {
|
||||
auto res = bench::LoadProgram(input_name);
|
||||
if (auto err = std::get_if<bench::Error>(&res)) {
|
||||
state.SkipWithError(err->msg.c_str());
|
||||
return;
|
||||
}
|
||||
auto& program = std::get<benchmark::ProgramAndFile>(res).program;
|
||||
auto& program = std::get<bench::ProgramAndFile>(res).program;
|
||||
for (auto _ : state) {
|
||||
auto res = Generate(&program, {});
|
||||
if (!res.error.empty()) {
|
||||
|
|
|
@ -14,18 +14,18 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "src/benchmark/benchmark.h"
|
||||
#include "src/bench/benchmark.h"
|
||||
|
||||
namespace tint::writer::wgsl {
|
||||
namespace {
|
||||
|
||||
void GenerateWGSL(::benchmark::State& state, std::string input_name) {
|
||||
auto res = benchmark::LoadProgram(input_name);
|
||||
if (auto err = std::get_if<benchmark::Error>(&res)) {
|
||||
void GenerateWGSL(benchmark::State& state, std::string input_name) {
|
||||
auto res = bench::LoadProgram(input_name);
|
||||
if (auto err = std::get_if<bench::Error>(&res)) {
|
||||
state.SkipWithError(err->msg.c_str());
|
||||
return;
|
||||
}
|
||||
auto& program = std::get<benchmark::ProgramAndFile>(res).program;
|
||||
auto& program = std::get<bench::ProgramAndFile>(res).program;
|
||||
for (auto _ : state) {
|
||||
auto res = Generate(&program, {});
|
||||
if (!res.error.empty()) {
|
||||
|
|
Loading…
Reference in New Issue