stephane eranian <[email protected]> wrote on 07/15/2009 05:02:47 PM:

> On Wed, Jul 15, 2009 at 11:32 PM, Corey
> Ashford<[email protected]> wrote:
> > (forgot to attach the patch, so here it is)
> >
> > Hi,
> >
> > I've made a stab at consolidating the event and group types for the 
Power
> > chips (ppc970 through Power7).
> >
> > I'm not real happy with the result.  It is a little more compact in 
the
> > coding of the case statements, but in gaining some compaction, we've 
lost
> > some clarity.
> >
> > I made an attempt to be able to use one pair of types for all 
processors,
> > but the C99 language doesn't appear to like things like this:
> >
> > int *foo = { 1, 2, 3 };
> >
> but this would probably work:
>    int foo[] = { 1, 2, 3}
> or
>    int bar[] = { 1, 2, 3}
>    int * foo = bar;
> 
> But I suspect you want foo[]. sizeof(foo) will return the correct 
information.

Well, you cannot have two variable size elements in a struct.  You can 
have only one, and it must be the final element in the struct, for fairly 
obvious reasons.  Unfortunately, the event struct has two arrays in it.

So yes, you could declare the arrays separately, and then point to them. 
That would mean that you would need either to name each array separately, 
and refer to those names, something like this:
        [ POWER5p_PME_PM_L3SB_REF ] = {
                .pme_name = "PM_L3SB_REF",
                .pme_code = 0x701c4,
                .pme_short_desc = "L3 slice B references",
                .pme_long_desc = "Number of attempts made by this chip 
cores to find data in the L3. Reported per L3 slice",
                .pme_event_ids = &power5p_pme_pm_l3sb_ref_event_ids; 
<******
                .pme_group_vector = &power5p_pme_pm_l3sb_group_vector; 
<******
              }

or put them in their own arrays, and then reference them something like:

        [ POWER5p_PME_PM_L3SB_REF ] = {
                .pme_name = "PM_L3SB_REF",
                .pme_code = 0x701c4,
                .pme_short_desc = "L3 slice B references",
                .pme_long_desc = "Number of attempts made by this chip 
cores to find data in the L3. Reported per L3 slice",
                .pme_event_ids = &power5p_event_ids[PME_PM_L3SB_REF]; 
<******
                .pme_group_vector = 
&power5p_group_vector[PME_PM_L3SB_REF];  <*****
              }


I'm ok with this solution too.  It does save some space (versus using max 
fixed-length arrays), but might make it a bit harder to understand, and 
slightly slower due to the extra level of indirection added.  It might 
involve quite a bit of re-work of the script that generates the code, but 
it shouldn't be too hard.


Regards,

- Corey

Corey Ashford
Software Engineer
IBM Linux Technology Center, Linux Toolchain
[email protected]


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
perfmon2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/perfmon2-devel

Reply via email to