MCPcopy Create free account
hub / github.com/a2flo/floor / build_archive

Function build_archive

compute/universal_binary.cpp:658–911  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

656 }
657
658 static bool build_archive(const string& src_input,
659 const bool is_file_input,
660 const string& dst_archive_file_name,
661 const llvm_toolchain::compile_options& options,
662 const vector<target>& targets_in,
663 const bool use_precompiled_header) {
664 // make sure we can open the output file before we start doing anything else
665 file_io archive(dst_archive_file_name, file_io::OPEN_TYPE::WRITE_BINARY);
666 if (!archive.is_open()) {
667 log_error("can't write archive to $", dst_archive_file_name);
668 return false;
669 }
670
671 // ensure targets are unique
672 unordered_set<target> unique_targets_in;
673 unique_targets_in.reserve(targets_in.size());
674 for (const auto& target : targets_in) {
675 unique_targets_in.emplace(target);
676 }
677
678 // create a thread pool of #logical-cpus threads that build all targets
679 const auto target_count = unique_targets_in.size();
680 const auto compile_job_count = uint32_t(min(size_t(core::get_hw_thread_count()), target_count));
681
682 // enqueue + sanitize targets
683 safe_mutex targets_lock;
684 vector<target_v2> targets;
685 deque<pair<size_t, target>> remaining_targets;
686 auto unique_target_iter = unique_targets_in.begin();
687 for (size_t i = 0; i < target_count; ++i, ++unique_target_iter) {
688 auto target = *unique_target_iter;
689 switch (target.common.type) {
690 case COMPUTE_TYPE::NONE:
691 log_error("invalid target type");
692 return false;
693 case COMPUTE_TYPE::OPENCL:
694 target.opencl._unused = 0;
695 break;
696 case COMPUTE_TYPE::CUDA:
697 target.cuda._unused = 0;
698 break;
699 case COMPUTE_TYPE::METAL:
700 target.metal._unused = 0;
701 break;
702 case COMPUTE_TYPE::HOST:
703 target.host._unused = 0;
704 break;
705 case COMPUTE_TYPE::VULKAN:
706 target.vulkan._unused = 0;
707 break;
708 }
709
710 targets.emplace_back(target);
711 remaining_targets.emplace_back(i, target);
712 }
713
714 safe_mutex prog_data_lock;
715 vector<unique_ptr<llvm_toolchain::program_data>> targets_prog_data(target_count);

Callers 2

build_archive_from_fileFunction · 0.85

Calls 15

get_hw_thread_countFunction · 0.85
spawnFunction · 0.85
compile_targetFunction · 0.85
compute_hashFunction · 0.85
is_openMethod · 0.80
reserveMethod · 0.80
emplaceMethod · 0.80
get_filestreamMethod · 0.80
write_blockMethod · 0.80
minFunction · 0.50
to_stringFunction · 0.50

Tested by

no test coverage detected