parsec基准接口工具
parsecp的Python项目详细描述
Python库以与PARSEC 2.1和3基准进行接口, 控制执行触发器并处理输出度量时间 计算加速比的数据。此外,库可以生成 并行应用程序加速的数学模型,基于 “粒子群优化”或“耦合模拟退火” 发现最小化“目标”的参数的算法 功能”。目标函数可以用模块python构建 在执行脚本时作为参数传递给库。
功能
- 使用多个输入大小运行parsec应用程序,并且可以选择, 为了更好地查明真相,不要执行死刑。
- 处理一组parsec 2.1或3.0日志文件,从 shell直接执行parsec。
- 操作日志处理或联机执行的结果数据, 由模块获取运行脚本本身。
- 计算应用程序的加速和效率,如果 可能,使用测量的执行时间。
- 提供一个“pso”算法来模拟并行程序的加速 应用回归过程。
- 提供一个“csa”算法来模拟并行程序的加速 应用回归过程。
- 使用交叉验证计算模型数据的统计得分 过程。
先决条件
- Parsec 2.1或更新版本
- Python3或更新版本
- 努比
- 熊猫
- 带mplot3d工具包的matplotlib(可选,用于绘制三维曲面)
- SCIKIT学习
安装
$ pip3 install parsecpy
用法
类parseCData
用于生成测量时间结构的类,以保存此类数据 在“json”文件中,加载先前保存的json数据文件 计算应用程序的速度或效率并绘制二维或三维图 时间、加速或效率与核心数和 频率或输入大小。
>>> from parsecpy import ParsecData >>> d = ParsecData('path_to_datafile') >>> print(d) # Print summary informations >>> d.times() # Show a Dataframe with mesures times >>> d.speedups() # Show a Dataframe with speedups >>> d.plot3D(d.speedups(), title='Speedup', zlabel='speedup') # plot a 3D Plot : speedups x number of cores x input sizes >>> d.plot3D(d.efficiency(), title='Efficiency', zlabel='efficiency') # plot a 3D Plot : speedups x number of cores x input sizes
类parsecModel
Class used to generate the result of modeling of the application, using any of supported algorithms (PSO, CSA or SVR). The class allows to save the modeling results, load previously saved model data, and plot the model data together with the real measurements. >>> from parsecpy import ParsecModel >>> m = ParsecModel('path_to_model_datafile') >>> print(m) # Print summary informations >>> print(m.measure) # Show a Dataframe with mesures speedups >>> print(m.y_model) # Show a Dataframe with modeled speedups >>> print(m.error) # Show the Mean Squared Error between measured and modeled speedup >>> m.plot3D(title='Speedup', showmeasures=True) # plot a 3D Plot with measurements and model data
类parseClogsData
>>> from parsecpy import ParsecLogsData >>> l = ParsecLogsData('path_to_folder_with_logfiles') >>> print(l) # Print summary informations >>> l.times() # Show a Dataframe with mesures times >>> l.speedups() # Show a Dataframe with speedups >>> l.plot3D() # plot a 3D Plot : speedups x number of cores x input sizes
类群
>>> from parsecpy import data_detach, Swarm, ParsecModel >>> parsec_date = ParsecData("my_output_parsec_file.dat") >>> out_measure = parsec_exec.speedups() >>> meas = data_detach(out_measure) >>> overhead = False >>> kwargsmodel = {'overhead': overhead} >>> sw = Swarm([0,0,0,0], [2.0,1.0,1.0,2.0], kwargs=kwargsmodel, threads=10, size=100, maxiter=1000, modelpath=/root/mymodelfunc.py, x_meas=meas['x'], y_meas=meas['y']) >>> error, solution = sw.run() >>> model = ParsecModel(bsol=solution, berr=error, ymeas=out_measure, modelcodesource=sw.modelcodesource, modelexecparams=sw.get_parameters()) >>> scores = model.validate(kfolds=10) >>> print(model.sol) >>> print(model.scores)
类耦合器
>>> import numpy as np
>>> import random
>>> from parsecpy import data_detach, Swarm, ParsecModel
>>> parsec_date = ParsecData("my_output_parsec_file.dat")
>>> out_measure = parsec_exec.speedups()
>>> meas = data_detach(out_measure)
>>> overhead = False
>>> kwargsmodel = {'overhead': overhead}
>>> initial_state = initial_state = np.array([np.random.uniform(size=5)
for _ in range(10)])
>>> csa = CoupledAnnealer(n_annealers=10, initial_state=initial_state,
tgen_initial=0.01, tacc_initial=0.1,
threads=10, steps=1000, update_interval=100, dimension=5,
args=argscsa, modelpath=/root/mymodelfunc.py
x_meas=meas['x'], y_meas=meas['y'])
>>> error, solution = csa.run()
>>> model = ParsecModel(bsol=solution,
berr=error,
measure=out_measure,
modelcodesource=csa.modelcodesource,
modelexecparams=csa.get_parameters())
>>> scores = model.validate(kfolds=10)
>>> print(model.sol)
>>> print(model.scores)
对模型python模块的要求
用户提供的python模块文件应该具有以下内容
要求:
对于pso模型,应具有如下约束功能:
def constraint_函数(par,x_meas,**kwargs):您的代码#
参数:par-粒子对象kwargs-dict with extra
参数:kwargs['overhead']-布尔值(如果overhead应该
相当可观)分析粒子位置的可行性
(搜索参数)根据要求返回true或false
返回布尔值
对于CSA型号,应具有如下探测功能:
def probe_u函数(par,tgen):您的代码参数:par-
实际参数值tgen-实际发电温度#
生成新的探测解决方案返回探测的操作系统参数列表
溶液返回探针溶液
模型文件应具有以下目标功能:
def objective_function(par, x_meas, y_meas, **kwargs):
# your code
# arguments:
# par - particle object
# x_meas - Measures array of independent variables
# y_meas - Measures array of dependent variable
# kwargs - Dict with extra parameters:
# kwargs['overhead'] - boolean value (if overhead should be considerable)
# calculate the function with should be minimized
# return the calculated value
return float_value
对模型python模块的要求
用户提供的python模块文件应该具有以下内容 要求:
对于pso模型,应具有如下约束功能:
def constraint_函数(par,x_meas,**kwargs):您的代码# 参数:par-粒子对象kwargs-dict with extra 参数:kwargs['overhead']-布尔值(如果overhead应该 相当可观)分析粒子位置的可行性 (搜索参数)根据要求返回true或false 返回布尔值
对于CSA型号,应具有如下探测功能:
def probe_u函数(par,tgen):您的代码参数:par- 实际参数值tgen-实际发电温度# 生成新的探测解决方案返回探测的操作系统参数列表 溶液返回探针溶液
模型文件应具有以下目标功能:
def objective_function(par, x_meas, y_meas, **kwargs): # your code # arguments: # par - particle object # x_meas - Measures array of independent variables # y_meas - Measures array of dependent variable # kwargs - Dict with extra parameters: # kwargs['overhead'] - boolean value (if overhead should be considerable) # calculate the function with should be minimized # return the calculated value return float_value
运行parsec
脚本以运行Parsec应用程序,并重复多次输入大小
usage: parsecpy_runprocess [-h] -p PACKAGE [-c {gcc,gcc-serial,gcc-hooks,gcc-openmp,gcc-pthreads,gcc-tbb}] [-f FREQUENCY] [-i INPUT] [-r REPETITIONS] [-b CPUBASE] [-v VERBOSITY] c Script to run parsec app with repetitions and multiples inputs sizes positional arguments: c List of cores numbers to be used. Ex: 1,2,4 optional arguments: -h, --help show this help message and exit -p PACKAGE, --package PACKAGE Package Name to run -c {gcc,gcc-serial,gcc-hooks,gcc-openmp,gcc-pthreads,gcc-tbb}, --compiler {gcc,gcc-serial,gcc-hooks,gcc-openmp,gcc-pthreads,gcc-tbb} Compiler name to be used on run. (Default: gcc-hooks). -f FREQUENCY, --frequency FREQUENCY List of frequencies (KHz). Ex: 2000000, 2100000 -i INPUT, --input INPUT Input name to be used on run. (Default: native). Syntax: inputsetname[<initialnumber>:<finalnumber>]. From lowest to highest size. Ex: native or native_1:10 -r REPETITIONS, --repetitions REPETITIONS Number of repetitions for a specific run. (Default: 1) -b CPUBASE, --cpubase CPUBASE If run with thread affinity(limiting the running cores to defined number of cores), define the cpu base number. -v VERBOSITY, --verbosity VERBOSITY verbosity level. 0 = No verbose Example: parsecpy_runprocess -p freqmine -c gcc-hooks -r 5 -i native 1,2,4,8 -v 3
运行pso或csa建模脚本
脚本来运行swarm建模来预测parsec应用程序的输出。打开 示例文件夹中,存在配置参数的模板文件 在执行此脚本时使用
usage: parsecpy_runmodel [-h] --config CONFIG -f PARSECPYFILEPATH [-p PARTICLES] [-x MAXITERATIONS] [-l LOWERVALUES] [-u UPPERVALUES] [-n PROBLEMSIZES] [-o OVERHEAD] [-t THREADS] [-r REPETITIONS] [-c CROSSVALIDATION] [-v VERBOSITY] Script to run modelling algorithm to predict a parsec application output optional arguments: -h, --help show this help message and exit --config CONFIG Filepath from Configuration file configurations parameters -p PARSECPYDATAFILEPATH, --parsecpydatafilepath PARSECPYDATAFILEPATH Path from input data file from Parsec specificated package. -f FREQUENCIES, --frequency FREQUENCIES List of frequencies (KHz). Ex: 2000000, 2100000 -n PROBLEMSIZES, --problemsizes PROBLEMSIZES List of problem sizes to model used. Ex: native_01,native_05,native_08 -o OVERHEAD, --overhead OVERHEAD If it consider the overhead -t THREADS, --threads THREADS Number of Threads -c CROSSVALIDATION, --crossvalidation CROSSVALIDATION If run the cross validation of modelling -m MEASURESFRACTION, --measuresfraction MEASURESFRACTION Fraction of measures data to calculate the model -v VERBOSITY, --verbosity VERBOSITY verbosity level. 0 = No verbose Example parsecpy_runmodel --config my_config.json -p /var/myparsecsim.dat -c True -v 3
日志处理
用于分析包含parsec日志文件的文件夹并保存度量值的脚本 输出文件
parsecpy_processlogs [-h] foldername outputfilename positional arguments: foldername Foldername with parsec log files. outputfilename Filename to save the measures dictionary. optional arguments: -h, --help show this help message and exit Example: parsecpy_processlogs logs_folder my-logs-folder-data.dat
创建分割零件
在特定部分拆分parsec输入文件的脚本
parsecpy_createinputs [-h] -p {freqmine,fluidanimate} -n NUMBEROFPARTS [-t {equal,diff}] -x EXTRAARG inputfilename positional arguments: inputfilename Input filename from Parsec specificated package. optional arguments: -h, --help show this help message and exit -p {freqmine,fluidanimate}, --package {freqmine,fluidanimate} Package name to be used on split. -n NUMBEROFPARTS, --numberofparts NUMBEROFPARTS Number of split parts -t {equal,diff}, --typeofsplit {equal,diff} Split on equal or diferent size partes parts -x EXTRAARG, --extraarg EXTRAARG Specific argument: Freqmine=minimum support (11000), Fluidanimate=Max number of frames Example: parsec_createinputs -p fluidanimate -n 10 -t diff -x 500 fluidanimate_native.tar