i have problem in implementing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • subodheee
    New Member
    • Jan 2008
    • 6

    i have problem in implementing

    i have a problem in implementing script,i have to extract from below data op,offset,and i need to compare the if same offset,same op repeats in other process i need to make it as same,else no .please suggest how to do or how to identify same op ,offset things.see below

    op means ld,st like that,offset means the last one.

    sample code to extract
    [code=perl]
    if($file_array[$i] =~ /process 1/)
    {
    for(my $j=0;$j<128;$j+ +)
    {
    @array = split(" ", $file_array[$i+2+$j]);
    @scull = $array[1]."\t".$array[4];
    #print "\n",@scull ;
    [/code]
    process 1 :

    IP Op Reg Node Offset
    C_1117 st4 24 0 bd8290
    C_1121 ld2 25 0 33c1f54
    C_1128 st2 26 0 1fea852
    C_1131 st2 27 0 1860844
    C_113a ld2 28 0 2a11a5c
    C_1141 st2 29 0 118b95c
    C_114a ld2 30 0 200d17a
    C_1151 ld4 31 0 b5a838
    C_1158 prefetch 32 0 28f0188
    C_115f st4 33 0 b5a838
    C_1169 prefetch 34 0 33c1f54
    C_1170 st2 35 0 1aad444
    C_1179 st4 36 0 6cc749
    C_1183 st2 37 0 8c1f42
    C_118c prefetch 38 0 1302398
    C_1193 ld2 39 0 336665e
    C_119b ld4 40 0 1302398
    C_11a2 st2 41 0 118b95c
    C_11ab ld2 42 0 118b95c
    C_11b3 ld2 43 0 118b95c
    C_11f6 st4 44 0 bd8290
    C_1200 st8 45 0 2edf363
    C_1211 prefetch 46 0 22f5477
    C_1218 prefetch 47 0 14617a4
    C_121f ld2 48 0 1aad444
    C_1226 st2 49 0 336665e
    C_122f ld2 50 0 8c1f42
    C_1236 prefetch 51 0 1abf60a
    C_123d prefetch 52 0 14617a4
    C_1244 st4 53 0 6cc749
    C_124e ld8 54 0 28f0188
    C_1255 ld4 55 0 b5a838
    C_125c prefetch 56 0 1fea852
    C_1263 ld2 57 0 2a11a5c
    C_126b st2 58 0 1fea852
    C_1274 st2 59 0 14617a4
    C_127d st2 60 0 1abf60a
    C_1286 st2 61 0 1abf60a
    C_128f ld8 62 0 2edf363
    C_1296 prefetch 63 0 d40b50
    C_129d st2 64 0 123424a
    C_12a6 ld2 65 0 2a11a5c
    C_12ae st8 66 0 2edf363
    C_12bf ld2 67 0 1abf60a
    C_1302 ld2 68 0 1fea852
    C_1309 ld2 69 0 33c1f54
    C_1310 ld4 70 0 8c604c
    C_1316 ld2 71 0 8c1f42
    C_131e ld2 72 0 1860844
    C_1326 ld2 73 0 33c1f54
    C_132e ld4 74 0 330b0a8
    C_1335 st4 75 0 8c604c
    C_133f ld2 76 0 2a11a5c
    C_1382 prefetch 77 0 28f0188
    C_1389 st2 78 0 1860844
    C_1392 st2 79 0 14617a4
    C_139b ld4 80 0 bd8290
    C_13a1 ld2 81 0 8c1f42
    C_13a8 ld4 82 0 1302398
    C_13ae ld8 83 0 2edf363
    C_13b5 ld8 84 0 5be630
    C_13bc prefetch 85 0 33c1f54
    C_13c3 ld4 86 0 b5a838
    C_13ca prefetch 87 0 3ae3e14
    C_13d1 ld4 88 0 d40b50
    C_13d8 ld4 89 0 bd8290
    C_1415 ld2 90 0 14617a4
    C_141c ld2 91 0 123424a
    C_1423 L2 evict d40b50
    C_14cb st2 92 0 14617a4
    C_14d4 prefetch 93 0 33c1f54
    C_14db prefetch 94 0 2a11a5c
    C_14e2 st8 95 0 28f0188
    C_14f3 st4 96 0 bd8290
    C_14fd prefetch 97 0 118b95c
    C_1504 prefetch 98 0 1aad444
    C_150b st2 99 0 3510e3c
    C_1514 ld4 100 0 3ae3e14
    C_151a ld4 101 0 3ae3e14
    C_1521 ld2 102 0 1aad444
    C_1529 ld8 103 0 236dc80
    C_1530 prefetch 104 0 1aad444
    C_1537 st2 105 0 336665e
    C_1540 ld2 106 0 1860844
    C_1548 st2 107 0 1aad444
    C_1551 ld4 108 0 3ae3e14
    C_1591 ld2 109 0 33c1f54
    C_1598 prefetch 110 0 5be630
    C_159f ld2 111 0 2a11a5c
    C_15a6 ld2 112 0 33c1f54
    C_15ad ld2 113 0 118b95c
    C_15b5 st8 114 0 236dc80
    C_15c6 ld4 115 0 bd8290
    C_15cd ld2 116 0 1fea852
    C_15d5 ld4 117 0 b5a838
    C_15dc prefetch 118 0 6cc749
    C_15e3 ld4 119 0 1302398
    C_1624 ld2 120 0 123424a
    C_162b st2 121 0 8c1f42
    C_1634 L2 evict 225a212
    C_16dc st2 122 0 1860844
    C_16e5 st2 123 0 8c1f42
    C_16ee st4 124 0 d40b50
    C_16f8 ld8 125 0 5be630
    C_16ff L2 evict ec7b12
    C_17a7 prefetch 126 0 28f0188
    C_17e8 ld8 127 0 e5ad8
    C_17ef ld8 128 0 2c50720
    C_17f6 ld4 129 0 b5a838
    C_17fc ld4 130 0 6cc749
    C_1803 ld4 131 0 c336a8
    C_180a ld4 132 0 8c604c
    C_1811 ld2 133 0 33c1f54
    C_1819 ld8 134 0 4e08a8
    C_1858 ld2 135 0 20de0a
    C_185f ld4 136 0 845f64
    C_1865 ld2 137 0 3403262
    C_186c ld4 138 0 11cf4f4
    C_1873 ld2 139 0 1848992




    process2 :

    IP Op Reg Node Offset
    C_1198 st4 24 0 845f64
    C_11a2 prefetch 25 0 2ae8638
    C_11a9 ld2 26 0 2ae8638
    C_11b0 ld2 27 0 ec7b12
    C_11b7 st8 28 0 1c96e4a
    C_11c8 ld2 29 0 3403262
    C_11cf ld4 30 0 845f64
    C_11d6 st2 31 0 ec7b12
    C_11df prefetch 32 0 845f64
    C_11e6 ld4 33 0 845f64
    C_11ed ld2 34 0 3403262
    C_11f5 st2 35 0 45bad7
    C_11fe prefetch 36 0 139e282
    C_1205 prefetch 37 0 2ae8638
    C_120c ld4 38 0 845f64
    C_1213 ld8 39 0 1c96e4a
    C_1253 ld2 40 0 139e282
    C_125a st2 41 0 2ae8638
    C_1263 ld2 42 0 ec7b12
    C_126a ld2 43 0 139e282
    C_1271 st2 44 0 2ae8638
    C_127a ld8 45 0 1c96e4a
    C_1281 prefetch 46 0 ec7b12
    C_1288 ld8 47 0 2974a36
    C_128f st2 48 0 ec7b12
    C_1298 prefetch 49 0 2974a36
    C_129f ld2 50 0 139e282
    C_12a7 ld2 51 0 3403262
    C_12af ld8 52 0 2974a36
    C_12f0 prefetch 53 0 845f64
    C_12f7 ld2 54 0 139e282
    C_12fe st8 55 0 2974a36
    C_130f st8 56 0 18f8370
    C_1320 ld8 57 0 1c96e4a
    C_1327 prefetch 58 0 18f8370
    C_132e ld2 59 0 2ae8638
    C_1335 ld2 60 0 139e282
    C_133d prefetch 61 0 18f8370
    C_1344 st2 62 0 ec7b12
    C_134d prefetch 63 0 2ae8638
    C_1354 st8 64 0 2974a36
    C_1365 prefetch 65 0 1c96e4a
    C_136c prefetch 66 0 2974a36
    C_1373 st2 67 0 45bad7
    C_137c st8 68 0 18f8370
    C_138d st2 69 0 2ae8638
    C_1396 st8 70 0 18f8370
    C_13a7 st2 71 0 1848992
    C_13b0 ld2 72 0 1848992
    C_13b8 ld8 73 0 2974a36
    C_13bf ld8 74 0 18f8370
    C_13c6 ld4 75 0 845f64
    C_1407 ld8 76 0 2974a36
    C_140e ld2 77 0 2ae8638
    C_1415 ld8 78 0 1c96e4a
    C_141c st2 79 0 3403262
    C_1425 ld2 80 0 ec7b12
    C_142d st2 81 0 ec7b12
    C_1436 ld2 82 0 3403262
    C_143e prefetch 83 0 2974a36
    C_1445 st2 84 0 ec7b12
    C_144e st2 85 0 1848992
    C_1457 ld8 86 0 2974a36
    C_145e ld8 87 0 1c96e4a
    C_1465 ld2 88 0 2ae8638
    C_14a8 ld2 89 0 1848992
    C_14af ld8 90 0 1c96e4a
    C_14b6 ld2 91 0 2ae8638
    C_14bd st2 92 0 2ae8638
    C_14c6 st2 93 0 45bad7
    C_14cf st2 94 0 ec7b12
    C_14d8 ld2 95 0 ec7b12
    C_14e0 ld2 96 0 1848992
    C_14e8 st2 97 0 ec7b12
    C_14f1 prefetch 98 0 845f64
    C_14f8 st2 99 0 1848992
    C_1501 prefetch 100 0 1c96e4a
    C_1508 st2 101 0 45bad7
    C_1511 st2 102 0 ec7b12
    Last edited by numberwhun; Jan 30 '08, 04:06 PM. Reason: add code tags
  • nithinpes
    Recognized Expert Contributor
    • Dec 2007
    • 410

    #2
    If your objective is to compare op and offset fields in Process1 and Process2, the following code should work:

    [CODE=perl]
    open(F,"data.tx t") or die "open failed"; # file containing the data
    @file_array=<F> ;
    close(F);
    $line=0;

    foreach $x (@file_array)
    {
    $line++;

    # #skip lines containing processname & column heading
    next if(($x =~ /process\s*1/)||($x =~ /^\s*IP/));
    next if($x=~/^$/); #skip blank lines

    last if($x =~ /process\s*2/) ; ##terminate loop on reaching process2

    my @data1= split / /,$x;
    push @first_process, $data1[1]."\t".$data1[4];
    }

    $i=0; $count=0;
    foreach $y (@file_array)
    {
    $i++;
    next if ($i<$line);

    # #skip lines containing processname & column heading
    next if(($y =~ /process\s*2/)||($y =~ /^\s*IP/));
    next if($y=~/^$/); #skip blank lines
    my @data2= split / /,$y;
    push @second_process , $data2[1]."\t".$data2[4];
    }

    foreach $pid (@first_process )
    {
    foreach $z (@second_proces s)
    {
    if($z eq $pid) { ###same op,offset
    print "Process $z and $pid are same\n";
    ###do whatever you want
    }
    else { $f=1; } ##setting a flag
    }

    if($f==1) ####the op,offset is not repeated in second process
    {
    ###do what you want
    }
    }

    [/CODE]

    Hope I understood your question correctly :)
    Last edited by nithinpes; Jan 30 '08, 02:31 PM. Reason: removed unnecessary lines

    Comment

    • subodheee
      New Member
      • Jan 2008
      • 6

      #3
      I tried with this its not working ,its just printing process and are same ,that more than 9k times ,.............i also did same thing like
      [code=perl]
      if($file_array[$i] =~ /process0/)
      {
      for(my $j=0;$j<128;$j+ +)
      {
      @array = split(" ", $file_array[$i+2+$j]);
      @scull = $array[1]."\t".$array[4];
      #print "\n",@scull ;
      }
      }
      [/code]
      i have tried in both the ways both are not working fine.
      Last edited by numberwhun; Jan 30 '08, 04:08 PM. Reason: fix top posting and add code tags

      Comment

      • numberwhun
        Recognized Expert Moderator Specialist
        • May 2007
        • 3467

        #4
        Originally posted by subodheee
        i tried with this its not working ,its just printing process and are same ,that more than 9k times ,.............i also did same thing like
        [code=perl]
        if($file_array[$i] =~ /process0/)
        {
        for(my $j=0;$j<128;$j+ +)
        {
        @array = split(" ", $file_array[$i+2+$j]);
        @scull = $array[1]."\t".$array[4];
        #print "\n",@scull ;
        }
        }
        [/code]
        i have tried in both the ways both are not working fine.
        subodheee,

        First, please use code tags when posting code in the forums. You can find information on using them at this link.

        Also, please do not top post. for when you do,

        conversation!
        the
        follow
        to
        difficult
        its

        Regards,

        Jeff

        Comment

        • subodheee
          New Member
          • Jan 2008
          • 6

          #5
          perl scripting

          i want to implement in a generic way if more than 2 processes are there than i need to compare process 2 to process1 ,when i reach to process 3 that should compare with process 2 and process1 if any of the process contains that op,offset than in process 3 i should type as equal .can any one suggest,
          Last edited by subodheee; Jan 31 '08, 03:22 AM. Reason: i am attaching text file containig data

          Comment

          • KevinADC
            Recognized Expert Specialist
            • Jan 2007
            • 4092

            #6
            How many processes are there in the file? For more than two processes this is going to get difficult.

            Comment

            • subodheee
              New Member
              • Jan 2008
              • 6

              #7
              Originally posted by KevinADC
              How many processes are there in the file? For more than two processes this is going to get difficult.

              i want to implement till 15 processes ,thats why

              Comment

              • KevinADC
                Recognized Expert Specialist
                • Jan 2007
                • 4092

                #8
                see my reply on other forum.

                Comment

                • subodheee
                  New Member
                  • Jan 2008
                  • 6

                  #9
                  Originally posted by KevinADC
                  see my reply on other forum.
                  ,

                  yes i have seen ur reply but not good . see mail to u in this forum

                  Comment

                  • subodheee
                    New Member
                    • Jan 2008
                    • 6

                    #10
                    i have a doubt in perl for comparing elements of a file.

                    i want to compare elements of a file , after extracting op, offset ,below given information, i want to implement using hashes like comparing first line op,offset with all other lines op,offset if match equal else no see below, i extracted op,offset took in to array like the code shown below

                    [code=perl]
                    use strict;
                    #use warnings;
                    foreach(@file_a rray) {


                    if($file_array[$i] =~ /process 1 /)
                    {
                    for(my $j=0;$j<128;$j+ +)
                    {
                    @array = split(" ", $file_array[$i+2+$j]);
                    @scull = $array[1]."\t".$array[4];
                    #print "\n",@scull ;
                    program(@scull) ;

                    }

                    }

                    $i++;

                    }
                    $i=0;
                    [/code]
                    process 1 :
                    IP Op Reg Node Offset
                    C_1117 st4 24 0 bd8290
                    C_1121 ld2 25 0 33c1f54
                    C_1128 st2 26 0 1fea852
                    C_1131 st2 27 0 1860844
                    C_113a ld2 28 0 2a11a5c
                    C_1141 st2 29 0 118b95c
                    C_114a ld2 30 0 200d17a
                    C_1151 ld4 31 0 b5a838
                    C_1158 prefetch 32 0 28f0188
                    C_115f st4 33 0 b5a838
                    C_1169 prefetch 34 0 33c1f54
                    C_1170 st2 35 0 1aad444
                    C_1179 st4 36 0 6cc749
                    C_1183 st2 37 0 8c1f42
                    C_118c prefetch 38 0 1302398
                    C_1193 ld2 39 0 336665e
                    C_119b ld4 40 0 1302398
                    C_11a2 st2 41 0 118b95c
                    C_11ab ld2 42 0 118b95c
                    C_11b3 ld2 43 0 118b95c
                    C_11f6 st4 44 0 bd8290
                    C_1200 st8 45 0 2edf363
                    C_1211 prefetch 46 0 22f5477
                    C_1218 prefetch 47 0 14617a4
                    C_121f ld2 48 0 1aad444
                    C_1226 st2 49 0 336665e
                    C_122f ld2 50 0 8c1f42
                    C_1236 prefetch 51 0 1abf60a
                    C_123d prefetch 52 0 14617a4
                    C_1244 st4 53 0 6cc749
                    C_124e ld8 54 0 28f0188
                    C_1255 ld4 55 0 b5a838
                    C_125c prefetch 56 0 1fea852
                    C_1263 ld2 57 0 2a11a5c
                    C_126b st2 58 0 1fea852
                    C_1274 st2 59 0 14617a4
                    C_127d st2 60 0 1abf60a
                    C_1286 st2 61 0 1abf60a
                    C_128f ld8 62 0 2edf363
                    C_1296 prefetch 63 0 d40b50
                    C_129d st2 64 0 123424a
                    C_12a6 ld2 65 0 2a11a5c
                    C_12ae st8 66 0 2edf363
                    C_12bf ld2 67 0 1abf60a
                    C_1302 ld2 68 0 1fea852
                    C_1309 ld2 69 0 33c1f54
                    C_1310 ld4 70 0 8c604c
                    C_1316 ld2 71 0 8c1f42
                    C_131e ld2 72 0 1860844
                    C_1326 ld2 73 0 33c1f54
                    C_132e ld4 74 0 330b0a8
                    C_1335 st4 75 0 8c604c
                    C_133f ld2 76 0 2a11a5c
                    C_1382 prefetch 77 0 28f0188
                    C_1389 st2 78 0 1860844
                    C_1392 st2 79 0 14617a4
                    C_139b ld4 80 0 bd8290
                    C_13a1 ld2 81 0 8c1f42
                    C_13a8 ld4 82 0 1302398
                    C_13ae ld8 83 0 2edf363
                    C_13b5 ld8 84 0 5be630
                    C_13bc prefetch 85 0 33c1f54
                    C_13c3 ld4 86 0 b5a838
                    C_13ca prefetch 87 0 3ae3e14
                    C_13d1 ld4 88 0 d40b50
                    C_13d8 ld4 89 0 bd8290
                    C_1415 ld2 90 0 14617a4
                    C_141c ld2 91 0 123424a
                    C_1423 L2 evict d40b50
                    C_14cb st2 92 0 14617a4
                    C_14d4 prefetch 93 0 33c1f54
                    C_14db prefetch 94 0 2a11a5c
                    C_14e2 st8 95 0 28f0188
                    C_14f3 st4 96 0 bd8290
                    C_14fd prefetch 97 0 118b95c
                    C_1504 prefetch 98 0 1aad444
                    C_150b st2 99 0 3510e3c
                    C_1514 ld4 100 0 3ae3e14
                    C_151a ld4 101 0 3ae3e14
                    C_1521 ld2 102 0 1aad444
                    C_1529 ld8 103 0 236dc80
                    C_1530 prefetch 104 0 1aad444
                    C_1537 st2 105 0 336665e
                    C_1540 ld2 106 0 1860844
                    C_1548 st2 107 0 1aad444
                    C_1551 ld4 108 0 3ae3e14
                    C_1591 ld2 109 0 33c1f54
                    C_1598 prefetch 110 0 5be630
                    C_159f ld2 111 0 2a11a5c
                    C_15a6 ld2 112 0 33c1f54
                    C_15ad ld2 113 0 118b95c
                    C_15b5 st8 114 0 236dc80
                    C_15c6 ld4 115 0 bd8290
                    C_15cd ld2 116 0 1fea852
                    C_15d5 ld4 117 0 b5a838
                    C_15dc prefetch 118 0 6cc749
                    C_15e3 ld4 119 0 1302398
                    C_1624 ld2 120 0 123424a
                    C_162b st2 121 0 8c1f42
                    C_1634 L2 evict 225a212
                    C_16dc st2 122 0 1860844
                    C_16e5 st2 123 0 8c1f42
                    C_16ee st4 124 0 d40b50
                    C_16f8 ld8 125 0 5be630
                    C_16ff L2 evict ec7b12
                    C_17a7 prefetch 126 0 28f0188
                    C_17e8 ld8 127 0 e5ad8
                    C_17ef ld8 128 0 2c50720
                    C_17f6 ld4 129 0 b5a838
                    C_17fc ld4 130 0 6cc749
                    C_1803 ld4 131 0 c336a8
                    Last edited by numberwhun; Jan 31 '08, 02:29 PM. Reason: add code tags

                    Comment

                    • numberwhun
                      Recognized Expert Moderator Specialist
                      • May 2007
                      • 3467

                      #11
                      I have a couple of issues with this post.

                      First, I believe in your last thread I asked you to use code tags when posting code into your threads. I even provided you a link to the page here on TSDN that shows you how to use them. This time, it is a warning! USE CODE TAGS!!!

                      Second, this is the SAME question as the other thread. It is unacceptable to start a new thread of the same question in hopes of a new answer. Work it out in the old thread. I know that you emailed(PM'd) Kevin, but what you really should do is keep your issues in the thread, that way we can all learn from them and also provide any input where we can.

                      I am merging these threads and this is your only warning not to do this!

                      Regards,

                      MODERATOR

                      Comment

                      • KevinADC
                        Recognized Expert Specialist
                        • Jan 2007
                        • 4092

                        #12
                        Originally posted by subodheee
                        ,

                        yes i have seen ur reply but not good . see mail to u in this forum

                        seen ur email not good . see mail to u in this forum

                        Comment

                        Working...