Profiling with XTC Tools v15.3 Topic is solved

New to XMOS and XCore? Get started here.
lone
New User
Posts: 3
Joined: Wed Apr 23, 2025 5:11 pm

Profiling with XTC Tools v15.3

Post by lone »

Dear Community,

I didn't find anything in the forum, hence the topic.
I'm trying to profile the xcore.ai on the XK-EVK-XU316 board and followed the following two documentations:
- Sample Based Profiling
- How to profile an executable

These are the steps I do:

Code: Select all

xcc -g -Wall -target=XK-EVK-XU316 main.c -o main.xe
xrun --gprof main.xe
xobjdump -s main.xe
xgprof -b image_n0c0_2.elf tile[0]_core0.gprof
If I look at the output, I don't see the amount of calls a function has made, see my screenshots.
Is there a way to change the scale from milliseconds to nanoseconds in case the average execution time of a function is smaller than a ms?
Should I see more or am I seeing all the info there is?

I tried the debug variation too and checked the other cores too, but they didn't have any info.

Attached the two C codes I wanted to profile. If someone could share their output with me or tell me what I'm doing wrong, it would be greatly appreciated.


Thank you in advance for your time, help and feedback.
You do not have the required permissions to view the files attached to this post.
View Solution
CiaranW
Verified
Member
Posts: 9
Joined: Tue Jun 28, 2022 10:58 am

Post by CiaranW »

Hi Lone,

It looks like you're doing everything right, but you have found the limitation with the sample-based profiling we use for hardware.

The process works by periodically polling the 'program counter' on the xcore, via the xtag. We do this without stopping the target, so the program speed is not affected at all.
However this does mean that not much information is extracted. For instance, it is not possible to know the call count via this mechanism. Nor is is possible to know the call stack.

For instance, you can tell that most of your program is in __adddf3, __truncdfsf2 and __extendsfdf2 - these are floating point operations. But we can't tell exactly why - we could assume they were being called inside the 'sin' implementation though.

Also, the 'millisecond' time is not accurate - only the % time is relevant here.

For small examples like this, you can get much more detailed information by using the '--gprof' argument to xsim (much slower though, so will have to decrease the amount of work). For instance, a modified simpleLoop file, run with "xsim --gprof .\simpleLoop.xe", will collect full profiling info.

For instance:

Code: Select all

PS C:\xmos\temp\profiling> xgprof.exe -l -b .\simpleLoop\image_n0c0_2.elf ".\tile[0]_core0.gprof"
Flat profile:

Each sample counts as 1.66667e-06 milliseconds.
  %   cumulative   self              self     total
 time milliseco  millisec    calls   m/call   m/call  name
 23.36      0.95     0.95     2000     0.00     0.00  __adddf3
 19.26      1.73     0.78     2000     0.00     0.00  __truncdfsf2
 17.62      2.45     0.72     4000     0.00     0.00  __extendsfdf2
 11.89      2.93     0.48        1     0.48     4.01  main
 10.65      3.37     0.43     2000     0.00     0.00  __kernel_sin
  9.83      3.77     0.40     2000     0.00     0.00  __fixdfsi
  5.74      4.00     0.23     2000     0.00     0.00  sin
  0.41      4.02     0.02        1     0.02     0.02  __free_threadlocal_timer
  0.41      4.03     0.02                             __ieee754_rem_pio2
  0.41      4.05     0.02                             fabs
  0.05      4.05     0.00        1     0.00     0.01  vfprintf
  0.04      4.05     0.00        4     0.00     0.00  _fflush
  0.03      4.06     0.00       10     0.00     0.00  __lock_recursive_acquire
  0.03      4.06     0.00                             _start
  0.03      4.06     0.00        1     0.00     0.00  _fwalk
  0.03      4.06     0.00        1     0.00     0.00  memchr
  0.02      4.06     0.00       12     0.00     0.33  _startExit
  0.02      4.06     0.00        1     0.00     0.00  __sfvwrite
  0.02      4.06     0.00        1     0.00     0.00  _init
  0.02      4.06     0.00        1     0.00     0.00  _SetupThread
  0.02      4.06     0.00       10     0.00     0.00  __lock_recursive_release
  0.02      4.06     0.00        3     0.00     0.00  std
  0.01      4.06     0.00        1     0.00     0.00  __swsetup
  0.01      4.06     0.00                             _DoException
  0.01      4.07     0.00        1     0.00     0.00  __sinit
  0.01      4.07     0.00        1     0.00     0.00  __malloc
  0.01      4.07     0.00        3     0.00     0.00  __lock_recursive_init
  0.01      4.07     0.00        1     0.00     0.00  __smakebuf
  0.01      4.07     0.00        1     0.00     0.00  __swrite
  0.01      4.07     0.00                             _InitChildThread
  0.00      4.07     0.00                             do_ctors_loop
  0.00      4.07     0.00        1     0.00     0.00  __sprint
  0.00      4.07     0.00        1     0.00     0.01  printf
  0.00      4.07     0.00        2     0.00     0.00  _fini
  0.00      4.07     0.00        1     0.00     0.00  malloc
  0.00      4.07     0.00        1     0.00     0.00  __lock_fair_acquire
  0.00      4.07     0.00        1     0.00     0.00  __libc_done
  0.00      4.07     0.00        1     0.00     0.00  __init_threadlocal_timer
  0.00      4.07     0.00                             do_dtors_end
  0.00      4.07     0.00        3     0.00     0.00  memset
  0.00      4.07     0.00        1     0.00     0.00  __lock_fair_release
  0.00      4.07     0.00        1     0.00     0.00  __sfp_lock_release
  0.00      4.07     0.00        1     0.00     0.00  _write
  0.00      4.07     0.00        1     0.00     0.00  _cleanup_impl
  0.00      4.07     0.00                             _DoSyscallErrno
  0.00      4.07     0.00        1     0.00     0.00  __alloc_libc_hwlock
  0.00      4.07     0.00        1     0.00     0.00  __call_exitprocs
  0.00      4.07     0.00        1     0.00     0.00  __malloc_lock
  0.00      4.07     0.00        1     0.00     0.00  __sfp_lock_acquire
  0.00      4.07     0.00        1     0.00     0.00  _cleanup
  0.00      4.07     0.00        1     0.00     0.00  localeconv
  0.00      4.07     0.00        1     0.00     0.00  __malloc_unlock
  0.00      4.07     0.00        1     0.00     0.00  memmove
  0.00      4.07     0.00                             _TrapHandler
  0.00      4.07     0.00                             _exit_unlocked
  0.00      4.07     0.00                             memcpy
  0.00      4.07     0.00        2     0.00     0.00  _DoSyscall
  0.00      4.07     0.00        1     0.00     0.00  __call_exitprocs_impl
  0.00      4.07     0.00        1     0.00     0.00  _done
  0.00      4.07     0.00                             __errno
  0.00      4.07     0.00                             __floatunsidf
  0.00      4.07     0.00                             __isnand
  0.00      4.07     0.00                             __kernel_rem_pio2
  0.00      4.07     0.00                             __lshrdi3
  0.00      4.07     0.00                             __register_frame_info_bases
  0.00      4.07     0.00                             __sread
  0.00      4.07     0.00                             __udivdi3
  0.00      4.07     0.00                             _exit
  0.00      4.07     0.00                             _get_cmdline
  0.00      4.07     0.00                             _read
  0.00      4.07     0.00                             calloc
  0.00      4.07     0.00                             do_ctors_end
  0.00      4.07     0.00                             do_dtors_loop
  0.00      4.07     0.00                             scalbn
  0.00      4.07     0.00                             strlen


                        Call graph


granularity: each sample hit covers 0 byte(s) for 0.00% of 4.07 seconds

index % time    self  children    called     name
                0.00    0.33       1/12          _TrapHandler [10]
                0.00    3.68      11/12          _start [3]
[1]     98.7    0.00    4.01      12         _startExit [1]
                0.48    3.52       1/1           main [2]
                0.00    0.00       1/1           __libc_done [17]
                0.00    0.00       1/2           _fini [43]
-----------------------------------------------
                0.48    3.52       1/1           _startExit [1]
[2]     98.5    0.48    3.52       1         main [2]
                0.23    0.83    2000/2000        sin [4]
                0.95    0.00    2000/2000        __adddf3 [5]
                0.78    0.00    2000/2000        __truncdfsf2 [7]
                0.72    0.00    4000/4000        __extendsfdf2 [8]
                0.00    0.01       1/1           printf [15]
-----------------------------------------------
                                                 <spontaneous>
[3]     90.5    0.00    3.68                 _start [3]
                0.00    3.68      11/12          _startExit [1]
                0.00    0.00       1/1           _init [29]
                0.00    0.00       1/1           _SetupThread [31]
                0.00    0.00       1/1           __init_threadlocal_timer [46]
                0.00    0.00       3/3           memset [47]
-----------------------------------------------
                0.23    0.83    2000/2000        main [2]
[4]     26.2    0.23    0.83    2000         sin [4]
                0.43    0.40    2000/2000        __kernel_sin [6]
-----------------------------------------------
                0.95    0.00    2000/2000        main [2]
[5]     23.4    0.95    0.00    2000         __adddf3 [5]
-----------------------------------------------
                0.43    0.40    2000/2000        sin [4]
[6]     20.5    0.43    0.40    2000         __kernel_sin [6]
                0.40    0.00    2000/2000        __fixdfsi [9]
-----------------------------------------------
                0.78    0.00    2000/2000        main [2]
[7]     19.3    0.78    0.00    2000         __truncdfsf2 [7]
-----------------------------------------------
                0.72    0.00    4000/4000        main [2]
[8]     17.6    0.72    0.00    4000         __extendsfdf2 [8]
-----------------------------------------------
                0.40    0.00    2000/2000        __kernel_sin [6]
[9]      9.8    0.40    0.00    2000         __fixdfsi [9]
-----------------------------------------------
                                                 <spontaneous>
[10]     8.2    0.00    0.33                 _TrapHandler [10]
                0.00    0.33       1/12          _startExit [1]
-----------------------------------------------
                0.02    0.00       1/1           do_dtors_end [11]
[12]     0.4    0.02    0.00       1         __free_threadlocal_timer [12]
-----------------------------------------------
                                                 <spontaneous>
[13]     0.4    0.02    0.00                 fabs [13]
-----------------------------------------------
                                                 <spontaneous>
[14]     0.4    0.02    0.00                 __ieee754_rem_pio2 [14]
-----------------------------------------------
                0.00    0.01       1/1           main [2]
[15]     0.2    0.00    0.01       1         printf [15]
                0.00    0.01       1/1           vfprintf [16]
-----------------------------------------------
                0.00    0.01       1/1           printf [15]
[16]     0.2    0.00    0.01       1         vfprintf [16]
                0.00    0.00       1/1           __sprint [22]
                0.00    0.00       1/1           __sinit [24]
                0.00    0.00       1/1           __swsetup [26]
                0.00    0.00       1/10          __lock_recursive_acquire [25]
                0.00    0.00       1/10          __lock_recursive_release [32]
                0.00    0.00       1/1           localeconv [52]
-----------------------------------------------
                0.00    0.00       1/1           _startExit [1]
[17]     0.1    0.00    0.00       1         __libc_done [17]
                0.00    0.00       1/1           _cleanup [18]
                0.00    0.00       1/2           _fini [43]
                0.00    0.00       1/1           __call_exitprocs [51]
                0.00    0.00       1/1           _done [56]
-----------------------------------------------
                0.00    0.00       1/1           __libc_done [17]
[18]     0.1    0.00    0.00       1         _cleanup [18]
                0.00    0.00       1/1           _cleanup_impl [19]
-----------------------------------------------
                0.00    0.00       1/1           _cleanup [18]
[19]     0.1    0.00    0.00       1         _cleanup_impl [19]
                0.00    0.00       1/1           _fwalk [20]
-----------------------------------------------
                0.00    0.00       1/1           _cleanup_impl [19]
[20]     0.1    0.00    0.00       1         _fwalk [20]
                0.00    0.00       3/4           _fflush [21]
                0.00    0.00       3/10          __lock_recursive_acquire [25]
                0.00    0.00       3/10          __lock_recursive_release [32]
                0.00    0.00       1/1           __sfp_lock_acquire [40]
                0.00    0.00       1/1           __sfp_lock_release [42]
-----------------------------------------------
                0.00    0.00       1/4           __sfvwrite [23]
                0.00    0.00       3/4           _fwalk [20]
[21]     0.1    0.00    0.00       4         _fflush [21]
                0.00    0.00       4/10          __lock_recursive_acquire [25]
                0.00    0.00       4/10          __lock_recursive_release [32]
                0.00    0.00       1/1           __swrite [36]
-----------------------------------------------
                0.00    0.00       1/1           vfprintf [16]
[22]     0.1    0.00    0.00       1         __sprint [22]
                0.00    0.00       1/1           __sfvwrite [23]
-----------------------------------------------
                0.00    0.00       1/1           __sprint [22]
[23]     0.1    0.00    0.00       1         __sfvwrite [23]
                0.00    0.00       1/1           memchr [27]
                0.00    0.00       1/4           _fflush [21]
                0.00    0.00       1/1           memmove [54]
-----------------------------------------------
                0.00    0.00       1/1           vfprintf [16]
[24]     0.0    0.00    0.00       1         __sinit [24]
                0.00    0.00       3/3           std [28]
                0.00    0.00       1/10          __lock_recursive_acquire [25]
                0.00    0.00       1/10          __lock_recursive_release [32]
-----------------------------------------------
                0.00    0.00       1/10          vfprintf [16]
                0.00    0.00       1/10          __sfp_lock_acquire [40]
                0.00    0.00       1/10          __sinit [24]
                0.00    0.00       3/10          _fwalk [20]
                0.00    0.00       4/10          _fflush [21]
[25]     0.0    0.00    0.00      10         __lock_recursive_acquire [25]
-----------------------------------------------
                0.00    0.00       1/1           vfprintf [16]
[26]     0.0    0.00    0.00       1         __swsetup [26]
                0.00    0.00       1/1           __smakebuf [30]
-----------------------------------------------
                0.00    0.00       1/1           __sfvwrite [23]
[27]     0.0    0.00    0.00       1         memchr [27]
-----------------------------------------------
                0.00    0.00       3/3           __sinit [24]
[28]     0.0    0.00    0.00       3         std [28]
                0.00    0.00       3/3           __lock_recursive_init [37]
-----------------------------------------------
                0.00    0.00       1/1           _start [3]
[29]     0.0    0.00    0.00       1         _init [29]
                0.00    0.00       1/1           __alloc_libc_hwlock [53]
-----------------------------------------------
                0.00    0.00       1/1           __swsetup [26]
[30]     0.0    0.00    0.00       1         __smakebuf [30]
                0.00    0.00       1/1           malloc [33]
-----------------------------------------------
                0.00    0.00       1/1           _start [3]
[31]     0.0    0.00    0.00       1         _SetupThread [31]
-----------------------------------------------
                0.00    0.00       1/10          vfprintf [16]
                0.00    0.00       1/10          __sinit [24]
                0.00    0.00       1/10          __sfp_lock_release [42]
                0.00    0.00       3/10          _fwalk [20]
                0.00    0.00       4/10          _fflush [21]
[32]     0.0    0.00    0.00      10         __lock_recursive_release [32]
-----------------------------------------------
                0.00    0.00       1/1           __smakebuf [30]
[33]     0.0    0.00    0.00       1         malloc [33]
                0.00    0.00       1/1           __malloc [35]
                0.00    0.00       1/1           __malloc_lock [41]
                0.00    0.00       1/1           __malloc_unlock [45]
-----------------------------------------------
                                                 <spontaneous>
[34]     0.0    0.00    0.00                 _DoException [34]
-----------------------------------------------
                0.00    0.00       1/1           malloc [33]
[35]     0.0    0.00    0.00       1         __malloc [35]
-----------------------------------------------
                0.00    0.00       1/1           _fflush [21]
[36]     0.0    0.00    0.00       1         __swrite [36]
                0.00    0.00       1/1           _write [49]
-----------------------------------------------
                0.00    0.00       3/3           std [28]
[37]     0.0    0.00    0.00       3         __lock_recursive_init [37]
-----------------------------------------------
                                                 <spontaneous>
[38]     0.0    0.00    0.00                 _InitChildThread [38]
-----------------------------------------------
                0.00    0.00       1/1           _fwalk [20]
[40]     0.0    0.00    0.00       1         __sfp_lock_acquire [40]
                0.00    0.00       1/10          __lock_recursive_acquire [25]
-----------------------------------------------
                0.00    0.00       1/1           malloc [33]
[41]     0.0    0.00    0.00       1         __malloc_lock [41]
                0.00    0.00       1/1           __lock_fair_acquire [44]
-----------------------------------------------
                0.00    0.00       1/1           _fwalk [20]
[42]     0.0    0.00    0.00       1         __sfp_lock_release [42]
                0.00    0.00       1/10          __lock_recursive_release [32]
-----------------------------------------------
                                   1             _fini [43]
                0.00    0.00       1/2           _startExit [1]
                0.00    0.00       1/2           __libc_done [17]
[43]     0.0    0.00    0.00       2+1       _fini [43]
                                   1             _fini [43]
-----------------------------------------------
                0.00    0.00       1/1           __malloc_lock [41]
[44]     0.0    0.00    0.00       1         __lock_fair_acquire [44]
-----------------------------------------------
                0.00    0.00       1/1           malloc [33]
[45]     0.0    0.00    0.00       1         __malloc_unlock [45]
                0.00    0.00       1/1           __lock_fair_release [48]
-----------------------------------------------
                0.00    0.00       1/1           _start [3]
[46]     0.0    0.00    0.00       1         __init_threadlocal_timer [46]
-----------------------------------------------
                0.00    0.00       3/3           _start [3]
[47]     0.0    0.00    0.00       3         memset [47]
-----------------------------------------------
                0.00    0.00       1/1           __malloc_unlock [45]
[48]     0.0    0.00    0.00       1         __lock_fair_release [48]
-----------------------------------------------
                0.00    0.00       1/1           __swrite [36]
[49]     0.0    0.00    0.00       1         _write [49]
-----------------------------------------------
                                                 <spontaneous>
[50]     0.0    0.00    0.00                 _DoSyscallErrno [50]
                0.00    0.00       1/2           _DoSyscall [58]
-----------------------------------------------
                0.00    0.00       1/1           __libc_done [17]
[51]     0.0    0.00    0.00       1         __call_exitprocs [51]
                0.00    0.00       1/1           __call_exitprocs_impl [59]
-----------------------------------------------
                0.00    0.00       1/1           vfprintf [16]
[52]     0.0    0.00    0.00       1         localeconv [52]
-----------------------------------------------
                0.00    0.00       1/1           _init [29]
[53]     0.0    0.00    0.00       1         __alloc_libc_hwlock [53]
-----------------------------------------------
                0.00    0.00       1/1           __sfvwrite [23]
[54]     0.0    0.00    0.00       1         memmove [54]
-----------------------------------------------
                                                 <spontaneous>
[55]     0.0    0.00    0.00                 memcpy [55]
-----------------------------------------------
                0.00    0.00       1/1           __libc_done [17]
[56]     0.0    0.00    0.00       1         _done [56]
                0.00    0.00       1/2           _DoSyscall [58]
-----------------------------------------------
                                                 <spontaneous>
[57]     0.0    0.00    0.00                 _exit_unlocked [57]
-----------------------------------------------
                0.00    0.00       1/2           _done [56]
                0.00    0.00       1/2           _DoSyscallErrno [50]
