Skip to content

Commit

Permalink
[misc] Remove AotModuleParams::enable_lazy_loading (taichi-dev#7424)
Browse files Browse the repository at this point in the history
Issue: taichi-dev#7002 

### Brief Summary
The member was used by old implementation of offline cache, which is
unnecessary now.
  • Loading branch information
PGZXB authored and quadpixels committed May 13, 2023
1 parent 9807f67 commit d017521
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 43 deletions.
61 changes: 19 additions & 42 deletions taichi/runtime/gfx/aot_module_loader_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,27 @@ class AotModuleImpl : public aot::Module {
liong::json::deserialize(json, ti_aot_data_);
}

if (!params.enable_lazy_loading) {
for (int i = 0; i < ti_aot_data_.kernels.size(); ++i) {
auto k = ti_aot_data_.kernels[i];
std::vector<std::vector<uint32_t>> spirv_sources_codes;
for (int j = 0; j < k.tasks_attribs.size(); ++j) {
std::string spirv_path = k.tasks_attribs[j].name + ".spv";

std::vector<uint32_t> spirv;
dir->load_file(spirv_path, spirv);

if (spirv.size() == 0) {
mark_corrupted();
TI_WARN("spirv '{}' cannot be read", spirv_path);
return;
}
if (spirv.at(0) != 0x07230203) {
TI_WARN("spirv '{}' has a incorrect magic number {}", spirv_path,
spirv.at(0));
}
spirv_sources_codes.emplace_back(std::move(spirv));
for (int i = 0; i < ti_aot_data_.kernels.size(); ++i) {
auto k = ti_aot_data_.kernels[i];
std::vector<std::vector<uint32_t>> spirv_sources_codes;
for (int j = 0; j < k.tasks_attribs.size(); ++j) {
std::string spirv_path = k.tasks_attribs[j].name + ".spv";

std::vector<uint32_t> spirv;
dir->load_file(spirv_path, spirv);

if (spirv.size() == 0) {
mark_corrupted();
TI_WARN("spirv '{}' cannot be read", spirv_path);
return;
}
if (spirv.at(0) != 0x07230203) {
TI_WARN("spirv '{}' has a incorrect magic number {}", spirv_path,
spirv.at(0));
}
ti_aot_data_.spirv_codes.emplace_back(std::move(spirv_sources_codes));
spirv_sources_codes.emplace_back(std::move(spirv));
}
ti_aot_data_.spirv_codes.emplace_back(std::move(spirv_sources_codes));
}

{
Expand Down Expand Up @@ -136,9 +134,6 @@ class AotModuleImpl : public aot::Module {
// AOT, only use the name of the function which should be the first part
// of the struct
if (ti_aot_data_.kernels[i].name.rfind(name, 0) == 0) {
if (!try_load_spv_kernel(i)) {
return false;
}
kernel.kernel_attribs = ti_aot_data_.kernels[i];
kernel.task_spirv_source_codes = ti_aot_data_.spirv_codes[i];
// We don't have to store the number of SNodeTree in |ti_aot_data_| yet,
Expand Down Expand Up @@ -176,24 +171,6 @@ class AotModuleImpl : public aot::Module {
return std::make_unique<FieldImpl>(runtime_, field);
}

bool try_load_spv_kernel(std::size_t index) {
if (index >= ti_aot_data_.spirv_codes.size() ||
ti_aot_data_.spirv_codes[index].empty()) {
ti_aot_data_.spirv_codes.resize(index + 1);
auto &codes = ti_aot_data_.spirv_codes[index];
const auto &k = ti_aot_data_.kernels[index];
for (const auto &t : k.tasks_attribs) {
auto spv = read_spv_file(module_path_, t);
if (spv.empty()) {
mark_corrupted();
return false;
}
codes.push_back(spv);
}
}
return true;
}

static std::vector<uint32_t> read_spv_file(const std::string &output_dir,
const TaskAttributes &k) {
const std::string spv_path = fmt::format("{}/{}.spv", output_dir, k.name);
Expand Down
1 change: 0 additions & 1 deletion taichi/runtime/gfx/aot_module_loader_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ struct TI_DLL_EXPORT AotModuleParams {
std::string module_path{};
const io::VirtualDir *dir{nullptr};
GfxRuntime *runtime{nullptr};
bool enable_lazy_loading{false};

AotModuleParams() = default;

Expand Down

0 comments on commit d017521

Please sign in to comment.