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

Method TrainFilesWithProfiler

paddle/fluid/framework/hogwild_worker.cc:1235–1350  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1233}
1234
1235void HogwildWorker::TrainFilesWithProfiler() {
1236 platform::SetNumThreads(1);
1237#if defined(PADDLE_WITH_HETERPS) && \
1238 (defined(PADDLE_WITH_NCCL) || defined(PADDLE_WITH_RCCL))
1239 platform::SetDeviceId(thread_id_);
1240#elif defined(PADDLE_WITH_HETERPS) && defined(PADDLE_WITH_XPU_BKCL)
1241 platform::SetXPUDeviceId(thread_id_);
1242#endif
1243 device_reader_->Start();
1244 std::vector<double> op_total_time;
1245 op_total_time.resize(ops_.size());
1246 for (double &op_time : op_total_time) {
1247 op_time = 0.0;
1248 }
1249 platform::Timer timeline;
1250 double total_time = 0.0;
1251 double read_time = 0.0;
1252 int cur_batch = 0;
1253 int batch_cnt = 0;
1254 if (thread_id_ == 0) {
1255 quit_flag_.store(false);
1256 }
1257 g_barrier.wait();
1258
1259 timeline.Start();
1260 uint64_t total_inst = 0;
1261
1262 std::unique_ptr<GarbageCollector> gc = nullptr;
1263 int64_t max_memory_size = GetEagerDeletionThreshold();
1264 if (max_memory_size >= 0) {
1265 gc = CreateGarbageCollector(place_, max_memory_size);
1266 }
1267 bool infer_out_of_ins = false;
1268 while (true) {
1269 cur_batch = device_reader_->Next();
1270 if (cur_batch <= 0 && !infer_out_of_ins) {
1271 break;
1272 }
1273 VLOG(3) << "read a batch in thread " << thread_id_;
1274 timeline.Pause();
1275 read_time += timeline.ElapsedSec();
1276 total_time += timeline.ElapsedSec();
1277 if (infer_out_of_ins) {
1278 for (size_t i = 0; i < ops_.size(); ++i) {
1279 timeline.Start();
1280 auto &op = ops_[i];
1281 VLOG(3) << "Going to run op " << op_names_[i];
1282 if (op->Type() == "c_broadcast") {
1283 op->Run(*thread_scope_, place_);
1284 }
1285 VLOG(3) << "Op " << op_names_[i] << " Finished";
1286 timeline.Pause();
1287 op_total_time[i] += timeline.ElapsedSec();
1288 total_time += timeline.ElapsedSec();
1289 if (gc) {
1290 DeleteUnusedTensors(*thread_scope_, op.get(), unused_vars_, gc.get());
1291 }
1292 }

Callers

nothing calls this directly

Calls 15

SetNumThreadsFunction · 0.85
CreateGarbageCollectorFunction · 0.85
DeleteUnusedTensorsFunction · 0.85
PauseMethod · 0.80
ElapsedSecMethod · 0.80
c_strMethod · 0.80
DirectClearCallbackMethod · 0.80
DropKidsMethod · 0.80
SetDeviceIdFunction · 0.50
SetXPUDeviceIdFunction · 0.50
StartMethod · 0.45

Tested by

no test coverage detected