0001 classdef SummaryData
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 properties (SetAccess=private)
0013 DeviceName
0014 FunctionName
0015 Datatype
0016 LongName
0017 IsSelectedDevice
0018 PeakFLOPS
0019 Score
0020 SortOrder
0021 end
0022
0023
0024 methods
0025 function obj = SummaryData( data )
0026
0027
0028 N = numel( data );
0029
0030
0031 obj.DeviceName = cell(N,1);
0032 obj.IsSelectedDevice = [data.IsSelected];
0033 functionNames = cell(N,1);
0034 datatypes = cell(N,1);
0035 longNames = cell(N,1);
0036 peakFlops = cell(N,1);
0037 for jj=1:numel(data)
0038 thisResults = data(jj).Results;
0039 M = numel( thisResults );
0040 obj.DeviceName{jj} = data(jj).getDeviceName();
0041 functionNames{jj} = cell( 1, M );
0042 datatypes{jj} = cell( 1, M );
0043 longNames{jj} = cell( 1, M );
0044 peakFlops{jj} = zeros( 1, M );
0045 for ii=1:M
0046 datatypes{jj}{ii} = thisResults(ii).DataType;
0047 functionNames{jj}{ii} = thisResults(ii).FunctionName;
0048 datatypes{jj}{ii} = thisResults(ii).DataType;
0049 longNames{jj}{ii} = [functionNames{jj}{ii},' (',datatypes{jj}{ii},')'];
0050 peakFlops{jj}(ii) = max( thisResults(ii).NumOps ./ thisResults(ii).Times );
0051 end
0052 end
0053 datatypes = [datatypes{:}];
0054 functionNames = [functionNames{:}];
0055
0056
0057
0058 [obj.LongName,idx] = unique( [longNames{:}] );
0059 obj.Datatype = datatypes(idx);
0060 obj.FunctionName = functionNames(idx);
0061
0062
0063 M = numel( obj.LongName );
0064 obj.PeakFLOPS = nan( N, M );
0065 for row=1:N
0066 [~,col] = ismember( longNames{row}, obj.LongName );
0067 obj.PeakFLOPS(row, col) = peakFlops{row};
0068 end
0069
0070
0071
0072
0073 normalizedFLOPS = bsxfun( @rdivide, obj.PeakFLOPS, max( obj.PeakFLOPS, [], 1 ) );
0074 normalizedFLOPS = normalizedFLOPS( :, strcmpi( obj.Datatype, 'double' ) );
0075
0076 obj.Score = zeros( N, 1 );
0077 for ii=1:N
0078 valid = ~isnan( normalizedFLOPS(ii,:) );
0079 obj.Score(ii) = mean( normalizedFLOPS(ii, valid) );
0080 end
0081
0082
0083 obj = sortResults( obj );
0084
0085 end
0086
0087 function t = getDatatypes( obj )
0088 t = unique( obj.Datatype );
0089 end
0090
0091 function cols = getColsForType( obj, typename )
0092 if iscell( typename )
0093 cols = cell( size( typename ) );
0094 for ii=1:numel(cols)
0095 cols{ii} = obj.getColsForType( typename{ii} );
0096 end
0097 else
0098 cols = find( strcmp( obj.Datatype, typename ) );
0099 end
0100 end
0101 end
0102
0103
0104 methods (Access=protected)
0105 function obj = sortResults(obj)
0106
0107
0108
0109
0110
0111
0112 [obj.Score,obj.SortOrder] = sort( obj.Score, 'descend' );
0113 obj.DeviceName = obj.DeviceName(obj.SortOrder);
0114 obj.PeakFLOPS = obj.PeakFLOPS(obj.SortOrder,:);
0115 obj.IsSelectedDevice = obj.IsSelectedDevice(obj.SortOrder);
0116
0117
0118 [~,idx] = sort( max( obj.PeakFLOPS ), 'descend' );
0119 obj = reorderFunctions( obj, idx );
0120
0121
0122
0123 [~,idx] = sort( obj.Datatype );
0124 obj = reorderFunctions( obj, idx );
0125 end
0126
0127 function obj = reorderFunctions( obj, idx )
0128 assert( numel(idx) == numel(obj.LongName) );
0129 obj.PeakFLOPS = obj.PeakFLOPS(:,idx);
0130 obj.FunctionName = obj.FunctionName(idx);
0131 obj.LongName = obj.LongName(idx);
0132 obj.Datatype = obj.Datatype(idx);
0133 end
0134
0135 end
0136
0137 end
0138