Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[aot] Dump required device capability in AOT module meta #6056

Merged
merged 3 commits into from
Sep 14, 2022
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/scripts/aot-demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function prepare-unity-build-env {
cd taichi

# Dependencies
git clone --reference-if-able /var/lib/git-cache https://github.com/taichi-dev/Taichi-UnityExample
git clone --reference-if-able /var/lib/git-cache -b upgrade-modules1 https://github.com/taichi-dev/Taichi-UnityExample

python misc/generate_unity_language_binding.py
cp c_api/unity/*.cs Taichi-UnityExample/Assets/Taichi/Generated
Expand Down
4 changes: 3 additions & 1 deletion taichi/aot/module_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <string>
#include <vector>

#include "taichi/rhi/device.h"
#include "taichi/common/core.h"
#include "taichi/common/serialization.h"

Expand Down Expand Up @@ -120,6 +121,7 @@ struct ModuleData {
std::unordered_map<std::string, CompiledTaichiKernel> kernels;
std::unordered_map<std::string, CompiledTaichiKernel> kernel_tmpls;
std::vector<aot::CompiledFieldData> fields;
std::map<DeviceCapability, uint32_t> required_caps;

size_t root_buffer_size;

Expand All @@ -129,7 +131,7 @@ struct ModuleData {
ts.write_to_file(path);
}

TI_IO_DEF(kernels, kernel_tmpls, fields, root_buffer_size);
TI_IO_DEF(kernels, kernel_tmpls, fields, required_caps, root_buffer_size);
};

} // namespace aot
Expand Down
5 changes: 5 additions & 0 deletions taichi/rhi/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,11 @@ class Device {
dest.set_cap(k, v);
}
}
void clone_caps(std::map<DeviceCapability, uint32_t> &dest) const {
for (const auto &[k, v] : caps_) {
dest[k] = v;
}
}

void print_all_cap() const;

Expand Down
2 changes: 2 additions & 0 deletions taichi/runtime/gfx/aot_module_builder_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class AotDataConverter {
res.kernels[ker.name] = val;
}
res.fields = in.fields;
res.required_caps = in.required_caps;
res.root_buffer_size = in.root_buffer_size;
return res;
}
Expand Down Expand Up @@ -110,6 +111,7 @@ AotModuleBuilderImpl::AotModuleBuilderImpl(
aot_target_device_ =
target_device ? std::move(target_device)
: std::make_unique<aot::TargetDevice>(device_api_backend_);
aot_target_device_->clone_caps(ti_aot_data_.required_caps);
if (!compiled_structs.empty()) {
ti_aot_data_.root_buffer_size = compiled_structs[0].root_size;
}
Expand Down
4 changes: 3 additions & 1 deletion taichi/runtime/gfx/aot_utils.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <vector>
#include <map>

#include "taichi/codegen/spirv/kernel_utils.h"
#include "taichi/aot/module_loader.h"
Expand All @@ -17,9 +18,10 @@ struct TaichiAotData {
std::vector<std::vector<std::vector<uint32_t>>> spirv_codes;
std::vector<spirv::TaichiKernelAttributes> kernels;
std::vector<aot::CompiledFieldData> fields;
std::map<DeviceCapability, uint32_t> required_caps;
size_t root_buffer_size{0};

TI_IO_DEF(kernels, fields, root_buffer_size);
TI_IO_DEF(kernels, fields, required_caps, root_buffer_size);
};

} // namespace gfx
Expand Down