MCPcopy Create free account
hub / github.com/NetSys/bess / ComputeMetadataOffsets

Method ComputeMetadataOffsets

core/metadata.cc:443–486  ·  view source on GitHub ↗

Main entry point for calculating metadata offsets. */

Source from the content-addressed store, hash-verified

441
442/* Main entry point for calculating metadata offsets. */
443int Pipeline::ComputeMetadataOffsets() {
444 int ret;
445
446 ret = PrepareMetadataComputation();
447
448 if (ret) {
449 CleanupMetadataComputation();
450 return ret;
451 }
452
453 for (const auto &it : ModuleGraph::GetAllModules()) {
454 Module *m = it.second;
455 if (!m) {
456 break;
457 }
458
459 size_t i = 0;
460 for (const auto &attr : m->all_attrs()) {
461 if (attr.mode == Attribute::AccessMode::kRead ||
462 attr.mode == Attribute::AccessMode::kUpdate) {
463 m->set_attr_offset(i, kMetadataOffsetNoRead);
464 } else if (attr.mode == Attribute::AccessMode::kWrite) {
465 m->set_attr_offset(i, kMetadataOffsetNoWrite);
466 if (attr.scope_id == -1) {
467 IdentifySingleScopeComponent(m, &attr);
468 }
469 }
470 i++;
471 }
472 }
473
474 ComputeScopeDegrees();
475 std::sort(scope_components_.begin(), scope_components_.end(), DegreeComp);
476 AssignOffsets();
477
478 if (VLOG_IS_ON(1)) {
479 LogAllScopes();
480 }
481
482 CheckOrphanReaders();
483
484 CleanupMetadataComputation();
485 return 0;
486}
487
488int Pipeline::RegisterAttribute(const std::string &attr_name, size_t size) {
489 const auto &it = registered_attrs_.find(attr_name);

Callers 2

TEST_FFunction · 0.80
RunMethod · 0.80

Calls 4

CheckOrphanReadersFunction · 0.85
set_attr_offsetMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by 1

TEST_FFunction · 0.64