void ompt_initialize_real(ompt_function_lookup_t lookup, const char* runtime_version, unsigned int /* ompt_version */) { Log(1).stream() << "Initializing OMPT interface with " << runtime_version << endl; Caliper c; // register callbacks if (!::api.init(lookup) || !::register_ompt_callbacks(::config.get("capture_events").to_bool())) { Log(0).stream() << "Callback registration error: OMPT interface disabled" << endl; return; } if (::config.get("capture_state").to_bool() == true) { register_ompt_states(); c.events().snapshot.connect(&snapshot_cb); } // set default thread ID if (::api.get_thread_id) c.set(thread_attr, Variant(static_cast<int>((*api.get_thread_id)()))); Log(1).stream() << "OMPT interface enabled." << endl; }
TEST(AttributeAPITest, GlobalAttributes) { Caliper c; Attribute global_attr = c.create_attribute("test.attribute.global", CALI_TYPE_INT, CALI_ATTR_GLOBAL); ASSERT_NE(global_attr, Attribute::invalid); // global attributes should always have process scope EXPECT_EQ(global_attr.properties() & CALI_ATTR_SCOPE_MASK, CALI_ATTR_SCOPE_PROCESS); // cali.caliper.version should be a global attribute EXPECT_NE(c.get_attribute("cali.caliper.version").properties() & CALI_ATTR_GLOBAL, 0); c.set(global_attr, Variant(42)); std::vector<Entry> globals = c.get_globals(); auto it = std::find_if(globals.begin(), globals.end(), [global_attr](const Entry& e) { return e.count(global_attr) > 0; } ); ASSERT_NE(it, globals.end()); EXPECT_EQ(it->value(global_attr).to_int(), 42); }