From 8ebe32b69b6cc7bb35466ffdb757bbc3d5236093 Mon Sep 17 00:00:00 2001 From: Bob Cao Date: Mon, 17 Jun 2024 03:28:03 -0700 Subject: [PATCH] [misc] Bump spdlog version and fix unformattable error (#8543) Issue: # ### Brief Summary copilot:summary ### Walkthrough copilot:walkthrough --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .gitmodules | 8 ++++++++ c_api/tests/c_api_behavior_test.cpp | 22 ++++++++++----------- external/backward_cpp | 2 +- external/spdlog | 2 +- taichi/aot/graph_data.cpp | 2 +- taichi/codegen/spirv/spirv_ir_builder.cpp | 2 +- taichi/common/exceptions.h | 2 +- taichi/common/serialization.h | 16 +++++++-------- taichi/python/export_lang.cpp | 6 ++++-- taichi/rhi/cuda/cuda_profiler.cpp | 2 +- taichi/rhi/device.cpp | 17 ++++++++++++++++ taichi/rhi/dx/dx_device.cpp | 4 ++-- taichi/rhi/public_device.h | 15 ++++++++++++++ taichi/runtime/llvm/llvm_offline_cache.cpp | 2 +- taichi/transforms/ir_printer.cpp | 4 +++- taichi/transforms/make_mesh_block_local.cpp | 2 +- taichi/ui/ggui/app_context.cpp | 2 +- 17 files changed, 77 insertions(+), 33 deletions(-) diff --git a/.gitmodules b/.gitmodules index 5966649751f08..a75c42ea73a85 100644 --- a/.gitmodules +++ b/.gitmodules @@ -65,3 +65,11 @@ [submodule "external/backward_cpp"] path = external/backward_cpp url = https://github.com/bombela/backward-cpp.git +[submodule "./SPIRV-Tools"] + branch = main +[submodule "./SPIRV-Cross"] + branch = main +[submodule "./SPIRV-Headers"] + branch = main +[submodule "./SPIRV-Reflect"] + branch = main diff --git a/c_api/tests/c_api_behavior_test.cpp b/c_api/tests/c_api_behavior_test.cpp index f74fc37ddb5f6..c48c169f99d66 100644 --- a/c_api/tests/c_api_behavior_test.cpp +++ b/c_api/tests/c_api_behavior_test.cpp @@ -28,7 +28,7 @@ TEST_F(CapiTest, TestBehaviorDestroyRuntime) { TEST_F(CapiTest, TestBehaviorGetRuntimeCapabilities) { auto inner = [this](TiArch arch) { if (!ti::is_arch_available(arch)) { - TI_WARN("arch {} is not supported so the test is skipped", arch); + TI_WARN("arch {} is not supported so the test is skipped", int(arch)); return; } @@ -95,7 +95,7 @@ TEST_F(CapiTest, TestBehaviorGetRuntimeCapabilities) { TEST_F(CapiTest, TestBehaviorAllocateMemory) { auto inner = [&](TiArch arch) { if (!ti::is_arch_available(arch)) { - TI_WARN("arch {} is not supported, so this test is skipped", arch); + TI_WARN("arch {} is not supported, so this test is skipped", int(arch)); return; } @@ -141,7 +141,7 @@ TEST_F(CapiTest, TestBehaviorAllocateMemory) { TEST_F(CapiTest, TestBehaviorFreeMemory) { auto inner = [this](TiArch arch) { if (!ti::is_arch_available(arch)) { - TI_WARN("arch {} is not supported, so the test is skipped", arch); + TI_WARN("arch {} is not supported, so the test is skipped", int(arch)); return; } @@ -172,7 +172,7 @@ TEST_F(CapiTest, TestBehaviorFreeMemory) { TEST_F(CapiTest, TestBehaviorMapMemory) { auto inner = [this](TiArch arch) { if (!ti::is_arch_available(arch)) { - TI_WARN("arch {} is not supported, so the test is skipped", arch); + TI_WARN("arch {} is not supported, so the test is skipped", int(arch)); return; } @@ -206,7 +206,7 @@ TEST_F(CapiTest, TestBehaviorMapMemory) { TEST_F(CapiTest, TestBehaviorUnmapMemory) { auto inner = [&](TiArch arch) { if (!ti::is_arch_available(arch)) { - TI_WARN("arch {} is nor supported, so the test is skipped", arch); + TI_WARN("arch {} is nor supported, so the test is skipped", int(arch)); return; } @@ -252,7 +252,7 @@ inline TiImageAllocateInfo make_image_allocate_info() { TEST_F(CapiTest, TestBehaviorAllocateImage) { auto inner = [&](TiArch arch) { if (!ti::is_arch_available(arch)) { - TI_WARN("arch {} is not supported, so the test is skipped", arch); + TI_WARN("arch {} is not supported, so the test is skipped", int(arch)); return; } @@ -305,7 +305,7 @@ TEST_F(CapiTest, TestBehaviorFreeImage) { auto inner = [&](TiArch arch) { // Attemp to free a normal 2D image if (!ti::is_arch_available(arch)) { - TI_WARN("arch {} is not supported, so the test is skipped", arch); + TI_WARN("arch {} is not supported, so the test is skipped", int(arch)); return; } @@ -336,7 +336,7 @@ TEST_F(CapiTest, TestBehaviorFreeImage) { TEST_F(CapiTest, TestBehaviorCopyMemoryDTD) { auto inner = [&](TiArch arch) { if (!ti::is_arch_available(arch)) { - TI_WARN("arch {} is not supported, so the test is skipped", arch); + TI_WARN("arch {} is not supported, so the test is skipped", int(arch)); return; } @@ -390,7 +390,7 @@ TEST_F(CapiTest, TestBehaviorLoadAOTModuleVulkan) { const std::string module_path = folder_dir + std::string("/module.tcm"); if (!ti::is_arch_available(arch)) { - TI_WARN("arch {} is not supported, so the test is skipped", arch); + TI_WARN("arch {} is not supported, so the test is skipped", int(arch)); return; } ti::Runtime runtime(arch); @@ -446,7 +446,7 @@ TEST_F(CapiTest, TestBehaviorDestroyAotModuleVulkan) { const auto folder_dir = getenv("TAICHI_AOT_FOLDER_PATH"); const std::string module_path = folder_dir + std::string("/module.tcm"); if (!ti::is_arch_available(arch)) { - TI_WARN("arch {} is not supported, so the test is skipped", arch); + TI_WARN("arch {} is not supported, so the test is skipped", int(arch)); return; } @@ -463,7 +463,7 @@ TEST_F(CapiTest, TestBehaviorGetCgraphVulkan) { const auto folder_dir = getenv("TAICHI_AOT_FOLDER_PATH"); const std::string module_path = folder_dir; if (!ti::is_arch_available(arch)) { - TI_WARN("arch {} is not supported, so the test is skipped", arch); + TI_WARN("arch {} is not supported, so the test is skipped", int(arch)); return; } diff --git a/external/backward_cpp b/external/backward_cpp index 647eccde8e87d..51f0700452cf7 160000 --- a/external/backward_cpp +++ b/external/backward_cpp @@ -1 +1 @@ -Subproject commit 647eccde8e87d7669be1be8c661e26f1a78a3244 +Subproject commit 51f0700452cf71c57d43c2d028277b24cde32502 diff --git a/external/spdlog b/external/spdlog index cf6f1dd01e660..c3aed4b683739 160000 --- a/external/spdlog +++ b/external/spdlog @@ -1 +1 @@ -Subproject commit cf6f1dd01e660d5865d68bf5fa78f6376b89470a +Subproject commit c3aed4b68373955e1cc94307683d44dca1515d2b diff --git a/taichi/aot/graph_data.cpp b/taichi/aot/graph_data.cpp index 3220e857725da..f77e8fa9599c6 100644 --- a/taichi/aot/graph_data.cpp +++ b/taichi/aot/graph_data.cpp @@ -137,7 +137,7 @@ void CompiledGraph::init_runtime_context( mat->length() * data_type_size(mat->dtype())); ctx.set_arg_matrix(i, *mat); } else { - TI_ERROR("Error in compiled graph: unknown tag {}", ival.tag); + TI_ERROR("Error in compiled graph: unknown tag {}", int(ival.tag)); } } } diff --git a/taichi/codegen/spirv/spirv_ir_builder.cpp b/taichi/codegen/spirv/spirv_ir_builder.cpp index f53be373958cc..8a9a696cf701f 100644 --- a/taichi/codegen/spirv/spirv_ir_builder.cpp +++ b/taichi/codegen/spirv/spirv_ir_builder.cpp @@ -1497,7 +1497,7 @@ Value IRBuilder::get_const(const SType &dtype, } TI_WARN_IF(dtype.flag != TypeKind::kPrimitive, - "Trying to get const with dtype.flag={} , .dt={}", dtype.flag, + "Trying to get const with dtype.flag={} , .dt={}", int(dtype.flag), dtype.dt.to_string()); Value ret = new_value(dtype, ValueKind::kConstant); if (dtype.dt->is_primitive(PrimitiveTypeID::u1)) { diff --git a/taichi/common/exceptions.h b/taichi/common/exceptions.h index 23c656a3d9239..d474a87e7d17c 100644 --- a/taichi/common/exceptions.h +++ b/taichi/common/exceptions.h @@ -60,7 +60,7 @@ class TaichiWarning : public TaichiExceptionImpl { using TaichiExceptionImpl::TaichiExceptionImpl; protected: - static constexpr std::string_view name_; + static constexpr std::string_view name_ = "TaichiWarning"; public: void emit() { diff --git a/taichi/common/serialization.h b/taichi/common/serialization.h index 752272cad1b81..0e43a1c562ee8 100644 --- a/taichi/common/serialization.h +++ b/taichi/common/serialization.h @@ -253,7 +253,7 @@ inline std::vector read_data_from_file(const std::string &fn) { return zip::read(fn); } else { // Read uncompressed file, e.g. particles.tcb - assert(f != nullptr); + TI_ASSERT(f != nullptr); std::size_t length = 0; while (true) { size_t limit = 1 << 8; @@ -278,7 +278,7 @@ inline void write_data_to_file(const std::string &fn, if (f == nullptr) { TI_ERROR("Cannot open file [{}] for writing. (Does the directory exist?)", fn); - assert(f != nullptr); + TI_ASSERT(f != nullptr); } if (ends_with(fn, ".tcb.zip")) { std::fclose(f); @@ -324,7 +324,7 @@ class BinarySerializer : public Serializer { void write_to_file(const std::string &fn) { void *ptr = c_data; if (!ptr) { - assert(!data.empty()); + TI_ASSERT(!data.empty()); ptr = &data[0]; } write_data_to_file(fn, reinterpret_cast(ptr), head); @@ -333,7 +333,7 @@ class BinarySerializer : public Serializer { void write_to_stream(std::ostream &os) { void *ptr = c_data; if (!ptr) { - assert(!data.empty()); + TI_ASSERT(!data.empty()); ptr = &data[0]; } os.write(reinterpret_cast(ptr), head); @@ -349,7 +349,7 @@ class BinarySerializer : public Serializer { TI_TRACE("preserved = {}", preserved_); // Preserved mode this->preserved = preserved_; - assert(c_data != nullptr); + TI_ASSERT(c_data != nullptr); this->c_data = (uint8_t *)c_data; } else { // otherwise use a std::vector @@ -365,11 +365,11 @@ class BinarySerializer : public Serializer { void *raw_data, std::size_t preserved_ = std::size_t(0)) { if (preserved_ != 0) { - assert(raw_data == nullptr); + TI_ASSERT(raw_data == nullptr); data.resize(preserved_); c_data = &data[0]; } else { - assert(raw_data != nullptr); + TI_ASSERT(raw_data != nullptr); c_data = reinterpret_cast(raw_data); } head = sizeof(std::size_t); @@ -389,7 +389,7 @@ class BinarySerializer : public Serializer { *reinterpret_cast(&data[0]) = head; } } else { - assert(head == retrieve_length()); + TI_ASSERT(head == retrieve_length()); } } diff --git a/taichi/python/export_lang.cpp b/taichi/python/export_lang.cpp index 867f4e785a841..390912abe2192 100644 --- a/taichi/python/export_lang.cpp +++ b/taichi/python/export_lang.cpp @@ -677,7 +677,8 @@ void export_lang(py::module &m) { #include "taichi/inc/data_type_with_c_type.inc.h" #undef PER_C_TYPE default: - TI_ERROR("Unsupported scalar type {}", type_id); + TI_ERROR("Unsupported scalar type {}", + expected_dtype->to_string()); } }; @@ -744,7 +745,8 @@ void export_lang(py::module &m) { #include "taichi/inc/data_type_with_c_type.inc.h" #undef PER_C_TYPE default: - TI_ERROR("Unsupported scalar type {}", type_id); + TI_ERROR("Unsupported scalar type {}", + arg.dtype()->to_string()); } } else { TI_NOT_IMPLEMENTED; diff --git a/taichi/rhi/cuda/cuda_profiler.cpp b/taichi/rhi/cuda/cuda_profiler.cpp index 774d462ce8f98..f1c84be5f6cb8 100644 --- a/taichi/rhi/cuda/cuda_profiler.cpp +++ b/taichi/rhi/cuda/cuda_profiler.cpp @@ -29,7 +29,7 @@ ProfilingToolkit get_toolkit_enum(std::string toolkit_name) { bool KernelProfilerCUDA::set_profiler_toolkit(std::string toolkit_name) { sync(); ProfilingToolkit set_toolkit = get_toolkit_enum(toolkit_name); - TI_TRACE("profiler toolkit enum = {} >>> {}", tool_, set_toolkit); + TI_TRACE("profiler toolkit enum = {} >>> {}", int(tool_), int(set_toolkit)); if (set_toolkit == tool_) return true; diff --git a/taichi/rhi/device.cpp b/taichi/rhi/device.cpp index 047fbf8455952..27c0aadb129b8 100644 --- a/taichi/rhi/device.cpp +++ b/taichi/rhi/device.cpp @@ -14,6 +14,23 @@ namespace taichi::lang { +const std::string rhi_result_to_string(RhiResult result) { + switch (result) { + case RhiResult::success: + return "success"; + case RhiResult::error: + return "error"; + case RhiResult::invalid_usage: + return "invalid_usage"; + case RhiResult::not_supported: + return "not_supported"; + case RhiResult::out_of_memory: + return "out_of_memory"; + default: + return "unknown"; + } +} + DeviceAllocationGuard::~DeviceAllocationGuard() { device->dealloc_memory(*this); } diff --git a/taichi/rhi/dx/dx_device.cpp b/taichi/rhi/dx/dx_device.cpp index 98037b95e82a0..d4f964854da9a 100644 --- a/taichi/rhi/dx/dx_device.cpp +++ b/taichi/rhi/dx/dx_device.cpp @@ -406,8 +406,8 @@ HRESULT create_compute_device(ID3D11Device **out_device, #endif if (FAILED(hr) || device == nullptr) { - TI_WARN("Failed to create D3D11 device with type {}: {}\n", driver_type, - driver_type_names[attempt_idx]); + TI_WARN("Failed to create D3D11 device with type {}: {}\n", + int(driver_type), driver_type_names[attempt_idx]); continue; } diff --git a/taichi/rhi/public_device.h b/taichi/rhi/public_device.h index 04297bad872c1..5bd7c3f2e0919 100644 --- a/taichi/rhi/public_device.h +++ b/taichi/rhi/public_device.h @@ -46,6 +46,8 @@ enum class RhiResult { out_of_memory = -4, }; +const std::string rhi_result_to_string(RhiResult result); + constexpr size_t kBufferSizeEntireSize = std::numeric_limits::max(); #define MAKE_ENUM_FLAGS(name) \ @@ -1012,3 +1014,16 @@ class RHI_DLL_EXPORT GraphicsDevice : public Device { }; } // namespace taichi::lang + +template <> +class fmt::formatter { + public: + constexpr auto parse(format_parse_context &ctx) { + return ctx.begin(); + } + template + constexpr auto format(taichi::lang::RhiResult const &res, + Context &ctx) const { + return format_to(ctx.out(), taichi::lang::rhi_result_to_string(res)); + } +}; diff --git a/taichi/runtime/llvm/llvm_offline_cache.cpp b/taichi/runtime/llvm/llvm_offline_cache.cpp index 6e1db919aba9a..907e8ccfa7e83 100644 --- a/taichi/runtime/llvm/llvm_offline_cache.cpp +++ b/taichi/runtime/llvm/llvm_offline_cache.cpp @@ -234,7 +234,7 @@ std::unique_ptr LlvmOfflineCacheFileReader::load_module( } return ret; } - TI_ERROR("Unknown LLVM format={}", format_); + TI_ERROR("Unknown LLVM format={}", int(format_)); return nullptr; } diff --git a/taichi/transforms/ir_printer.cpp b/taichi/transforms/ir_printer.cpp index c1012f0668039..263904cfd40f9 100644 --- a/taichi/transforms/ir_printer.cpp +++ b/taichi/transforms/ir_printer.cpp @@ -104,7 +104,9 @@ class IRPrinter : public IRVisitor { } void visit(FrontendExprStmt *stmt) override { - print("{}", (stmt->val)); + if (stmt->val) { + stmt->val->accept(expr_printer_); + } dbg_info_printer_(stmt); } diff --git a/taichi/transforms/make_mesh_block_local.cpp b/taichi/transforms/make_mesh_block_local.cpp index 5421e07b153ed..cffe4551c93df 100644 --- a/taichi/transforms/make_mesh_block_local.cpp +++ b/taichi/transforms/make_mesh_block_local.cpp @@ -465,7 +465,7 @@ MakeMeshBlockLocal::MakeMeshBlockLocal(OffloadedStmt *offload, break; // not enough space to ensure occupacy } TI_TRACE("available = {}, x = {}, loop_index = {}, unique_access = {}", - available_bytes, cache.total_flags, int(cache.loop_index), + available_bytes, int(cache.total_flags), int(cache.loop_index), cache.unique_accessed); caches->caches.insert(std::make_pair(cache.snode, cache)); } diff --git a/taichi/ui/ggui/app_context.cpp b/taichi/ui/ggui/app_context.cpp index 6d1f12d8d79a7..b1cf07a8330d6 100644 --- a/taichi/ui/ggui/app_context.cpp +++ b/taichi/ui/ggui/app_context.cpp @@ -85,7 +85,7 @@ void AppContext::init_with_vulkan(Program *prog, VkResult result = VK_SUCCESS; if ((result = glfwCreateWindowSurface(instance, window, nullptr, &surface)) != VK_SUCCESS) { - TI_WARN("Failed to create window: error {}", result); + TI_WARN("Failed to create window: error {}", int(result)); return nullptr; } #endif