added t-openmp.py

This commit is contained in:
Caner Candan 2010-11-27 21:24:07 +01:00
commit 2141719076
6 changed files with 116 additions and 6 deletions

View file

@ -96,6 +96,8 @@ ELSEIF(ENABLE_CMAKE_TESTING)
SET(RESOURCES
boxplot.py
boxplot_to_png.py
boxplot_to_pdf.py
t-openmp.py
)
FOREACH(file ${RESOURCES})

View file

@ -11,4 +11,5 @@ if __name__ == '__main__':
for i in range(1, len(sys.argv)):
pylab.boxplot( [ [ float(value) for value in line.split() ] for line in open( sys.argv[i] ).readlines() ] )
pylab.xlabel('iterations')
pylab.show()

15
eo/test/boxplot_to_pdf.py Executable file
View file

@ -0,0 +1,15 @@
#!/usr/bin/env python
import pylab
import sys
if __name__ == '__main__':
if len(sys.argv) < 3:
print 'Usage: boxplot_to_pdf.py [Results files, ...] [output file in .pdf]'
sys.exit()
for i in range(1, len(sys.argv) - 1):
pylab.boxplot( [ [ float(value) for value in line.split() ] for line in open( sys.argv[i] ).readlines() ] )
pylab.xlabel('iterations')
pylab.savefig( sys.argv[ len(sys.argv) - 1 ], format='pdf', transparent=True )

View file

@ -5,10 +5,11 @@ import sys
if __name__ == '__main__':
if len(sys.argv) < 3:
print 'Usage: boxplot.py [Results files, ...] [output file in .png]'
print 'Usage: boxplot_to_png.py [Results files, ...] [output file in .png]'
sys.exit()
for i in range(1, len(sys.argv) - 1):
pylab.boxplot( [ [ float(value) for value in line.split() ] for line in open( sys.argv[i] ).readlines() ] )
pylab.savefig( sys.argv[ len(sys.argv) - 1 ] )
pylab.xlabel('iterations')
pylab.savefig( sys.argv[ len(sys.argv) - 1 ], format='png', transparent=True, papertype='a0' )

View file

@ -38,7 +38,7 @@ int main(int ac, char** av)
unsigned int nRun = parser.getORcreateParam((unsigned int)100, "nRun", "Number of runs", 'r', "Evolution Engine").value();
std::string fileNamesPrefix = parser.getORcreateParam(std::string("notitle"), "fileNamesPrefix", "Prefix of all results files name", 'H', "Results").value();
std::string fileNamesPrefix = parser.getORcreateParam(std::string(""), "fileNamesPrefix", "Prefix of all results files name", 'H', "Results").value();
std::string speedupFileName = parser.getORcreateParam(std::string("speedup"), "speedupFileName", "Speedup file name", 0, "Results").value();
std::string efficiencyFileName = parser.getORcreateParam(std::string("efficiency"), "efficiencyFileName", "Efficiency file name", 0, "Results").value();
@ -67,9 +67,9 @@ int main(int ac, char** av)
params << "-pS" << popStep << "-p" << popMin << "-P" << popMax
<< "-dS" << dimStep << "-d" << dimMin << "-D" << dimMax
<< "-r" << nRun << "-s" << seedParam;
std::ofstream speedupFile( std::string( fileNamesPrefix + "_" + speedupFileName + params.str() ).c_str() );
std::ofstream efficiencyFile( std::string( fileNamesPrefix + "_" + efficiencyFileName + params.str() ).c_str() );
std::ofstream dynamicityFile( std::string( fileNamesPrefix + "_" + dynamicityFileName + params.str() ).c_str() );
std::ofstream speedupFile( std::string( fileNamesPrefix + speedupFileName + params.str() ).c_str() );
std::ofstream efficiencyFile( std::string( fileNamesPrefix + efficiencyFileName + params.str() ).c_str() );
std::ofstream dynamicityFile( std::string( fileNamesPrefix + dynamicityFileName + params.str() ).c_str() );
size_t nbtask = 1;
#pragma omp parallel

91
eo/test/t-openmp.py Executable file
View file

@ -0,0 +1,91 @@
#!/usr/bin/env python
import pylab
import optparse, logging, sys, os
from datetime import datetime
LEVELS = {'debug': logging.DEBUG,
'info': logging.INFO,
'warning': logging.WARNING,
'error': logging.ERROR,
'critical': logging.CRITICAL}
LOG_DEFAULT_FILENAME='notitle.log'
OPENMP_EXEC_FORMAT='./test/t-openmp -p=%d --popStep=%d -P=%d -d=%d --dimStep=%d -D=%d -r=%d --seed=%d -v=%s -H=%s'
def parser(parser=optparse.OptionParser()):
# general parameters
parser.add_option('-v', '--verbose', choices=LEVELS.keys(), default='warning', help='set a verbose level')
parser.add_option('-f', '--file', help='give an input project filename', default='')
parser.add_option('-o', '--output', help='give an output filename for logging', default=LOG_DEFAULT_FILENAME)
# general parameters ends
parser.add_option('-p', '--popMin', default=1)
parser.add_option('', '--popStep', default=1)
parser.add_option('-P', '--popMax', default=100)
parser.add_option('-d', '--dimMin', default=1)
parser.add_option('', '--dimStep', default=1)
parser.add_option('-D', '--dimMax', default=100)
parser.add_option('-r', '--nRun', default=100)
parser.add_option('-s', '--seed', default=-1)
topic = str(datetime.today())
for char in [' ', ':', '-', '.']: topic = topic.replace(char, '_')
parser.add_option('-t', '--topic', default='openmp_' + topic + '/')
options, args = parser.parse_args()
logger(options.verbose, options.output)
return options
def logger(level_name, filename=LOG_DEFAULT_FILENAME):
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
filename=filename, filemode='a'
)
console = logging.StreamHandler()
console.setLevel(LEVELS.get(level_name, logging.NOTSET))
console.setFormatter(logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s'))
logging.getLogger('').addHandler(console)
options = parser()
def execute_openmp( p, ps, P, d, ds, D, r, s, v=options.verbose ):
cmd = OPENMP_EXEC_FORMAT % (p, ps, P, d, ds, D, r, s, v, options.topic)
logging.debug( cmd )
#os.system( cmd )
def main():
# creates first the new topic repository
#os.mkdir( options.topic )
# (1) EA in time O(1)
# (1.1) speedup measure Sp, Ep for P & D
# (1.1.1) measure for all combinaisons of P n D
execute_openmp( 1, 10, 100, 1, 10, 100, 100, options.seed )
# (1.1.1) measure for all combinaisons of P n D
execute_openmp( 1, 10, 100, 1, 10, 100, 100, options.seed )
# pylab.boxplot( [ [ float(value) for value in line.split() ] for line in open( sys.argv[i] ).readlines() ] )
# pylab.xlabel('iterations')
# pylab.savefig( sys.argv[ len(sys.argv) - 1 ], format='pdf', transparent=True )
# (2) EA in time O(1)
# when executed, just run main():
if __name__ == '__main__':
logging.debug('### plotting started ###')
main()
logging.debug('### plotting ended ###')