def test_c_ann_trace(self): target_cmd = [ './ci_test_c_ann' ] query_cmd = [ '../../src/tools/cali-query/cali-query', '-e' ] caliper_config = { 'CALI_CONFIG_PROFILE' : 'serial-trace', 'CALI_RECORDER_FILENAME' : 'stdout', 'CALI_LOG_VERBOSITY' : '0' } query_output = calitest.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = calitest.get_snapshots_from_text(query_output) self.assertTrue(len(snapshots) >= 10) self.assertTrue(calitest.has_snapshot_with_keys( snapshots, {'iteration', 'phase', 'time.inclusive.duration'})) self.assertTrue(calitest.has_snapshot_with_attributes( snapshots, {'event.end#phase': 'loop', 'phase': 'loop'})) self.assertTrue(calitest.has_snapshot_with_attributes( snapshots, {'event.end#iteration': '3', 'iteration': '3', 'phase': 'loop'})) self.assertTrue(calitest.has_snapshot_with_keys( snapshots, { 'attr.int', 'attr.dbl', 'attr.str', 'ci_test_c_ann.setbyname' })) self.assertTrue(calitest.has_snapshot_with_attributes( snapshots, { 'attr.int' : '20', 'attr.str' : 'fidibus' })) self.assertTrue(calitest.has_snapshot_with_attributes( snapshots, { 'test-attr-with-metadata' : 'abracadabra' }))
def test_thread(self): target_cmd = [ './ci_test_thread' ] query_cmd = [ '../../src/tools/cali-query/cali-query', '-e' ] caliper_config = { 'CALI_CONFIG_PROFILE' : 'thread-trace', 'CALI_RECORDER_FILENAME' : 'stdout', 'CALI_LOG_VERBOSITY' : '0' } query_output = calitest.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = calitest.get_snapshots_from_text(query_output) self.assertTrue(len(snapshots) >= 20) self.assertTrue(calitest.has_snapshot_with_keys( snapshots, {'local', 'global', 'function'})) self.assertTrue(calitest.has_snapshot_with_keys( snapshots, {'pthread.id', 'my_thread_id', 'global', 'event.end#function'})) self.assertTrue(calitest.has_snapshot_with_attributes( snapshots, {'my_thread_id' : '49', 'function' : 'thread_proc', 'global' : '999' })) self.assertTrue(calitest.has_snapshot_with_attributes( snapshots, { 'function' : 'main', 'local' : '99' }))
def test_c_ann_globals(self): target_cmd = ['./ci_test_c_ann'] query_cmd = [ '../../src/tools/cali-query/cali-query', '-e', '--list-globals' ] caliper_config = { 'CALI_CONFIG_PROFILE': 'serial-trace', 'CALI_RECORDER_FILENAME': 'stdout', 'CALI_LOG_VERBOSITY': '0' } query_output = cat.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = cat.get_snapshots_from_text(query_output) self.assertTrue(len(snapshots) == 1) self.assertTrue( cat.has_snapshot_with_keys( snapshots, { 'global.double', 'global.string', 'global.int', 'global.uint', 'cali.caliper.version' })) self.assertTrue( cat.has_snapshot_with_attributes( snapshots, { 'global.int': '1337', 'global.string': 'my global string', 'global.uint': '42' }))
def test_callpath(self): target_cmd = ['./ci_test_alloc'] query_cmd = ['../../src/tools/cali-query/cali-query', '-e'] caliper_config = { 'CALI_SERVICES_ENABLE': 'callpath,trace,recorder', 'CALI_CALLPATH_USE_NAME': 'true', 'CALI_RECORDER_FILENAME': 'stdout', 'CALI_LOG_VERBOSITY': '0' } query_output = cat.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = cat.get_snapshots_from_text(query_output) self.assertTrue(len(snapshots) == 3) self.assertTrue( cat.has_snapshot_with_keys( snapshots, { 'callpath.address', 'callpath.regname', 'test_alloc.allocated.0', 'function' })) sreg = cat.get_snapshot_with_keys( snapshots, {'callpath.regname', 'test_alloc.allocated.0'}) self.assertTrue('main' in sreg.get('callpath.regname'))
def test_aggregate_value_key(self): target_cmd = ['./ci_test_aggregate'] query_cmd = ['../../src/tools/cali-query/cali-query', '-e'] caliper_config = { 'CALI_SERVICES_ENABLE': 'aggregate:event:recorder', 'CALI_AGGREGATE_KEY': 'iteration', 'CALI_RECORDER_FILENAME': 'stdout', 'CALI_LOG_VERBOSITY': '0' } query_output = calitest.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = calitest.get_snapshots_from_text(query_output) self.assertTrue( calitest.has_snapshot_with_attributes(snapshots, { 'iteration': '1', 'count': '8' })) self.assertTrue( calitest.has_snapshot_with_attributes(snapshots, { 'iteration': '3', 'count': '3' })) self.assertFalse( calitest.has_snapshot_with_keys(snapshots, ['function', 'loop.id']))
def test_aggregate_default(self): target_cmd = ['./ci_test_aggregate'] query_cmd = ['../../src/tools/cali-query/cali-query', '-e'] caliper_config = { 'CALI_SERVICES_ENABLE': 'aggregate:event:recorder:timestamp', 'CALI_TIMER_SNAPSHOT_DURATION': 'true', 'CALI_TIMER_INCLUSIVE_DURATION': 'true', 'CALI_RECORDER_FILENAME': 'stdout', 'CALI_LOG_VERBOSITY': '0' } query_output = calitest.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = calitest.get_snapshots_from_text(query_output) self.assertTrue( calitest.has_snapshot_with_keys(snapshots, [ 'loop.id', 'function', 'sum#time.inclusive.duration', 'min#time.inclusive.duration', 'max#time.inclusive.duration', 'sum#time.duration', 'count' ])) self.assertTrue( calitest.has_snapshot_with_attributes(snapshots, { 'event.end#function': 'foo', 'loop.id': 'A', 'count': '6' })) self.assertTrue( calitest.has_snapshot_with_attributes(snapshots, { 'event.end#function': 'foo', 'loop.id': 'B', 'count': '4' }))
def test_basic_trace(self): target_cmd = ['./ci_test_basic'] query_cmd = ['../../src/tools/cali-query/cali-query', '-e'] caliper_config = { 'CALI_CONFIG_PROFILE': 'serial-trace', 'CALI_RECORDER_FILENAME': 'stdout', 'CALI_LOG_VERBOSITY': '0' } query_output = cat.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = cat.get_snapshots_from_text(query_output) self.assertTrue(len(snapshots) > 10) self.assertTrue( cat.has_snapshot_with_keys( snapshots, {'iteration', 'phase', 'time.inclusive.duration'})) self.assertTrue( cat.has_snapshot_with_attributes(snapshots, { 'event.end#phase': 'initialization', 'phase': 'initialization' })) self.assertTrue( cat.has_snapshot_with_attributes(snapshots, { 'event.end#iteration': '3', 'iteration': '3', 'phase': 'loop' }))
def test_sampler_symbollookup(self): target_cmd = ['./ci_dgemm_memtrack'] query_cmd = ['../../src/tools/cali-query/cali-query', '-e'] caliper_config = { 'CALI_SERVICES_ENABLE': 'sampler:symbollookup:trace:recorder', 'CALI_RECORDER_FILENAME': 'stdout', 'CALI_LOG_VERBOSITY': '0' } query_output = calitest.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = calitest.get_snapshots_from_text(query_output) self.assertTrue(len(snapshots) > 1) self.assertTrue( calitest.has_snapshot_with_keys( snapshots, { 'cali.sampler.pc', 'source.function#cali.sampler.pc', 'source.file#cali.sampler.pc', 'source.line#cali.sampler.pc', 'function' })) sfile = calitest.get_snapshot_with_keys( snapshots, {'source.file#cali.sampler.pc'}) self.assertTrue( 'ci_dgemm_memtrack' in sfile.get('source.file#cali.sampler.pc'))
def test_cali_config(self): # Test the builtin ConfigManager (CALI_CONFIG env var) target_cmd = ['./ci_test_basic'] query_cmd = ['../../src/tools/cali-query/cali-query', '-e'] caliper_config = { 'CALI_LOG_VERBOSITY': '0', 'CALI_CONFIG': 'event-trace,output=stdout' } query_output = cat.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = cat.get_snapshots_from_text(query_output) self.assertTrue(len(snapshots) > 10) self.assertTrue( cat.has_snapshot_with_keys( snapshots, {'iteration', 'phase', 'time.inclusive.duration'})) self.assertTrue( cat.has_snapshot_with_attributes(snapshots, { 'event.end#phase': 'initialization', 'phase': 'initialization' })) self.assertTrue( cat.has_snapshot_with_attributes(snapshots, { 'event.end#iteration': '3', 'iteration': '3', 'phase': 'loop' }))
def test_sampler_symbollookup(self): target_cmd = [ './ci_dgemm_memtrack' ] query_cmd = [ '../../src/tools/cali-query/cali-query', '-e' ] caliper_config = { 'CALI_SERVICES_ENABLE' : 'sampler:symbollookup:trace:recorder', 'CALI_SYMBOLLOOKUP_LOOKUP_FILE' : 'true', 'CALI_SYMBOLLOOKUP_LOOKUP_LINE' : 'true', 'CALI_RECORDER_FILENAME' : 'stdout', 'CALI_LOG_VERBOSITY' : '0' } query_output = calitest.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = calitest.get_snapshots_from_text(query_output) self.assertTrue(len(snapshots) > 1) self.assertTrue(calitest.has_snapshot_with_keys( snapshots, { 'cali.sampler.pc', 'source.function#cali.sampler.pc', 'source.file#cali.sampler.pc', 'source.line#cali.sampler.pc', 'sourceloc#cali.sampler.pc', 'function' })) sfile = calitest.get_snapshot_with_keys(snapshots, { 'source.file#cali.sampler.pc' }) self.assertTrue('ci_dgemm_memtrack' in sfile.get('source.file#cali.sampler.pc'))
def test_ioservice(self): target_cmd = [ './ci_test_io', 'event-trace(trace.io=true),output=stdout' ] query_cmd = ['../../src/tools/cali-query/cali-query', '-e'] caliper_config = {'CALI_LOG_VERBOSITY': '0'} query_output = cat.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = cat.get_snapshots_from_text(query_output) self.assertTrue(len(snapshots) > 1) self.assertTrue( cat.has_snapshot_with_attributes(snapshots, { 'io.bytes.read': '16', 'io.region': 'read', 'function': 'main' })) self.assertTrue( cat.has_snapshot_with_keys(snapshots, { 'io.bytes.read', 'io.region', 'io.filesystem', 'io.mount.point' }))
def test_aggregate_default(self): target_cmd = [ './ci_test_aggregate' ] query_cmd = [ '../../src/tools/cali-query/cali-query', '-e' ] caliper_config = { 'CALI_SERVICES_ENABLE' : 'aggregate:event:recorder:timestamp', 'CALI_TIMER_SNAPSHOT_DURATION' : 'true', 'CALI_TIMER_INCLUSIVE_DURATION' : 'true', 'CALI_RECORDER_FILENAME' : 'stdout', 'CALI_LOG_VERBOSITY' : '0' } query_output = calitest.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = calitest.get_snapshots_from_text(query_output) self.assertTrue(calitest.has_snapshot_with_keys( snapshots, [ 'loop.id', 'function', 'sum#time.inclusive.duration', 'min#time.inclusive.duration', 'max#time.inclusive.duration', 'sum#time.duration', 'count' ] )) self.assertTrue(calitest.has_snapshot_with_attributes( snapshots, { 'event.end#function': 'foo', 'loop.id': 'A', 'count': '6' })) self.assertTrue(calitest.has_snapshot_with_attributes( snapshots, { 'event.end#function': 'foo', 'loop.id': 'B', 'count': '4' }))
def test_sampler_symbollookup(self): target_cmd = [ './ci_test_macros', '5000' ] query_cmd = [ '../../src/tools/cali-query/cali-query', '-e' ] caliper_config = { 'CALI_SERVICES_ENABLE' : 'sampler:symbollookup:trace:recorder', 'CALI_SYMBOLLOOKUP_LOOKUP_FILE' : 'true', 'CALI_SYMBOLLOOKUP_LOOKUP_LINE' : 'true', 'CALI_SYMBOLLOOKUP_LOOKUP_MODULE' : 'true', 'CALI_RECORDER_FILENAME' : 'stdout', 'CALI_LOG_VERBOSITY' : '0' } query_output = cat.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = cat.get_snapshots_from_text(query_output) self.assertTrue(len(snapshots) > 1) self.assertTrue(cat.has_snapshot_with_keys( snapshots, { 'cali.sampler.pc', 'source.function#cali.sampler.pc', 'source.file#cali.sampler.pc', 'source.line#cali.sampler.pc', 'sourceloc#cali.sampler.pc', 'module#cali.sampler.pc', 'function', 'loop' }))
def test_c_ann_trace(self): target_cmd = ['./ci_test_c_ann'] query_cmd = ['../../src/tools/cali-query/cali-query', '-e'] caliper_config = { 'CALI_CONFIG_PROFILE': 'serial-trace', 'CALI_RECORDER_FILENAME': 'stdout', 'CALI_LOG_VERBOSITY': '0' } query_output = cat.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = cat.get_snapshots_from_text(query_output) self.assertTrue(len(snapshots) >= 10) self.assertTrue( cat.has_snapshot_with_keys(snapshots, { 'iteration', 'phase', 'time.inclusive.duration', 'global.int' })) self.assertTrue( cat.has_snapshot_with_attributes(snapshots, { 'event.end#phase': 'loop', 'phase': 'loop' })) self.assertTrue( cat.has_snapshot_with_attributes(snapshots, { 'event.end#iteration': '3', 'iteration': '3', 'phase': 'loop' })) self.assertTrue( cat.has_snapshot_with_keys(snapshots, { 'attr.int', 'attr.dbl', 'attr.str', 'ci_test_c_ann.setbyname' })) self.assertTrue( cat.has_snapshot_with_attributes(snapshots, { 'attr.int': '20', 'attr.str': 'fidibus' })) self.assertTrue( cat.has_snapshot_with_attributes( snapshots, {'test-attr-with-metadata': 'abracadabra'}))
def test_hatchet_sample_profile(self): target_cmd = [ './ci_test_macros', '5000', 'hatchet-sample-profile(output=stdout,output.format=cali)' ] query_cmd = [ '../../src/tools/cali-query/cali-query', '-e' ] caliper_config = { 'CALI_LOG_VERBOSITY' : '0' } query_output = cat.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = cat.get_snapshots_from_text(query_output) self.assertTrue(len(snapshots) > 0) self.assertTrue(cat.has_snapshot_with_keys( snapshots, { 'loop', 'function' }))
def test_spot_controller(self): target_cmd = ['./ci_test_mpi_before_cali', 'spot(output=stdout)'] query_cmd = ['../../src/tools/cali-query/cali-query', '-e'] caliper_config = { 'PATH': '/usr/bin', # for ssh/rsh 'CALI_LOG_VERBOSITY': '0', } query_output = cat.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = cat.get_snapshots_from_text(query_output) self.assertTrue( cat.has_snapshot_with_keys( snapshots, {'function', 'avg#inclusive#sum#time.duration'}))
def test_report_attribute_aliases(self): target_cmd = ['./ci_test_macros'] caliper_config = { 'CALI_SERVICES_ENABLE': 'event,trace,report', 'CALI_REPORT_CONFIG': 'select function as my\\ function\\ alias,count() group by function format expand', 'CALI_LOG_VERBOSITY': '0' } query_output, _ = cat.run_test(target_cmd, caliper_config) snapshots = cat.get_snapshots_from_text(query_output) self.assertTrue( cat.has_snapshot_with_keys(snapshots, {'my function alias', 'count'}))
def test_globals(self): target_cmd = [ './ci_test_basic' ] query_cmd = [ '../../src/tools/cali-query/cali-query', '-e', '--list-globals' ] caliper_config = { 'CALI_CONFIG_PROFILE' : 'serial-trace', 'CALI_RECORDER_FILENAME' : 'stdout', 'CALI_LOG_VERBOSITY' : '0' } query_output = cat.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = cat.get_snapshots_from_text(query_output) self.assertEqual(len(snapshots), 1) self.assertTrue(cat.has_snapshot_with_keys( snapshots, { 'cali.caliper.version' } ) )
def test_globals(self): target_cmd = [ './ci_test_basic' ] query_cmd = [ '../../src/tools/cali-query/cali-query', '-e', '--list-globals' ] caliper_config = { 'CALI_CONFIG_PROFILE' : 'serial-trace', 'CALI_RECORDER_FILENAME' : 'stdout', 'CALI_LOG_VERBOSITY' : '0' } query_output = cat.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = cat.get_snapshots_from_text(query_output) self.assertEqual(len(snapshots), 1) self.assertTrue(cat.has_snapshot_with_keys( snapshots, { 'cali.caliper.version' } ) )
def test_thread(self): target_cmd = ['./ci_test_thread'] query_cmd = ['../../src/tools/cali-query/cali-query', '-e'] caliper_config = { 'CALI_CONFIG_PROFILE': 'thread-trace', 'CALI_RECORDER_FILENAME': 'stdout', 'CALI_LOG_VERBOSITY': '0' } query_output = calitest.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = calitest.get_snapshots_from_text(query_output) self.assertTrue(len(snapshots) >= 20) self.assertTrue( calitest.has_snapshot_with_keys(snapshots, {'local', 'global', 'function'})) self.assertTrue( calitest.has_snapshot_with_keys( snapshots, { 'pthread.id', 'pthread.is_master', 'my_thread_id', 'global', 'function' })) self.assertTrue( calitest.has_snapshot_with_attributes( snapshots, { 'my_thread_id': '49', 'pthread.is_master': 'false', 'function': 'thread_proc', 'global': '999' })) self.assertTrue( calitest.has_snapshot_with_attributes(snapshots, { 'function': 'main', 'pthread.is_master': 'true', 'local': '99' })) self.assertTrue( calitest.has_snapshot_with_keys( snapshots, {'pthread.id', 'my_thread_id', 'global', 'pthread_exp'})) self.assertTrue( calitest.has_snapshot_with_keys( snapshots, {'global', 'my_thread_id', 'nopthread_exp'})) self.assertTrue( calitest.has_snapshot_with_keys( snapshots, {'event.set#pthread.id', 'pthread_exp'})) self.assertFalse( calitest.has_snapshot_with_keys( snapshots, {'event.set#pthread.id', 'nopthread_exp'}))
def test_alloc(self): target_cmd = [ './ci_test_alloc' ] query_cmd = [ '../../src/tools/cali-query/cali-query', '-e' ] caliper_config = { 'CALI_SERVICES_ENABLE' : 'alloc:recorder:trace', 'CALI_ALLOC_RESOLVE_ADDRESSES': 'true', 'CALI_RECORDER_FILENAME' : 'stdout', 'CALI_LOG_VERBOSITY' : '0' } query_output = cat.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = cat.get_snapshots_from_text(query_output) self.assertTrue(len(snapshots) == 5) # test allocated.0 self.assertTrue(cat.has_snapshot_with_keys( snapshots, { 'test_alloc.allocated.0', 'ptr_in', 'ptr_out' })) self.assertTrue(cat.has_snapshot_with_attributes( snapshots, {'test_alloc.allocated.0' : 'true', 'alloc.uid#ptr_in' : '1', 'alloc.index#ptr_in' : '0', 'alloc.label#ptr_in' : 'test_alloc_A' })) self.assertFalse(cat.has_snapshot_with_keys( snapshots, { 'test_alloc.allocated.0', 'alloc.uid#ptr_out' })) # test allocated.1 self.assertTrue(cat.has_snapshot_with_keys( snapshots, { 'test_alloc.allocated.1', 'ptr_in', 'ptr_out' })) self.assertTrue(cat.has_snapshot_with_attributes( snapshots, {'test_alloc.allocated.1' : 'true', 'alloc.uid#ptr_in' : '1', 'alloc.index#ptr_in' : '41', 'alloc.label#ptr_in' : 'test_alloc_A' })) self.assertFalse(cat.has_snapshot_with_keys( snapshots, { 'test_alloc.allocated.1', 'alloc.uid#ptr_out' })) # test allocated.freed self.assertTrue(cat.has_snapshot_with_keys( snapshots, { 'test_alloc.freed', 'ptr_in', 'ptr_out' })) self.assertFalse(cat.has_snapshot_with_keys( snapshots, { 'test_alloc.freed', 'alloc.uid#ptr_in' }))
def helper_test_hook(self, hook): # test allocated.0 self.assertTrue(cat.has_snapshot_with_keys( self.snapshots, { 'test_alloc.' + hook + '_hook', 'test_alloc.allocated.0', 'alloc.uid#ptr_in', 'ptr_in', 'ptr_out' })) self.assertTrue(cat.has_snapshot_with_attributes( self.snapshots, {'test_alloc.' + hook + '_hook' : 'true', 'test_alloc.allocated.0' : 'true', 'alloc.index#ptr_in' : '0' })) self.assertFalse(cat.has_snapshot_with_keys( self.snapshots, { 'test_alloc.' + hook + '_hook', 'test_alloc.allocated.0', 'alloc.uid#ptr_out' })) # test allocated.1 self.assertTrue(cat.has_snapshot_with_keys( self.snapshots, { 'test_alloc.' + hook + '_hook', 'test_alloc.allocated.1', 'alloc.uid#ptr_in', 'ptr_in', 'ptr_out' })) index = '41' if hook == 'calloc' else '167' # 41*sizeof(int)-1 self.assertTrue(cat.has_snapshot_with_attributes( self.snapshots, {'test_alloc.' + hook + '_hook' : 'true', 'test_alloc.allocated.1' : 'true', 'alloc.index#ptr_in' : index })) self.assertFalse(cat.has_snapshot_with_keys( self.snapshots, { 'test_alloc.' + hook + '_hook', 'test_alloc.allocated.1', 'alloc.uid#ptr_out' })) # test allocated.freed self.assertTrue(cat.has_snapshot_with_keys( self.snapshots, { 'test_alloc.' + hook + '_hook', 'test_alloc.freed', 'ptr_in', 'ptr_out' })) self.assertFalse(cat.has_snapshot_with_keys( self.snapshots, { 'test_alloc.' + hook + '_hook', 'test_alloc.freed', 'alloc.uid#ptr_in' }))
def test_papi(self): target_cmd = [ './ci_test_basic' ] query_cmd = [ '../../src/tools/cali-query/cali-query', '-e' ] caliper_config = { 'CALI_SERVICES_ENABLE' : 'event:papi:trace:recorder', 'CALI_PAPI_COUNTERS' : 'PAPI_TOT_CYC', 'CALI_RECORDER_FILENAME' : 'stdout', 'CALI_LOG_VERBOSITY' : '0' } query_output = calitest.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = calitest.get_snapshots_from_text(query_output) self.assertTrue(len(snapshots) > 1) self.assertTrue(calitest.has_snapshot_with_keys( snapshots, { 'papi.PAPI_TOT_CYC', 'phase', 'iteration' }))
def helper_test_hook(self, hook): # test allocated.0 self.assertTrue(cat.has_snapshot_with_keys( self.snapshots, { 'test_alloc.' + hook + '_hook', 'test_alloc.allocated.0', 'alloc.uid#ptr_in', 'ptr_in', 'ptr_out' })) self.assertTrue(cat.has_snapshot_with_attributes( self.snapshots, {'test_alloc.' + hook + '_hook' : 'true', 'test_alloc.allocated.0' : 'true', 'alloc.index#ptr_in' : '0' })) self.assertFalse(cat.has_snapshot_with_keys( self.snapshots, { 'test_alloc.' + hook + '_hook', 'test_alloc.allocated.0', 'alloc.uid#ptr_out' })) # test allocated.1 self.assertTrue(cat.has_snapshot_with_keys( self.snapshots, { 'test_alloc.' + hook + '_hook', 'test_alloc.allocated.1', 'alloc.uid#ptr_in', 'ptr_in', 'ptr_out' })) index = '41' if hook == 'calloc' else '167' # 41*sizeof(int)-1 self.assertTrue(cat.has_snapshot_with_attributes( self.snapshots, {'test_alloc.' + hook + '_hook' : 'true', 'test_alloc.allocated.1' : 'true', 'alloc.index#ptr_in' : index })) self.assertFalse(cat.has_snapshot_with_keys( self.snapshots, { 'test_alloc.' + hook + '_hook', 'test_alloc.allocated.1', 'alloc.uid#ptr_out' })) # test allocated.freed self.assertTrue(cat.has_snapshot_with_keys( self.snapshots, { 'test_alloc.' + hook + '_hook', 'test_alloc.freed', 'ptr_in', 'ptr_out' })) self.assertFalse(cat.has_snapshot_with_keys( self.snapshots, { 'test_alloc.' + hook + '_hook', 'test_alloc.freed', 'alloc.uid#ptr_in' }))
def test_alloc(self): target_cmd = [ './ci_test_alloc' ] query_cmd = [ '../../src/tools/cali-query/cali-query', '-e' ] caliper_config = { 'CALI_SERVICES_ENABLE' : 'alloc:recorder:trace', 'CALI_ALLOC_TRACK_RANGES': 'true', 'CALI_RECORDER_FILENAME' : 'stdout', 'CALI_LOG_VERBOSITY' : '0' } query_output = calitest.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = calitest.get_snapshots_from_text(query_output) self.assertTrue(len(snapshots) == 4) # test allocated.0 self.assertTrue(calitest.has_snapshot_with_keys( snapshots, { 'test_alloc.allocated.0', 'ptr_in', 'ptr_out' })) self.assertTrue(calitest.has_snapshot_with_attributes( snapshots, {'test_alloc.allocated.0' : 'true', 'alloc.uid#ptr_in' : '0', 'alloc.index#ptr_in' : '0' })) self.assertFalse(calitest.has_snapshot_with_keys( snapshots, { 'test_alloc.allocated.0', 'alloc.uid#ptr_out' })) # test allocated.1 self.assertTrue(calitest.has_snapshot_with_keys( snapshots, { 'test_alloc.allocated.1', 'ptr_in', 'ptr_out' })) self.assertTrue(calitest.has_snapshot_with_attributes( snapshots, {'test_alloc.allocated.1' : 'true', 'alloc.uid#ptr_in' : '0', 'alloc.index#ptr_in' : '41' })) self.assertFalse(calitest.has_snapshot_with_keys( snapshots, { 'test_alloc.allocated.1', 'alloc.uid#ptr_out' })) # test allocated.freed self.assertTrue(calitest.has_snapshot_with_keys( snapshots, { 'test_alloc.freed', 'ptr_in', 'ptr_out' })) self.assertFalse(calitest.has_snapshot_with_keys( snapshots, { 'test_alloc.freed', 'alloc.uid#ptr_in' }))
def test_f_ann_trace(self): target_cmd = ['./ci_test_f_ann', 'event-trace,output=stdout'] query_cmd = ['../../src/tools/cali-query/cali-query', '-e'] caliper_config = {'CALI_LOG_VERBOSITY': '0'} query_output = cat.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = cat.get_snapshots_from_text(query_output) self.assertTrue( cat.has_snapshot_with_keys( snapshots, {'annotation', 'time.inclusive.duration'})) self.assertTrue( cat.has_snapshot_with_attributes(snapshots, {'annotation': 'main/work'})) self.assertTrue( cat.has_snapshot_with_attributes(snapshots, {'annotation': 'main/foo'}))
def test_memusage(self): target_cmd = [ './ci_test_basic' ] query_cmd = [ '../../src/tools/cali-query/cali-query', '-e' ] caliper_config = { 'CALI_SERVICES_ENABLE' : 'event,memusage,trace,recorder', 'CALI_RECORDER_FILENAME' : 'stdout', 'CALI_LOG_VERBOSITY' : '0' } query_output = calitest.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = calitest.get_snapshots_from_text(query_output) self.assertTrue(len(snapshots) > 1) self.assertTrue(calitest.has_snapshot_with_keys( snapshots, { 'malloc.total.bytes', 'phase', 'iteration' }))
def test_libpfm_sampling(self): target_cmd = [ './ci_dgemm_memtrack' ] query_cmd = [ '../../src/tools/cali-query/cali-query', '-e' ] caliper_config = { 'CALI_SERVICES_ENABLE' : 'event:libpfm:pthread:trace:recorder', 'CALI_LIBPFM_ENABLE_SAMPLING' : 'true', 'CALI_LIBPFM_RECORD_COUNTERS' : 'false', 'CALI_LIBPFM_EVENTS' : 'instructions', 'CALI_RECORDER_FILENAME' : 'stdout', 'CALI_LOG_VERBOSITY' : '0' } query_output = calitest.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = calitest.get_snapshots_from_text(query_output) self.assertTrue(len(snapshots) > 1) self.assertTrue(calitest.has_snapshot_with_keys( snapshots, { 'libpfm.event_sample_name', 'libpfm.ip', 'libpfm.time' }))
def test_ioservice_multichannel_disabled(self): # Enable the IO service in the default config but not in the trace channel. # While I/O regions will be on the shared blackboard, there should be no # I/O event records in the trace channel. target_cmd = [ './ci_test_io', 'event-trace(trace.io=false,output=stdout)' ] query_cmd = [ '../../src/tools/cali-query/cali-query', '-e' ] caliper_config = { 'CALI_LOG_VERBOSITY' : '0', 'CALI_SERVICES_ENABLE' : 'event,io,trace', 'CALI_CHANNEL_CONFIG_CHECK' : 'false' } query_output = cat.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = cat.get_snapshots_from_text(query_output) self.assertTrue(cat.has_snapshot_with_attributes( snapshots, { 'function': 'main' })) self.assertFalse(cat.has_snapshot_with_keys( snapshots, { 'io.region' }))
def test_basic_trace(self): target_cmd = [ './ci_test_basic' ] query_cmd = [ '../../src/tools/cali-query/cali-query', '-e' ] caliper_config = { 'CALI_CONFIG_PROFILE' : 'serial-trace', 'CALI_RECORDER_FILENAME' : 'stdout', 'CALI_LOG_VERBOSITY' : '0' } query_output = cat.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = cat.get_snapshots_from_text(query_output) self.assertTrue(len(snapshots) > 10) self.assertTrue(cat.has_snapshot_with_keys( snapshots, {'iteration', 'phase', 'time.inclusive.duration'})) self.assertTrue(cat.has_snapshot_with_attributes( snapshots, {'event.end#phase': 'initialization', 'phase': 'initialization'})) self.assertTrue(cat.has_snapshot_with_attributes( snapshots, {'event.end#iteration': '3', 'iteration': '3', 'phase': 'loop'}))
def test_libpfm_counting(self): target_cmd = [ './ci_test_basic' ] query_cmd = [ '../../src/tools/cali-query/cali-query', '-e' ] caliper_config = { 'CALI_SERVICES_ENABLE' : 'event:libpfm:trace:recorder', 'CALI_LIBPFM_ENABLE_SAMPLING' : 'false', 'CALI_LIBPFM_RECORD_COUNTERS' : 'true', 'CALI_LIBPFM_EVENTS' : 'cycles', 'CALI_LIBPFM_SAMPLE_PERIOD' : '10000000', 'CALI_LIBPFM_SAMPLE_ATTRIBUTES' : 'ip,time', 'CALI_RECORDER_FILENAME' : 'stdout', 'CALI_LOG_VERBOSITY' : '0' } query_output = calitest.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = calitest.get_snapshots_from_text(query_output) self.assertTrue(len(snapshots) > 1) self.assertTrue(calitest.has_snapshot_with_keys( snapshots, { 'libpfm.counter.cycles', 'phase', 'iteration' }))
def test_callpath(self): target_cmd = [ './ci_test_alloc' ] query_cmd = [ '../../src/tools/cali-query/cali-query', '-e' ] caliper_config = { 'CALI_SERVICES_ENABLE' : 'callpath:trace:recorder:alloc', 'CALI_CALLPATH_USE_NAME' : 'true', 'CALI_RECORDER_FILENAME' : 'stdout', 'CALI_LOG_VERBOSITY' : '0' } query_output = cat.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = cat.get_snapshots_from_text(query_output) self.assertTrue(len(snapshots) == 5) self.assertTrue(cat.has_snapshot_with_keys( snapshots, { 'callpath.address', 'callpath.regname', 'test_alloc.allocated.0', 'function' })) sreg = cat.get_snapshot_with_keys(snapshots, { 'callpath.regname', 'test_alloc.allocated.0' }) self.assertTrue('main/ci_test_alloc' in sreg.get('callpath.regname'))
def test_measurement_template(self): target_cmd = ['./ci_test_basic'] query_cmd = ['../../src/tools/cali-query/cali-query', '-e'] caliper_config = { 'CALI_SERVICES_ENABLE': 'event,measurement_template,trace,recorder', 'CALI_MEASUREMENT_TEMPLATE_NAMES': 'ci_test', 'CALI_RECORDER_FILENAME': 'stdout', 'CALI_LOG_VERBOSITY': '0' } query_output = calitest.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = calitest.get_snapshots_from_text(query_output) self.assertTrue(len(snapshots) > 1) self.assertTrue( calitest.has_snapshot_with_keys( snapshots, {'phase', 'measurement.val.ci_test', 'measurement.ci_test'}))
def test_mpi_msg_trace(self): target_cmd = ['./ci_test_mpi_before_cali'] query_cmd = ['../../src/tools/cali-query/cali-query', '-e'] caliper_config = { 'PATH': '/usr/bin', # for ssh/rsh 'CALI_LOG_VERBOSITY': '0', 'CALI_SERVICES_ENABLE': 'event,mpi,recorder,trace', 'CALI_MPI_MSG_TRACING': 'true', 'CALI_MPI_WHITELIST': 'all', 'CALI_RECORDER_FILENAME': 'stdout' } query_output = cat.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = cat.get_snapshots_from_text(query_output) self.assertTrue( cat.has_snapshot_with_attributes( snapshots, { 'function': 'main', 'mpi.function': 'MPI_Barrier', 'mpi.coll.type': '1', 'mpi.comm.is_world': 'true' })) self.assertTrue( cat.has_snapshot_with_attributes( snapshots, { 'function': 'main', 'mpi.function': 'MPI_Bcast', 'mpi.coll.type': '3', 'mpi.coll.root': '0', 'mpi.comm.is_world': 'true' })) self.assertTrue( cat.has_snapshot_with_keys( snapshots, {'function', 'mpi.function', 'mpi.coll.type', 'mpi.call.id'}))
def test_papi_aggr(self): # PAPI counters should be aggregated target_cmd = [ './ci_test_basic' ] query_cmd = [ '../../src/tools/cali-query/cali-query', '-e' ] caliper_config = { 'CALI_SERVICES_ENABLE' : 'aggregate:event:papi:recorder', 'CALI_AGGREGATE_KEY' : 'phase', 'CALI_PAPI_COUNTERS' : 'PAPI_TOT_CYC', 'CALI_RECORDER_FILENAME' : 'stdout', 'CALI_LOG_VERBOSITY' : '0' } query_output = calitest.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = calitest.get_snapshots_from_text(query_output) self.assertTrue(len(snapshots) > 1) self.assertTrue(calitest.has_snapshot_with_keys( snapshots, { 'sum#papi.PAPI_TOT_CYC', 'min#papi.PAPI_TOT_CYC', 'max#papi.PAPI_TOT_CYC', 'phase' }))
def test_alloc(self): target_cmd = ['./ci_test_alloc'] query_cmd = ['../../src/tools/cali-query/cali-query', '-e'] caliper_config = { 'CALI_SERVICES_ENABLE': 'alloc:recorder:trace:event', 'CALI_EVENT_ENABLE_SNAPSHOT_INFO': 'false', 'CALI_ALLOC_RESOLVE_ADDRESSES': 'true', 'CALI_RECORDER_FILENAME': 'stdout', 'CALI_LOG_VERBOSITY': '0' } query_output = cat.run_test_with_query(target_cmd, query_cmd, caliper_config) snapshots = cat.get_snapshots_from_text(query_output) # test allocated.0 self.assertTrue( cat.has_snapshot_with_keys( snapshots, {'test_alloc.allocated.0', 'ptr_in', 'ptr_out'})) self.assertTrue( cat.has_snapshot_with_attributes( snapshots, { 'test_alloc.allocated.0': 'true', 'alloc.uid#ptr_in': '1', 'alloc.index#ptr_in': '0', 'alloc.label#ptr_in': 'test_alloc_A' })) self.assertFalse( cat.has_snapshot_with_keys( snapshots, {'test_alloc.allocated.0', 'alloc.uid#ptr_out'})) # test allocated.1 self.assertTrue( cat.has_snapshot_with_keys( snapshots, {'test_alloc.allocated.1', 'ptr_in', 'ptr_out'})) self.assertTrue( cat.has_snapshot_with_attributes( snapshots, { 'test_alloc.allocated.1': 'true', 'alloc.uid#ptr_in': '1', 'alloc.index#ptr_in': '41', 'alloc.label#ptr_in': 'test_alloc_A' })) self.assertFalse( cat.has_snapshot_with_keys( snapshots, {'test_alloc.allocated.1', 'alloc.uid#ptr_out'})) # test allocated.freed self.assertTrue( cat.has_snapshot_with_keys( snapshots, {'test_alloc.freed', 'ptr_in', 'ptr_out'})) self.assertFalse( cat.has_snapshot_with_keys( snapshots, {'test_alloc.freed', 'alloc.uid#ptr_in'}))