Exemple #1
0
    def test_aggregate_nested(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': 'prop:nested',
            '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, {
                'loop.id': 'A',
                'function': 'foo',
                'count': '6'
            }))
        self.assertTrue(
            calitest.has_snapshot_with_attributes(snapshots, {
                'loop.id': 'B',
                'function': 'foo',
                'count': '4'
            }))
Exemple #2
0
    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 = 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': 'initialization',
                'phase': 'initialization'
            }))
        self.assertTrue(
            calitest.has_snapshot_with_attributes(snapshots, {
                'event.end#iteration': '3',
                'iteration': '3',
                'phase': 'loop'
            }))
Exemple #3
0
    def test_report_caliwriter(self):
        """ Test reader lib's CSV export via report service """

        target_cmd = ['./ci_test_macros']
        query_cmd = [
            '../../src/tools/cali-query/cali-query', '-q',
            'SELECT count(),iteration#fooloop WHERE loop=fooloop GROUP BY iteration#fooloop FORMAT expand'
        ]

        caliper_config = {
            'CALI_SERVICES_ENABLE': 'event,trace,report',
            'CALI_REPORT_CONFIG': 'format cali',
            '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_attributes(snapshots, {
                'iteration#fooloop': '3',
                'count': '4'
            }))
Exemple #4
0
    def test_report_attribute_aliases_in_cali(self):
        """ Test json object layout """

        target_cmd = ['./ci_test_macros']
        query_cmd = [
            '../../src/tools/cali-query/cali-query', '-q',
            'format json(object)'
        ]

        caliper_config = {
            'CALI_SERVICES_ENABLE': 'event,trace,report',
            'CALI_REPORT_FILENAME': 'stdout',
            'CALI_REPORT_CONFIG':
            'select *,count() as CountAlias group by prop:nested format cali',
            'CALI_LOG_VERBOSITY': '0'
        }

        obj = json.loads(
            cat.run_test_with_query(target_cmd, query_cmd, caliper_config))

        self.assertTrue({'records', 'globals',
                         'attributes'}.issubset(set(obj.keys())))

        self.assertIn('count', obj['attributes'])
        self.assertIn('attribute.alias', obj['attributes']['count'])

        self.assertEqual('CountAlias',
                         obj['attributes']['count']['attribute.alias'])
    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' }))
Exemple #6
0
    def test_spot_timeseries(self):
        target_cmd = [
            './ci_test_macros', '0',
            'spot(output=stdout,timeseries,timeseries.iteration_interval=15)',
            '75'
        ]
        query_cmd = [
            '../../src/tools/cali-query/cali-query', '-q',
            'select * where spot.channel=timeseries format json(object)'
        ]

        caliper_config = {
            'CALI_LOG_VERBOSITY': '0',
        }

        obj = json.loads(
            cat.run_test_with_query(target_cmd, query_cmd, caliper_config))

        self.assertIn('globals', obj)
        self.assertIn('records', obj)

        self.assertIn('timeseries', obj['globals']['spot.options'])

        self.assertIn('avg#loop.iterations/time.duration',
                      obj['globals']['spot.timeseries.metrics'])
        self.assertIn('avg#loop.iterations/time.duration', obj['records'][0])
        self.assertEqual(obj['records'][0]['spot.channel'], 'timeseries')

        blocks = []
        for rec in obj['records']:
            blocks.append(int(rec['block']))
        blocks.sort()

        self.assertEqual(blocks, [0, 15, 30, 45, 60])
Exemple #7
0
    def test_jsonobject_pretty(self):
        """ Test json object layout """

        target_cmd = ['./ci_test_macros']
        query_cmd = [
            '../../src/tools/cali-query/cali-query', '-q',
            'SELECT count(),* group by prop:nested where function format json(object,pretty)'
        ]

        caliper_config = {
            'CALI_CONFIG_PROFILE': 'serial-trace',
            'CALI_RECORDER_FILENAME': 'stdout',
            'CALI_LOG_VERBOSITY': '0'
        }

        obj = json.loads(
            cat.run_test_with_query(target_cmd, query_cmd, caliper_config))

        self.assertTrue({'records', 'globals',
                         'attributes'}.issubset(set(obj.keys())))

        self.assertEqual(len(obj['records']), 7)
        self.assertTrue('path' in obj['records'][0].keys())

        self.assertTrue('cali.caliper.version' in obj['globals'].keys())
        self.assertTrue('count' in obj['attributes'].keys())
        self.assertEqual(
            obj['attributes']['cali.caliper.version']['is_global'], True)
Exemple #8
0
    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'
                }))
Exemple #9
0
    def test_ann_metadata(self):
        target_cmd = ['./ci_test_basic']
        query_cmd = [
            '../../src/tools/cali-query/cali-query', '--list-attributes', '-e',
            '--print-attributes',
            'cali.attribute.name,meta.int,cali.attribute.prop'
        ]

        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(
            cat.has_snapshot_with_attributes(
                snapshots,
                {
                    'cali.attribute.name': 'phase',
                    'meta.int': '42',
                    'cali.attribute.prop':
                    '20'  # default property: CALI_ATTR_SCOPE_THREAD
                }))
    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' }))
Exemple #11
0
    def test_largetrace(self):
        target_cmd = ['./ci_test_macros', '0', 'none', '400']
        query_cmd = ['../../src/tools/cali-query/cali-query', '-e']

        caliper_config = {
            'CALI_SERVICES_ENABLE': 'event,trace,report',
            # 'CALI_EVENT_ENABLE_SNAPSHOT_INFO' : 'false',
            'CALI_REPORT_FILENAME': 'stdout',
            'CALI_REPORT_CONFIG':
            'select function,event.end#loop,count() group by function,event.end#loop format cali',
            'CALI_TRACE_BUFFER_SIZE': '1',
            '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_attributes(
                snapshots, {
                    'function': 'main/foo',
                    'event.end#loop': 'fooloop',
                    'count': '400'
                }))
Exemple #12
0
    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'
            }))
Exemple #13
0
    def test_usec_unit_selection(self):
        target_cmd = ['./ci_test_basic']
        query_cmd = [
            '../../src/tools/cali-query/cali-query', '--list-attributes', '-e',
            '--print-attributes', 'cali.attribute.name,time.unit'
        ]

        caliper_config = {
            'CALI_CONFIG_PROFILE': 'serial-trace',
            'CALI_TIMER_SNAPSHOT_DURATION': 'true',
            'CALI_TIMER_UNIT': 'usec',
            '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(
            cat.has_snapshot_with_attributes(snapshots, {
                'cali.attribute.name': 'time.duration',
                'time.unit': 'usec'
            }))
        self.assertTrue(
            cat.has_snapshot_with_attributes(
                snapshots, {
                    'cali.attribute.name': 'time.inclusive.duration',
                    'time.unit': 'usec'
                }))
Exemple #14
0
    def test_default_scope_switch(self):
        target_cmd = ['./ci_test_basic']
        query_cmd = [
            '../../src/tools/cali-query/cali-query', '--list-attributes', '-e',
            '--print-attributes',
            'cali.attribute.name,meta.int,cali.attribute.prop'
        ]

        caliper_config = {
            'CALI_CONFIG_PROFILE': 'serial-trace',
            'CALI_CALIPER_ATTRIBUTE_DEFAULT_SCOPE': 'process',
            '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(
            cat.has_snapshot_with_attributes(
                snapshots,
                {
                    'cali.attribute.name': 'phase',
                    'meta.int': '42',
                    'cali.attribute.prop': '12'  # CALI_ATTR_SCOPE_PROCESS
                }))
        self.assertTrue(
            cat.has_snapshot_with_attributes(
                snapshots,
                {
                    'cali.attribute.name': 'iteration',
                    'cali.attribute.prop':
                    '13'  # CALI_ATTR_SCOPE_PROCESS | CALI_ATTR_ASVALUE
                }))
Exemple #15
0
    def test_spot_controller(self):
        target_cmd = ['./ci_test_mpi_before_cali', 'spot(output=stdout)']
        query_cmd = [
            '../../src/tools/cali-query/cali-query', '-q',
            'format json(object)'
        ]

        caliper_config = {
            'PATH': '/usr/bin',  # for ssh/rsh
            'CALI_LOG_VERBOSITY': '0',
        }

        obj = json.loads(
            cat.run_test_with_query(target_cmd, query_cmd, caliper_config))

        self.assertTrue('globals' in obj)
        self.assertTrue('records' in obj)

        self.assertTrue('spot.format.version' in obj['globals'])
        self.assertTrue('avg#inclusive#sum#time.duration' in obj['globals']
                        ['spot.metrics'])

        r = None
        for rec in obj['records']:
            if 'path' in rec and rec['path'] == 'main':
                r = rec
                break

        self.assertTrue(r is not None, 'No record with "path" entry found')
        self.assertTrue('avg#inclusive#sum#time.duration' in r)
    def test_macros(self):
        target_cmd = [ './ci_test_macros' ]
        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_attributes(
            snapshots, {
                'function'   : 'main',
                'loop'       : 'mainloop',
                'iteration#mainloop' : '3' }))
        self.assertTrue(cat.has_snapshot_with_attributes(
            snapshots, {
                'function'   : 'main/foo',
                'annotation' : 'pre-loop',
                'statement'  : 'foo.init' }))
        self.assertTrue(cat.has_snapshot_with_attributes(
            snapshots, {
                'function'   : 'main/foo',
                'loop'       : 'mainloop/fooloop',
                'iteration#fooloop' : '3' }))
Exemple #17
0
    def test_property_override(self):
        target_cmd = ['./ci_test_macros']
        query_cmd = [
            '../../src/tools/cali-query/cali-query', '-e', '--list-attributes'
        ]

        caliper_config = {
            'CALI_CONFIG_PROFILE': 'serial-trace',
            'CALI_RECORDER_FILENAME': 'stdout',
            'CALI_LOG_VERBOSITY': '0',
            'CALI_CALIPER_ATTRIBUTE_PROPERTIES': 'annotation=process_scope'
        }

        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, {
                    'cali.attribute.name': 'function',
                    'cali.attribute.prop': '20',
                    'cali.attribute.type': 'string'
                }))

        self.assertTrue(
            calitest.has_snapshot_with_attributes(
                snapshots, {
                    'cali.attribute.name': 'annotation',
                    'cali.attribute.prop': '12',
                    'cali.attribute.type': 'string',
                    'class.nested': 'true'
                }))
Exemple #18
0
    def test_macros(self):
        # Use ConfigManager API here
        target_cmd = [ './ci_test_macros', '0', '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(len(snapshots) > 10)

        self.assertTrue(cat.has_snapshot_with_attributes(
            snapshots, {
                'function'   : 'main',
                'loop'       : 'mainloop',
                'iteration#mainloop' : '3' }))
        self.assertTrue(cat.has_snapshot_with_attributes(
            snapshots, {
                'function'   : 'main/foo',
                'annotation' : 'pre-loop',
                'statement'  : 'foo.init' }))
        self.assertTrue(cat.has_snapshot_with_attributes(
            snapshots, {
                'function'   : 'main',
                'annotation' : 'before_loop' }))
        self.assertTrue(cat.has_snapshot_with_attributes(
            snapshots, {
                'function'   : 'main/foo',
                'loop'       : 'mainloop/fooloop',
                'iteration#fooloop' : '3' }))
Exemple #19
0
    def test_cali_before_mpi(self):
        target_cmd = [ './ci_test_cali_before_mpi' ]
        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,mpireport,trace',
            'CALI_MPI_WHITELIST'      : 'all',
            'CALI_MPIREPORT_FILENAME' : 'stdout',
            'CALI_MPIREPORT_CONFIG'   : 'select count() group by function,mpi.function,mpi.rank format cali'
        }

        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',
                         'count'          : '2',
                         'mpi.rank'       : '0'
            }))
        self.assertTrue(cat.has_snapshot_with_attributes(
            snapshots, { 'function' : 'main', 'mpi.function' : 'MPI_Bcast',   'count' : '1' }))
        self.assertTrue(cat.has_snapshot_with_attributes(
            snapshots, { 'function' : 'main', 'mpi.function' : 'MPI_Reduce',  'count' : '1' }))
Exemple #20
0
    def test_esc(self):
        target_cmd = ['./ci_test_basic']
        query_cmd = [
            '../../src/tools/cali-query/cali-query', '-q',
            'select *,count() format json-split'
        ]

        caliper_config = {
            'CALI_CONFIG_PROFILE': 'serial-trace',
            'CALI_RECORDER_FILENAME': 'stdout',
            'CALI_LOG_VERBOSITY': '0'
        }

        obj = json.loads(
            cat.run_test_with_query(target_cmd, query_cmd, caliper_config))

        columns = obj['columns']

        self.assertTrue('event.set# =\\weird ""attribute"=  ' in columns)

        data = obj['data']
        nodes = obj['nodes']

        index = columns.index('event.set# =\\weird ""attribute"=  ')

        self.assertEqual(nodes[data[0][index]]['label'],
                         '  \\\\ weird," name",')
        self.assertEqual(obj[' =\\weird "" global attribute"=  '],
                         '  \\\\ weird," name",')
Exemple #21
0
    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'
            }))
Exemple #22
0
    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' }))
Exemple #23
0
    def test_multichannel_trace(self):
        target_cmd = [ './ci_test_multichannel' ]
        query_cmd  = [ '../../src/tools/cali-query/cali-query', '-e' ]

        caliper_config = {
            'CALI_CONFIG_PROFILE'    : 'serial-trace',
            'CALI_CHANNEL_SNAPSHOT_SCOPES' : 'process,thread,channel',
            '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) >= 205)

        self.assertTrue(cat.has_snapshot_with_attributes(
            snapshots, {'chn.id'       : '1', 
                        'thread'       : 'true' }))
        self.assertTrue(cat.has_snapshot_with_attributes(
            snapshots, {'chn.id'       : '1', 
                        'main'         : 'true' }))
        self.assertTrue(cat.has_snapshot_with_attributes(
            snapshots, {'chn.id'       : '42', 
                        'thread'       : 'true' }))
Exemple #24
0
    def test_c_ann_metadata(self):
        target_cmd = ['./ci_test_c_ann']
        query_cmd = [
            '../../src/tools/cali-query/cali-query', '-e', '--list-attributes'
        ]

        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(
            cat.has_snapshot_with_attributes(snapshots, {
                'cali.attribute.name': 'meta-attr',
                'cali.attribute.type': 'int'
            }))
        self.assertTrue(
            cat.has_snapshot_with_attributes(
                snapshots, {
                    'cali.attribute.name': 'test-attr-with-metadata',
                    'cali.attribute.type': 'string',
                    'meta-attr': '47'
                }))
Exemple #25
0
    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_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'))
Exemple #27
0
    def test_macros(self):
        target_cmd = [ './ci_test_macros' ]
        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_attributes(
            snapshots, {
                'function'   : 'main',
                'loop'       : 'mainloop',
                'iteration#mainloop' : '3' }))
        self.assertTrue(cat.has_snapshot_with_attributes(
            snapshots, {
                'function'   : 'main/foo',
                'annotation' : 'pre-loop',
                'statement'  : 'foo.init' }))
        self.assertTrue(cat.has_snapshot_with_attributes(
            snapshots, {
                'function'   : 'main/foo',
                'loop'       : 'mainloop/fooloop',
                'iteration#fooloop' : '3' }))
Exemple #28
0
    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'
            }))
Exemple #29
0
    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_property_override(self):
        target_cmd = [ './ci_test_macros' ]
        query_cmd  = [ '../../src/tools/cali-query/cali-query', '-e', '--list-attributes' ]

        caliper_config = {
            'CALI_CONFIG_PROFILE'    : 'serial-trace',
            'CALI_RECORDER_FILENAME' : 'stdout',
            'CALI_LOG_VERBOSITY'     : '0',
            'CALI_CALIPER_ATTRIBUTE_PROPERTIES' : 'annotation=process_scope'
        }

        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, {
                'cali.attribute.name' : 'function',
                'cali.attribute.prop' : '276',
                'cali.attribute.type' : 'string' }))

        self.assertTrue(cat.has_snapshot_with_attributes(
            snapshots, {
                'cali.attribute.name' : 'annotation',
                'cali.attribute.prop' : '12',
                'cali.attribute.type' : 'string' }))
Exemple #31
0
    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'))
Exemple #32
0
    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' }))
Exemple #33
0
    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']))
Exemple #34
0
    def test_spot_regionprofile(self):
        target_cmd = ['./ci_test_macros', '0', 'spot(output=stdout)']
        query_cmd = [
            '../../src/tools/cali-query/cali-query', '-q',
            'format json(object)'
        ]

        caliper_config = {
            'CALI_LOG_VERBOSITY': '0',
        }

        obj = json.loads(
            cat.run_test_with_query(target_cmd, query_cmd, caliper_config))

        self.assertIn('globals', obj)
        self.assertIn('records', obj)

        self.assertIn('spot.format.version', obj['globals'])
        self.assertIn('avg#inclusive#sum#time.duration',
                      obj['globals']['spot.metrics'])
        self.assertIn('min#inclusive#sum#time.duration',
                      obj['globals']['spot.metrics'])
        self.assertIn('max#inclusive#sum#time.duration',
                      obj['globals']['spot.metrics'])
        self.assertIn('sum#inclusive#sum#time.duration',
                      obj['globals']['spot.metrics'])
        self.assertIn('avg#inclusive#sum#time.duration', obj['attributes'])
        self.assertIn('min#inclusive#sum#time.duration', obj['attributes'])
        self.assertIn('max#inclusive#sum#time.duration', obj['attributes'])
        self.assertIn('sum#inclusive#sum#time.duration', obj['attributes'])
        self.assertIn('attribute.alias',
                      obj['attributes']['avg#inclusive#sum#time.duration'])
        self.assertIn('attribute.unit',
                      obj['attributes']['avg#inclusive#sum#time.duration'])

        self.assertEqual(
            'Avg time/rank', obj['attributes']
            ['avg#inclusive#sum#time.duration']['attribute.alias'])
        self.assertEqual(
            'sec', obj['attributes']['avg#inclusive#sum#time.duration']
            ['attribute.unit'])

        r = None
        for rec in obj['records']:
            if 'path' in rec and rec['path'] == 'main':
                r = rec
                break

        self.assertTrue(r is not None, 'No record with "path" entry found')
        self.assertIn('avg#inclusive#sum#time.duration', r)
        self.assertIn('min#inclusive#sum#time.duration', r)
        self.assertIn('max#inclusive#sum#time.duration', r)
        self.assertIn('sum#inclusive#sum#time.duration', r)
        self.assertEqual(r['spot.channel'], 'regionprofile')
    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' }))
Exemple #36
0
    def test_jsontree(self):
        """ Test basic json-tree formatter """

        target_cmd = ['./ci_test_macros']
        query_cmd = [
            '../../src/tools/cali-query/cali-query', '-q',
            'SELECT count(),sum(time.inclusive.duration),loop,iteration#main\ loop group by loop,iteration#main\ loop format json-split'
        ]

        caliper_config = {
            'CALI_CONFIG_PROFILE': 'serial-trace',
            'CALI_RECORDER_FILENAME': 'stdout',
            'CALI_LOG_VERBOSITY': '0'
        }

        obj = json.loads(
            cat.run_test_with_query(target_cmd, query_cmd, caliper_config))

        self.assertTrue({'data', 'columns', 'column_metadata',
                         'nodes'}.issubset(set(obj.keys())))

        columns = obj['columns']

        self.assertEqual(
            {
                'path', 'iteration#main loop', 'count',
                'sum#time.inclusive.duration'
            }, set(columns))

        data = obj['data']

        self.assertEqual(len(data), 10)
        self.assertEqual(len(data[0]), 4)

        meta = obj['column_metadata']

        self.assertEqual(len(meta), 4)
        self.assertTrue(meta[columns.index('count')]['is_value'])
        self.assertFalse(meta[columns.index('path')]['is_value'])

        nodes = obj['nodes']

        self.assertEqual(nodes[0]['label'], 'main loop')
        self.assertEqual(nodes[0]['column'], 'path')
        self.assertEqual(nodes[1]['label'], 'fooloop')
        self.assertEqual(nodes[1]['column'], 'path')
        self.assertEqual(nodes[1]['parent'], 0)

        iterindex = columns.index('iteration#main loop')

        # Note: this is a pretty fragile test
        self.assertEqual(data[9][iterindex], 3)
    def test_esc(self):
        target_cmd = [ './ci_test_esc' ]
        query_cmd  = [ '../../src/tools/cali-query/cali-query', '-j' ]

        caliper_config = {
            'CALI_CONFIG_PROFILE'    : 'serial-trace',
            'CALI_RECORDER_FILENAME' : 'stdout',
            'CALI_LOG_VERBOSITY'     : '0'
        }

        obj = json.loads( cat.run_test_with_query(target_cmd, query_cmd, caliper_config) )

        self.assertEqual(obj[0]['event.set# =\\weird ""attribute"=  '], '  \\\\ weird," name",' )
    def test_binding(self):
        target_cmd = [ './ci_test_binding' ]
        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(cat.has_snapshot_with_attributes(
            snapshots, { 'testbinding' : 'binding.nested=outer/binding.nested=inner' }))
Exemple #39
0
    def test_c_ann_snapshot(self):
        target_cmd = [ './ci_test_c_snapshot' ]
        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) >= 4)
        self.assertTrue(calitest.has_snapshot_with_attributes(
            snapshots, {'ci_test_c': 'snapshot', 'string_arg': 'teststring', 'int_arg': '42' }))
    def test_alloc_hooks(self):
        target_cmd = [ './ci_test_alloc_hooks' ]
        query_cmd  = [ '../../src/tools/cali-query/cali-query', '-e' ]

        caliper_config = {
            'CALI_ALLOC_RESOLVE_ADDRESSES' : 'true',
            'CALI_SERVICES_ENABLE'         : 'alloc:recorder:sysalloc:trace',
            'CALI_RECORDER_FILENAME'       : 'stdout',
            'CALI_LOG_VERBOSITY'           : '0'
        }

        query_output = cat.run_test_with_query(target_cmd, query_cmd, caliper_config)
        self.snapshots = cat.get_snapshots_from_text(query_output)

        self.helper_test_hook('malloc')
        self.helper_test_hook('calloc')
        self.helper_test_hook('realloc')
    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' } ) )
Exemple #42
0
    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 test_postprocess_snapshot(self):
        target_cmd = [ './ci_test_postprocess_snapshot' ]
        query_cmd  = [ '../../src/tools/cali-query/cali-query', '-e' ]

        caliper_config = {
            'CALI_SERVICES_ENABLE'   : 'trace:recorder',
            '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(cat.has_snapshot_with_attributes(
            snapshots, {
                'snapshot.val'     : '49',
                'postprocess.val'  : '42',
                'postprocess.node' : '36' }))
    def test_largetrace(self):
        target_cmd = [ './ci_test_loop', '80000' ]
        query_cmd  = [ '../../src/tools/cali-query/cali-query', '-e' ]

        caliper_config = {
            'CALI_SERVICES_ENABLE'   : 'event,trace,report',
            # 'CALI_EVENT_ENABLE_SNAPSHOT_INFO' : 'false',
            'CALI_REPORT_FILENAME'   : 'stdout',
            'CALI_REPORT_CONFIG'     : 'select function,count() group by function format cali',
            'CALI_TRACE_BUFFER_SIZE' : '1',
            '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_attributes(
            snapshots, { 'function' : 'main/foo', 'count' : '80000'}))
    def test_report_caliwriter(self):
        """ Test reader lib's CSV export via report service """
        
        target_cmd = [ './ci_test_macros' ]
        query_cmd  = [ '../../src/tools/cali-query/cali-query',
                       '-q', 'SELECT count(),iteration#fooloop WHERE loop=fooloop GROUP BY iteration#fooloop FORMAT expand' ]

        caliper_config = {
            'CALI_SERVICES_ENABLE'   : 'event,trace,report',
            'CALI_REPORT_CONFIG'     : 'format cali',
            '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_attributes(
            snapshots, { 'iteration#fooloop': '3', 'count': '1' }))
    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' }))
Exemple #47
0
    def test_c_ann_metadata(self):
        target_cmd = [ './ci_test_c_ann' ]
        query_cmd  = [ '../../src/tools/cali-query/cali-query', '-e', '--list-attributes' ]

        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(calitest.has_snapshot_with_attributes(
            snapshots, { 'cali.attribute.name' : 'meta-attr',
                         'cali.attribute.type' : 'int' }))
        self.assertTrue(calitest.has_snapshot_with_attributes(
            snapshots, { 'cali.attribute.name' : 'test-attr-with-metadata',
                         'cali.attribute.type' : 'string',
                         'meta-attr'           : '47' }))
    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'))
Exemple #51
0
    def test_mpi_blacklist(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,mpireport,trace',
            'CALI_MPI_BLACKLIST'      : 'MPI_Barrier,MPI_Reduce',
            'CALI_MPIREPORT_FILENAME' : 'stdout',
            'CALI_MPIREPORT_CONFIG'   : 'select count() group by function,mpi.function format cali'
        }

        query_output = cat.run_test_with_query(target_cmd, query_cmd, caliper_config)
        snapshots = cat.get_snapshots_from_text(query_output)

        self.assertFalse(cat.has_snapshot_with_attributes(
            snapshots, { 'function' : 'main', 'mpi.function' : 'MPI_Barrier' }))
        self.assertTrue(cat.has_snapshot_with_attributes(
            snapshots, { 'function' : 'main', 'mpi.function' : 'MPI_Bcast', 'count' : '1' }))
        self.assertFalse(cat.has_snapshot_with_attributes(
            snapshots, { 'function' : 'main', 'mpi.function' : 'MPI_Reduce'  }))
Exemple #52
0
    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_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:timestamp',
            'CALI_AGGREGATE_KEY'     : 'event.end#function: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, {
                'event.end#function': 'foo', 
                'iteration': '1',
                'count': '3' }))
        self.assertTrue(calitest.has_snapshot_with_attributes(
            snapshots, {
                'event.end#function': 'foo', 
                'iteration': '3',
                'count': '1' }))