0001 classdef PerformanceData
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 properties
0013 IsSelected
0014 IsHostData
0015 end
0016
0017 properties (SetAccess=private)
0018 MATLABRelease
0019 CPUInfo
0020 GPUInfo
0021 Results
0022 Timestamp
0023 end
0024
0025 methods
0026 function obj = PerformanceData( release, cpuinfo, gpuinfo, timestamp )
0027
0028 obj.MATLABRelease = release;
0029 obj.CPUInfo = cpuinfo;
0030 obj.GPUInfo = gpuinfo;
0031 obj.Results = struct( ...
0032 'FunctionName', {}, ...
0033 'DataType', {}, ...
0034 'Sizes', {}, ...
0035 'NumOps', {}, ...
0036 'Times', {} );
0037 obj.IsSelected = false;
0038 obj.IsHostData = false;
0039 obj.Timestamp = timestamp;
0040 end
0041
0042 function obj = addResult( obj, fcnName, datatype, sizes, numops, times )
0043 N = numel( obj.Results );
0044 obj.Results(N+1,1).FunctionName = fcnName;
0045 obj.Results(N+1,1).DataType = datatype;
0046 obj.Results(N+1,1).Sizes = sizes;
0047 obj.Results(N+1,1).NumOps = numops;
0048 obj.Results(N+1,1).Times = times;
0049 end
0050
0051 function out = hasResult( obj, fcnname, datatype )
0052 if nargin<3
0053
0054 [fcnname,datatype] = iSplitName( fcnname );
0055 end
0056 nameMatches = ismember( {obj.Results.FunctionName}, fcnname );
0057 typeMatches = ismember( {obj.Results.DataType}, datatype );
0058 out = any( nameMatches & typeMatches );
0059 end
0060
0061 function out = getResult( obj, fcnname, datatype )
0062 if nargin<3
0063
0064 [fcnname,datatype] = iSplitName( fcnname );
0065 end
0066 nameMatches = ismember( {obj.Results.FunctionName}, fcnname );
0067 typeMatches = ismember( {obj.Results.DataType}, datatype );
0068 idx = find( nameMatches & typeMatches, 1, 'first' );
0069 if isempty( idx )
0070 error( 'GPUBench:PerformanceData:NoSuchData', 'No results were found for %s (%s).', ...
0071 fcnname, datatype );
0072 end
0073 out = obj.Results(idx);
0074 end
0075
0076 function name = getDeviceName( obj )
0077 if obj.IsHostData
0078 name = 'Host PC';
0079 else
0080 name = obj.GPUInfo.Name;
0081 end
0082 end
0083
0084 end
0085
0086 end
0087
0088 function [fcnname,datatype] = iSplitName( longname )
0089
0090 out = regexp( longname, '(?<fcn>\w+)\s+\((?<type>\w+)\)', 'names' );
0091 fcnname = out.fcn;
0092 datatype = out.type;
0093 end