diff --git a/cmake/TaichiCXXFlags.cmake b/cmake/TaichiCXXFlags.cmake index 79fe36770b646..da3ff8432982a 100644 --- a/cmake/TaichiCXXFlags.cmake +++ b/cmake/TaichiCXXFlags.cmake @@ -46,7 +46,25 @@ else() message("Invalid compiler ${CMAKE_CXX_COMPILER_ID} detected.") message(FATAL_ERROR "clang and MSVC are the only supported compilers for Taichi compiler development. Consider using 'cmake -DCMAKE_CXX_COMPILER=clang' if you are on Linux.") endif() + + # [Global] CXX compilation option to enable all warnings. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall ") + + # [Global] By default, CXX compiler will throw a warning if it decides to ignore an attribute, for example "[[ maybe unused ]]". + # However, this behaviour diverges across different compilers (GCC/CLANG), as well as different compiler versions. + # Therefore we disable such warnings for now. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-ignored-attributes ") + + # [Global] Clang warns if a C++ pointer's nullability wasn't marked explicitly (__nonnull, nullable, ...). + # Nullability seems to be a clang-specific feature, thus we disable this warning. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nullability-completeness ") + + # [Global] Disable warning for unused-private-field for convenience in development. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-private-field ") + + # [Global] By evaluating "constexpr", compiler throws a warning for functions known to be dead at compile time. + # However, some of these "constexpr" are debug flags and will be manually enabled upon debuging. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unneeded-internal-declaration ") endif () message("Building for processor ${CMAKE_SYSTEM_PROCESSOR}") diff --git a/taichi/backends/interop/vulkan_cpu_interop.cpp b/taichi/backends/interop/vulkan_cpu_interop.cpp index 11359dcc2b8bb..126d9eca7e256 100644 --- a/taichi/backends/interop/vulkan_cpu_interop.cpp +++ b/taichi/backends/interop/vulkan_cpu_interop.cpp @@ -22,7 +22,6 @@ void memcpy_cpu_to_vulkan_via_staging(DevicePtr dst, VulkanDevice *vk_dev = dynamic_cast(dst.device); CpuDevice *cpu_dev = dynamic_cast(src.device); - DeviceAllocation dst_alloc(dst); DeviceAllocation src_alloc(src); CpuDevice::AllocInfo src_alloc_info = cpu_dev->get_alloc_info(src_alloc); diff --git a/taichi/backends/vulkan/vulkan_program.cpp b/taichi/backends/vulkan/vulkan_program.cpp index 81184bdd56722..63511189d99fb 100644 --- a/taichi/backends/vulkan/vulkan_program.cpp +++ b/taichi/backends/vulkan/vulkan_program.cpp @@ -71,8 +71,8 @@ FunctionType compile_to_executable(Kernel *kernel, VkRuntime *runtime, SNodeTreeManager *snode_tree_mgr) { auto handle = runtime->register_taichi_kernel( - std::move(run_codegen(kernel, runtime->get_ti_device(), - snode_tree_mgr->get_compiled_structs()))); + run_codegen(kernel, runtime->get_ti_device(), + snode_tree_mgr->get_compiled_structs())); return [runtime, handle](RuntimeContext &ctx) { runtime->launch_kernel(handle, &ctx); }; diff --git a/taichi/backends/vulkan/vulkan_utils.cpp b/taichi/backends/vulkan/vulkan_utils.cpp deleted file mode 100644 index e54133ce0757a..0000000000000 --- a/taichi/backends/vulkan/vulkan_utils.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "taichi/backends/vulkan/vulkan_utils.h" - -#include - -namespace taichi { -namespace lang { -namespace vulkan { -namespace { - -std::vector GetInstanceExtensionProperties() { - constexpr char *kNoLayerName = nullptr; - uint32_t count = 0; - vkEnumerateInstanceExtensionProperties(kNoLayerName, &count, nullptr); - std::vector extensions(count); - vkEnumerateInstanceExtensionProperties(kNoLayerName, &count, - extensions.data()); - return extensions; -} - -std::vector GetDeviceExtensionProperties( - VkPhysicalDevice physicalDevice) { - constexpr char *kNoLayerName = nullptr; - uint32_t count = 0; - vkEnumerateDeviceExtensionProperties(physicalDevice, kNoLayerName, &count, - nullptr); - std::vector extensions(count); - vkEnumerateDeviceExtensionProperties(physicalDevice, kNoLayerName, &count, - extensions.data()); - return extensions; -} - -} // namespace - -} // namespace vulkan -} // namespace lang -} // namespace taichi