Skip to content

Commit

Permalink
Fixed compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
PENGUINLIONG committed Nov 22, 2022
1 parent 2af13c8 commit 9e80d86
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 20 deletions.
8 changes: 5 additions & 3 deletions c_api/src/taichi_core_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ void ti_destroy_runtime(TiRuntime runtime) {
TI_CAPI_TRY_CATCH_END();
}

void ti_set_runtime_capabilities_ext(TiRuntime runtime, uint32_t capability_count, TiCapabilityLevelInfo* capabilities) {
void ti_set_runtime_capabilities_ext(TiRuntime runtime,
uint32_t capability_count,
const TiCapabilityLevelInfo *capabilities) {
TI_CAPI_TRY_CATCH_BEGIN();
TI_CAPI_ARGUMENT_NULL(runtime);

Expand All @@ -200,7 +202,7 @@ void ti_set_runtime_capabilities_ext(TiRuntime runtime, uint32_t capability_coun
const auto &cap_level_info = capabilities[i];
devcaps.set((taichi::lang::DeviceCapability)cap_level_info.capability, cap_level_info.level);
}
runtime2->get().set_current_caps(std::move(devcaps));
runtime2->get().set_caps(std::move(devcaps));

TI_CAPI_TRY_CATCH_END();
}
Expand All @@ -213,7 +215,7 @@ void ti_get_runtime_capabilities(TiRuntime runtime,

Runtime *runtime2 = (Runtime *)runtime;
const taichi::lang::DeviceCapabilityConfig &devcaps =
runtime2->get().get_current_caps();
runtime2->get().get_caps();

if (capability_count == nullptr) {
return;
Expand Down
2 changes: 1 addition & 1 deletion c_api/src/taichi_gfx_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Error GfxRuntime::create_aot_module(const taichi::io::VirtualDir *dir,
}

const taichi::lang::DeviceCapabilityConfig &current_devcaps =
params.runtime->get_ti_device()->get_current_caps();
params.runtime->get_ti_device()->get_caps();
const taichi::lang::DeviceCapabilityConfig &required_devcaps =
aot_module->get_required_caps();
for (const auto &pair : required_devcaps.devcaps) {
Expand Down
2 changes: 1 addition & 1 deletion c_api/src/taichi_opengl_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ OpenglRuntime::OpenglRuntime()
caps.set(taichi::lang::DeviceCapability::spirv_has_int64, true);
caps.set(taichi::lang::DeviceCapability::spirv_has_float64, true);
caps.set(taichi::lang::DeviceCapability::spirv_version, 0x10300);
get_gl().set_current_caps(std::move(caps));
get_gl().set_caps(std::move(caps));
}
taichi::lang::Device &OpenglRuntime::get() {
return static_cast<taichi::lang::Device &>(device_);
Expand Down
2 changes: 1 addition & 1 deletion c_api/src/taichi_vulkan_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ VulkanRuntimeImported::Workaround::Workaround(
}
*/

vk_device.set_current_caps(std::move(caps));
vk_device.set_caps(std::move(caps));
vk_device.init_vulkan_structs(
const_cast<taichi::lang::vulkan::VulkanDevice::Params &>(params));
}
Expand Down
2 changes: 1 addition & 1 deletion taichi/cache/gfx/cache_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ CompiledKernelData CacheManager::load_or_compile(CompileConfig *config,
if (kernel->is_evaluator) {
spirv::lower(kernel);
return gfx::run_codegen(kernel, runtime_->get_ti_device()->arch(),
runtime_->get_ti_device()->get_current_caps(),
runtime_->get_ti_device()->get_caps(),
compiled_structs_);
}
std::string kernel_key = make_kernel_key(config, kernel);
Expand Down
4 changes: 2 additions & 2 deletions taichi/rhi/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,10 @@ class Device {

// Get all supported capabilities of the current created device.
virtual Arch arch() const = 0;
inline const DeviceCapabilityConfig &get_current_caps() const {
inline const DeviceCapabilityConfig &get_caps() const {
return caps_;
}
inline void set_current_caps(DeviceCapabilityConfig&& caps) {
inline void set_caps(DeviceCapabilityConfig&& caps) {
caps_ = std::move(caps);
}
};
Expand Down
16 changes: 9 additions & 7 deletions taichi/rhi/vulkan/vulkan_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1330,7 +1330,9 @@ struct VulkanDevice::ThreadLocalStreams {
VulkanDevice::VulkanDevice()
: compute_streams_(std::make_unique<ThreadLocalStreams>()),
graphics_streams_(std::make_unique<ThreadLocalStreams>()) {
caps_.set(DeviceCapability::spirv_version, 0x10000);
DeviceCapabilityConfig caps {};
caps.set(DeviceCapability::spirv_version, 0x10000);
set_caps(std::move(caps));
}

void VulkanDevice::init_vulkan_structs(Params &params) {
Expand Down Expand Up @@ -1458,7 +1460,7 @@ DeviceAllocation VulkanDevice::allocate_memory(const AllocParams &params) {
VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;
#endif

bool export_sharing = params.export_sharing && vk_caps_.external_memory;
bool export_sharing = params.export_sharing && vk_caps().external_memory;

VmaAllocationCreateInfo alloc_info{};
if (export_sharing) {
Expand Down Expand Up @@ -1490,7 +1492,7 @@ DeviceAllocation VulkanDevice::allocate_memory(const AllocParams &params) {
alloc_info.requiredFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
}

if (caps_.get(DeviceCapability::spirv_has_physical_storage_buffer)) {
if (get_caps().get(DeviceCapability::spirv_has_physical_storage_buffer)) {
buffer_info.usage |= VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT_KHR;
}

Expand All @@ -1505,7 +1507,7 @@ DeviceAllocation VulkanDevice::allocate_memory(const AllocParams &params) {
handle.alloc_id);
#endif

if (caps_.get(DeviceCapability::spirv_has_physical_storage_buffer)) {
if (get_caps().get(DeviceCapability::spirv_has_physical_storage_buffer)) {
VkBufferDeviceAddressInfoKHR info{};
info.sType = VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO_KHR;
info.buffer = alloc.buffer->buffer;
Expand Down Expand Up @@ -1850,7 +1852,7 @@ DeviceAllocation VulkanDevice::import_vkbuffer(vkapi::IVkBuffer buffer) {
alloc_int.external = true;
alloc_int.buffer = buffer;
alloc_int.mapped = nullptr;
if (caps_.get(DeviceCapability::spirv_has_physical_storage_buffer)) {
if (get_caps().get(DeviceCapability::spirv_has_physical_storage_buffer)) {
VkBufferDeviceAddressInfoKHR info{};
info.sType = VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO;
info.buffer = buffer->buffer;
Expand Down Expand Up @@ -2171,7 +2173,7 @@ vkapi::IVkDescriptorSet VulkanDevice::alloc_desc_set(

void VulkanDevice::create_vma_allocator() {
VmaAllocatorCreateInfo allocatorInfo = {};
allocatorInfo.vulkanApiVersion = vk_caps_.vk_api_version;
allocatorInfo.vulkanApiVersion = vk_caps().vk_api_version;
allocatorInfo.physicalDevice = physical_device_;
allocatorInfo.device = device_;
allocatorInfo.instance = instance_;
Expand Down Expand Up @@ -2223,7 +2225,7 @@ void VulkanDevice::create_vma_allocator() {

allocatorInfo.pVulkanFunctions = &vk_vma_functions;

if (caps_.get(DeviceCapability::spirv_has_physical_storage_buffer)) {
if (get_caps().get(DeviceCapability::spirv_has_physical_storage_buffer)) {
allocatorInfo.flags |= VMA_ALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT;
}

Expand Down
2 changes: 1 addition & 1 deletion taichi/rhi/vulkan/vulkan_device_creator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ void VulkanDeviceCreator::create_logical_device(bool manual_create) {

// Dump capabilities
caps.dbg_print_all();
ti_device_->set_current_caps(std::move(caps));
ti_device_->set_caps(std::move(caps));
}

} // namespace vulkan
Expand Down
2 changes: 1 addition & 1 deletion taichi/runtime/program_impls/dx/dx_program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ FunctionType compile_to_executable(Kernel *kernel,
gfx::GfxRuntime *runtime,
gfx::SNodeTreeManager *snode_tree_mgr) {
auto handle = runtime->register_taichi_kernel(gfx::run_codegen(
kernel, Arch::dx11, runtime->get_ti_device()->get_current_caps(),
kernel, Arch::dx11, runtime->get_ti_device()->get_caps(),
snode_tree_mgr->get_compiled_structs()));
return [runtime, handle](RuntimeContext &ctx) {
runtime->launch_kernel(handle, &ctx);
Expand Down
2 changes: 1 addition & 1 deletion taichi/runtime/program_impls/opengl/opengl_program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const std::unique_ptr<gfx::CacheManager>
params.mode = config->offline_cache ? Mgr::MemAndDiskCache : Mgr::MemCache;
params.cache_path = config->offline_cache_file_path;
params.runtime = runtime_.get();
params.caps = device_->get_current_caps();
params.caps = device_->get_caps();
params.compiled_structs = &snode_tree_mgr_->get_compiled_structs();
cache_manager_ = std::make_unique<gfx::CacheManager>(std::move(params));
}
Expand Down
2 changes: 1 addition & 1 deletion taichi/runtime/program_impls/vulkan/vulkan_program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ const std::unique_ptr<gfx::CacheManager>
params.mode = config->offline_cache ? Mgr::MemAndDiskCache : Mgr::MemCache;
params.cache_path = config->offline_cache_file_path;
params.runtime = vulkan_runtime_.get();
params.caps = embedded_device_->device()->get_current_caps();
params.caps = embedded_device_->device()->get_caps();
params.compiled_structs = &snode_tree_mgr_->get_compiled_structs();
cache_manager_ = std::make_unique<gfx::CacheManager>(std::move(params));
}
Expand Down

0 comments on commit 9e80d86

Please sign in to comment.