From 69f2911e04ffb1b19eef1fafb8c040af271f656e Mon Sep 17 00:00:00 2001 From: Tor Aamodt Date: Thu, 15 Jul 2010 18:09:46 -0800 Subject: creating branch for adding support for CUDA 3.x and Fermi [git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 6829] --- benchmarks/CUDA/WP/spt.pl | 219 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 219 insertions(+) create mode 100755 benchmarks/CUDA/WP/spt.pl (limited to 'benchmarks/CUDA/WP/spt.pl') diff --git a/benchmarks/CUDA/WP/spt.pl b/benchmarks/CUDA/WP/spt.pl new file mode 100755 index 0000000..7dc272a --- /dev/null +++ b/benchmarks/CUDA/WP/spt.pl @@ -0,0 +1,219 @@ +#!/usr/bin/perl + +# 0 line number +# 1 keyword +# 2 action + +open DIRECTIVES, "| cat -n | grep '//_def_' | sed 's/ .*\\\/\\\/_def_/ / ' > directives__" or die "writing directives" ; +open TEMP1, "> tmp1__" or die "making copy of code" ; + +while () { + print DIRECTIVES ; + print TEMP1 ; +} +close DIRECTIVES ; +close TEMP1 ; + +open DEBUG, "> debug__" or die ; +## first pass, preprocess the directives + +open DIRECTIVES, "< directives__" or die ; +while () { + print TEMP1 ; + $line = $_ ; + @t = split( ' ',$line ) ; + $keyword = $t[1] ; + $action = $t[2] ; + @actionlist = split( ';', $action ) ; + foreach $act ( @actionlist ) { + @dim_vlist = split ( ':', $act ) ; + $dim = $dim_vlist[0] ; $vlist = $dim_vlist[1] ; + foreach $v ( split( ',', $vlist ) ) { + $vars{$v} = $v ; + $dimensionality{$v} = $dim ; + if ( $keyword eq "arg" ) { + $key{$v} = $keyword ; + if ( $dim eq "ikj" ) { $ikj_args{$v} = $v ; } + if ( $dim eq "ij" ) { $ij_args{$v} = $v ; } + } + if ( $keyword eq "local" ) { + $key{$v} = $keyword ; + if ( $dim eq "k" ) { $k_local{$v} = $v ; } + } + if ( $keyword eq "register" ) { + $key{$v} = $keyword ; + if ( $dim eq "0" ) { $register{$v} = $v ; } + } + if ( $keyword eq "copy_up_mem" ) { + if ( $key{$v} ne "arg" ) { + print "//warning: copy_up_mem of $v when $v is not arg.\n" ; + } else { + $copy_up_mem{$v} = $dim ; + if ( $dim eq "ikj" ) { $ikj_shared{$v} = $v ; } + if ( $dim eq "ij" ) { $ij_shared{$v} = $v ; } + } + } + if ( $keyword eq "shared_mem_local" ) { + $key{$v} = $keyword ; + $shared_mem_local{$v} = $dim ; + if ( $dim eq "ikj" ) { $ikj_shared{$v} = $v ; } + if ( $dim eq "ij" ) { $ij_shared{$v} = $v ; } + } + if ( $keyword eq "copy_down_mem" ) { + if ( $key{$v} ne "arg" ) { + print "//warning: copy_down_mem of $v when $v is not arg.\n" ; + } else { + $copy_down_mem{$v} = $dim ; + if ( $dim eq "ikj" ) { $ikj_shared{$v} = $v ; } + if ( $dim eq "ij" ) { $ij_shared{$v} = $v ; } + } + } + } + } +} +close DIRECTIVES ; + +## seond pass, modify the code +## and preprocess deferred directives + +$spton=0 ; + +open TEMP1, "< tmp1__" or die ; +while () { + $line = $_ ; + # toggle on and off between SPTSTART and SPTSTOP + if ( $line =~ "SPTSTART" ) { $spton = 1 ; } + elsif ( $line =~ "SPTSTOP" ) { $spton = 0 ; } + if ( $spton == 1 ) { + + # handle copy_up_mem and copy_down_mem directives in line + if ( $line =~ m/\/\/\s*_def_\s+copy_up_mem\s/ ) { + @t = split( ' ',$line ) ; + $action = $t[2] ; + @dim_vlist = split ( ':', $action ) ; + $vlist = $dim_vlist[1] ; + foreach $v ( split( ',', $vlist ) ) { + print "LOCSM(${v}_s,bx*by*kx) ;\n" ; + } + print "{ int k ; \n" ; + foreach $v ( split( ',', $vlist ) ) { + print "for(k=kps-1;k