MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / LoadIntoMemoryFromSo

Method LoadIntoMemoryFromSo

paddle/fluid/framework/data_feed.cc:607–655  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

605
606template <typename T>
607void InMemoryDataFeed<T>::LoadIntoMemoryFromSo() {
608#if (defined _LINUX) && (defined PADDLE_WITH_HETERPS)
609 VLOG(3) << "LoadIntoMemoryFromSo() begin, thread_id=" << thread_id_;
610 int buf_len = 1024 * 1024 * 10;
611 char* buf = reinterpret_cast<char*>(malloc(buf_len + 10));
612 auto ps_gpu_ptr = PSGPUWrapper::GetInstance();
613
614#ifdef PADDLE_WITH_PSLIB
615 paddle::framework::CustomParser* parser =
616 global_dlmanager_pool().Load(so_parser_name_, slot_conf_);
617#endif
618
619 std::string filename;
620 while (this->PickOneFile(&filename)) {
621 VLOG(3) << "PickOneFile, filename=" << filename
622 << ", thread_id=" << thread_id_;
623 platform::Timer timeline;
624 timeline.Start();
625 if (ps_gpu_ptr->UseAfsApi()) {
626#ifdef PADDLE_WITH_PSLIB
627 auto afs_reader = ps_gpu_ptr->OpenReader(filename);
628 int read_len = 0;
629 char* cursor = buf;
630 int remain = 0;
631 while ((read_len = afs_reader->read(cursor, buf_len - remain)) > 0) {
632 std::vector<T> instances;
633 read_len += remain;
634 remain = ParseInstanceFromSo(read_len, buf, &instances, parser);
635 input_channel_->Write(std::move(instances));
636 instances = std::vector<T>();
637 if (remain) {
638 memmove(buf, buf + read_len - remain, remain);
639 }
640 cursor = buf + remain;
641 }
642#endif
643 } else {
644 VLOG(0) << "Should Call InitAfsApi First";
645 }
646
647 timeline.Pause();
648 VLOG(3) << "LoadIntoMemoryFromSo() read all lines, file=" << filename
649 << ", cost time=" << timeline.ElapsedSec()
650 << " seconds, thread_id=" << thread_id_;
651 }
652 free(buf);
653 VLOG(3) << "LoadIntoMemoryFromSo() end, thread_id=" << thread_id_;
654#endif
655}
656
657// explicit instantiation
658template class InMemoryDataFeed<Record>;

Callers

nothing calls this directly

Calls 9

mallocFunction · 0.85
GetInstanceFunction · 0.85
freeFunction · 0.85
PickOneFileMethod · 0.80
PauseMethod · 0.80
ElapsedSecMethod · 0.80
LoadMethod · 0.45
StartMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected