This patch adds '--cell-spe-follow' option to use the SPE 
follow feature.

When '--cell-spe-follow' option is specified,
perfmon2 chases the target SPE thread(context).

[Target SPE thread]
 * per-thread & creation mode
   -> the created main thread is the target.

 * per-thread & attach mode
   -> the attached thread by '--attach-task' is the target.
      NOTE: we can use spu-ps command to know the target SPE thread id.

Signed-off-by: Takashi Yamamoto <[EMAIL PROTECTED]>
---
 pfmon/pfmon_cell.c |   26 +++++++++++++++++++++++---
 pfmon/pfmon_cell.h |    1 +
 2 files changed, 24 insertions(+), 3 deletions(-)

--- a/pfmon/pfmon_cell.c
+++ b/pfmon/pfmon_cell.c
@@ -40,10 +40,13 @@
 #define CELL_PM_CONTROL_COUNTER_WIDTH_32      0x00000000
 #define CELL_PM_CONTROL_COUNTER_WIDTH_MASK    0x01E00000
 
+#define CELL_CTX_FLAGS_SPE_FOLLOW 0x00010000U
 #define CELL_OPTION_NAME_COUNTER_BITS "cell-cntr-width"
 #define CELL_OPTION_NAME_SPE_LIST     "event-spe-list"
+#define CELL_OPTION_NAME_SPE_FOLLOW   "cell-spe-follow"
 #define CELL_OPTION_CODE_COUNTER_BITS 401
 #define CELL_OPTION_CODE_SPE_LIST     402
+#define CELL_OPTION_CODE_SPE_FOLLOW   403
 
 static pfmon_cell_options_t pfmon_cell_opt;
 
@@ -76,15 +79,19 @@ static void pfmon_cell_usage(void)
               "\t\t\t\t\tIf multi-event set(list)s are specified\n"
               "\t\t\t\t\tby --event options,\n"
               "\t\t\t\t\tmulti --%s options\n"
-              "\t\t\t\t\tshould be specified.\n",
+              "\t\t\t\t\tshould be specified.\n"
+              "--%s\t\t\tEnables spe follow.\n",
               CELL_OPTION_NAME_COUNTER_BITS,
               CELL_OPTION_NAME_SPE_LIST,
-              CELL_OPTION_NAME_SPE_LIST);
+              CELL_OPTION_NAME_SPE_LIST,
+              CELL_OPTION_NAME_SPE_FOLLOW);
+
 }
 
 static struct option cmd_cell_options[] = {
        {CELL_OPTION_NAME_COUNTER_BITS, 1, 0, CELL_OPTION_CODE_COUNTER_BITS},
        {CELL_OPTION_NAME_SPE_LIST, 1, 0, CELL_OPTION_CODE_SPE_LIST},
+       {CELL_OPTION_NAME_SPE_FOLLOW, 0, &pfmon_cell_opt.spe_follow, 
CELL_OPTION_CODE_SPE_FOLLOW},
        {0, 0, 0, 0},
 };
 
@@ -103,6 +110,7 @@ static int pfmon_cell_initialize(void)
        pfmon_cell_opt.num_spe_id_lists = 0;
        memset(pfmon_cell_opt.target_spe_info, 0,
               sizeof(pfmon_cell_opt.target_spe_info));
+       pfmon_cell_opt.spe_follow = 0;
 
        return 0;
 }
@@ -247,6 +255,12 @@ static int pfmon_cell_setup(pfmon_event_
                return -1;
        }
 
+       if (pfmon_cell_opt.spe_follow && num_of_spe_events(set) == 0) {
+               fatal_error("'--%s' needs a SPE event in the event list\n",
+                           CELL_OPTION_NAME_SPE_FOLLOW);
+               return -1;
+       }
+
        p = set->mod_inp;
        p->control = CELL_DEFAULT_PM_CONTROL_REG_VALUE;
        p->control |= CELL_PM_CONTROL_FREEZE;
@@ -285,12 +299,18 @@ static int pfmon_cell_print_header(FILE 
 
 static int pfmon_cell_setup_ctx_flags(pfmon_ctx_t *ctx)
 {
-       DPRINT(("\n"));
+       if (pfmon_cell_opt.spe_follow)
+               ctx->ctx_flags |= CELL_CTX_FLAGS_SPE_FOLLOW;
        return 0;
 }
 
 static void pfmon_cell_verify_cmdline(int argc, char **argv)
 {
+       if (pfmon_cell_opt.spe_follow && options.opt_follows)
+               fatal_error("--%s doesn't work with"
+                           " other follow options\n",
+                           CELL_OPTION_NAME_SPE_FOLLOW);
+
        if (options.data_trigger_start ||
            options.data_trigger_stop ||
            options.opt_code_trigger_repeat ||
--- a/pfmon/pfmon_cell.h
+++ b/pfmon/pfmon_cell.h
@@ -65,6 +65,7 @@ typedef struct {
        int counter_bits;
        int num_spe_id_lists;
        pfmon_cell_target_spe_info_t target_spe_info[PFMON_CELL_MAX_EVENT_SETS];
+       int spe_follow;
 } pfmon_cell_options_t;
 
 #endif                         /* __PFMON_CELL_H__ */


Attachment: cell-spe-follow.patch
Description: Binary data

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
perfmon2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/perfmon2-devel

Reply via email to