[58]     0.0    0.00    0.00       2         _DoSyscall [58]
-----------------------------------------------
                0.00    0.00       1/1           __call_exitprocs [51]
[59]     0.0    0.00    0.00       1         __call_exitprocs_impl [59]
-----------------------------------------------
                                                 <spontaneous>
[60]     0.0    0.00    0.00                 calloc [60]
-----------------------------------------------
                                                 <spontaneous>
[63]     0.0    0.00    0.00                 scalbn [63]
-----------------------------------------------
                                                 <spontaneous>
[64]     0.0    0.00    0.00                 strlen [64]
-----------------------------------------------
                                                 <spontaneous>
[65]     0.0    0.00    0.00                 __errno [65]
-----------------------------------------------
                                                 <spontaneous>
[66]     0.0    0.00    0.00                 __floatunsidf [66]
-----------------------------------------------
                                                 <spontaneous>
[67]     0.0    0.00    0.00                 __isnand [67]
-----------------------------------------------
                                                 <spontaneous>
[68]     0.0    0.00    0.00                 __kernel_rem_pio2 [68]
-----------------------------------------------
                                                 <spontaneous>
[69]     0.0    0.00    0.00                 __lshrdi3 [69]
-----------------------------------------------
                                                 <spontaneous>
[70]     0.0    0.00    0.00                 __register_frame_info_bases [70]
-----------------------------------------------
                                                 <spontaneous>
[71]     0.0    0.00    0.00                 __sread [71]
-----------------------------------------------
                                                 <spontaneous>
[72]     0.0    0.00    0.00                 __udivdi3 [72]
-----------------------------------------------
                                                 <spontaneous>
[73]     0.0    0.00    0.00                 _exit [73]
-----------------------------------------------
                                                 <spontaneous>
[74]     0.0    0.00    0.00                 _get_cmdline [74]
-----------------------------------------------
                                                 <spontaneous>
[75]     0.0    0.00    0.00                 _read [75]
-----------------------------------------------


Index by function name

  [34] _DoException           [32] __lock_recursive_release [74] _get_cmdline
  [58] _DoSyscall             [69] __lshrdi3              [29] _init
  [50] _DoSyscallErrno        [35] __malloc               [75] _read
  [38] _InitChildThread       [41] __malloc_lock           [3] _start
  [31] _SetupThread           [45] __malloc_unlock         [1] _startExit
  [10] _TrapHandler           [70] __register_frame_info_bases [49] _write
   [5] __adddf3               [40] __sfp_lock_acquire     [60] calloc
  [53] __alloc_libc_hwlock    [42] __sfp_lock_release     [61] do_ctors_end
  [51] __call_exitprocs       [23] __sfvwrite             [39] do_ctors_loop
  [59] __call_exitprocs_impl  [24] __sinit                [11] do_dtors_end
  [65] __errno                [30] __smakebuf             [62] do_dtors_loop
   [8] __extendsfdf2          [22] __sprint               [13] fabs
   [9] __fixdfsi              [71] __sread                [52] localeconv
  [66] __floatunsidf          [36] __swrite                [2] main
  [12] __free_threadlocal_timer [26] __swsetup            [33] malloc
  [14] __ieee754_rem_pio2      [7] __truncdfsf2           [27] memchr
  [46] __init_threadlocal_timer [72] __udivdi3            [55] memcpy
  [67] __isnand               [18] _cleanup               [54] memmove
  [68] __kernel_rem_pio2      [19] _cleanup_impl          [47] memset
   [6] __kernel_sin           [56] _done                  [15] printf
  [17] __libc_done            [73] _exit                  [63] scalbn
  [44] __lock_fair_acquire    [57] _exit_unlocked          [4] sin
  [48] __lock_fair_release    [21] _fflush                [28] std
  [25] __lock_recursive_acquire [43] _fini                [64] strlen
  [37] __lock_recursive_init  [20] _fwalk                 [16] vfprintf
  
This confirms that 'sin' is where all the time is going.

Hope this is helpful,
Ciaran
lone
New User
Posts: 3
Joined: Wed Apr 23, 2025 5:11 pm

Post by lone »

Dear Ciaran,

Thank you very much for the responsive reply and explanation, that makes a lot of sense. Thank you. - I should have paid a bit more attention on the title "Sample based Profiling..." 😅🤣

If you don't mind answering a follow up question:
How would you actually do a detailed profiling for bigger projects on the target hardware?

The only thing which comes to my mind would be to use hardware timers and "wrap them around the code area of interest" and use xscope to transmit the timings to the host computer without majorly impacting the performance.

Thanks in advance and appreciate everyone's time and help here.

Thank you,
Lone
CiaranW
Verified
Member
Posts: 9
Joined: Tue Jun 28, 2022 10:58 am

Post by CiaranW »

Hi Lone,

I think generally we can roughly split the task of profiling into two distinct categories.

1. Microbenchmarking
2. Full-system profiling

For Microbenchmarking specific parts of code, a full-program profiler doesn't always do such a great job anyway. You can either:

- Extract the functions of interest to a smaller program of interest you can run through xsim as I mentioned previously (using the --gprof or --trace option to get some output to analyse).

or

- Use xscope with 'start_stop' probes. These probes just send a timestamp + id code up to the host, which can then be viewed with a program like 'gtkwave'. As a quick example, I converted the 'simpleLoop' program to send these probes.

You can build it with a command like "xcc -target=XK-EVK-XU316 simpleLoop.c ./simpleLoop.xscope -o simpleLoop.xe"

Then you can run it on hardware with a command like "xrun --xscope-file ./simpleLoopOut ./simpleLoop.xe" (connect in xgdb has a similar argument)

Then you can use gtkwave to open the simpleLoopOut.gtkw file and view the waveforms. (you should also be able to view the .vcd file with any VCD viewer)

simpleLoop.c:

Code: Select all

#include <math.h>
#include <stdio.h>
#include <xscope.h>

int main(){
        int i;
        float x = 0;
        for (i = 0; i < 2000; ++i){
                xscope_start(SIN_FUNCTION);
                x +=sin(x);
                xscope_stop(SIN_FUNCTION);
        }
        printf("Done with computation\n");
        return 0;
}
simpleLoop.xscope:

Code: Select all

<xSCOPEconfig ioMode="basic" enabled="true">
  <Probe name="sin function" type="STARTSTOP" datatype="NONE" units="t" enabled="true"/>
</xSCOPEconfig>
Docs on xscope target library: https://www.xmos.com/documentation/XM-0 ... brary.html

Docs on xscope config file: https://www.xmos.com/documentation/XM-0 ... ope-format

For full-system profiling, where you're trying to figure out what your system is generally doing, it can be useful to use a technique similar to the "poor man's profiler" https://poormansprofiler.org/

In short: start your program, then stop it in xgdb after a short (random) period of time. When it is stopped, investigate what it is doing and make some notes. Then repeat this a few times, and you will probably notice some patterns emerge, which will probably be useful.

If you want, it is possible to script this (as demonstrated in the above website). You will lose the detail of doing a full investigation, but might get some nice high-level information.

Just be aware that if your system is doing anything real-time critical, then all of the real-time guarantees will have been broken by stopping it in the debugger. Therefore you may need to re-start the program between samples.

If you're interested in reading more about this technique, this stack overflow post has a bunch of interesting thoughts on one person's exploration of using gdb for profiling: https://stackoverflow.com/a/1779343/4798231

Hope this is helpful, let me know if you would like any more pointers.

Cheers,
Ciaran
lone
New User
Posts: 3
Joined: Wed Apr 23, 2025 5:11 pm

Post by lone »

Hi Ciaran,

Thank you very much for the explanation and example. This should do.
I'll try over the weekend and do some experiments, see how far I get and get the results I want.
Big thanks for your time, help and the pointers. I really appreciate it.

Have a great weekend.
Take care.
Cheers,
Omar