@@ -8,7 +8,7 @@ import {getGigaflopsReadableString, setLoadingState} from 'org_xprof/frontend/ap
88import { DATA_SERVICE_INTERFACE_TOKEN , DataServiceV2Interface } from 'org_xprof/frontend/app/services/data_service_v2/data_service_v2_interface' ;
99import { setCurrentToolStateAction } from 'org_xprof/frontend/app/store/actions' ;
1010import { ReplaySubject } from 'rxjs' ;
11- import { takeUntil } from 'rxjs/operators' ;
11+ import { take , takeUntil } from 'rxjs/operators' ;
1212
1313import { OperationLevelAnalysis } from './operation_level_analysis/operation_level_analysis' ;
1414import { ProgramLevelAnalysis } from './program_level_analysis/program_level_analysis' ;
@@ -27,6 +27,7 @@ declare interface DeviceIndicators {
2727 hasCmem : boolean ;
2828 hasMegacore : boolean ;
2929 isGpu : boolean ;
30+ timeScaleMultiplier : number ;
3031}
3132type ColumnIdxArr = Array < number | google . visualization . ColumnSpec > ;
3233
@@ -61,6 +62,9 @@ export class RooflineModel implements OnDestroy {
6162 @ViewChild ( 'opLevelAnalysis' ) opLevelAnalysis ?: OperationLevelAnalysis ;
6263
6364 host = '' ;
65+ applyScalingFactor = false ;
66+ loadingAnalysis = false ;
67+
6468 // Device Information section data
6569 deviceInfoArray : DeviceInfoData [ ] = [ ] ;
6670 // Some critical indicators
@@ -69,6 +73,7 @@ export class RooflineModel implements OnDestroy {
6973 hasCmem : false ,
7074 hasMegacore : false ,
7175 isGpu : false ,
76+ timeScaleMultiplier : 1.0 ,
7277 } ;
7378
7479 // dataTableRaw from the raw roofline model data
@@ -178,6 +183,20 @@ export class RooflineModel implements OnDestroy {
178183 } ) ;
179184 }
180185
186+ updateAnalysis ( ) {
187+ this . loadingAnalysis = true ;
188+ const params = new Map < string , string | boolean > ( ) ;
189+ if ( this . applyScalingFactor ) {
190+ params . set ( 'apply_time_scale_multiplier' , this . applyScalingFactor ) ;
191+ }
192+ this . dataService . getData ( this . sessionId , this . tool , this . host , params )
193+ . pipe ( take ( 1 ) )
194+ . subscribe ( ( data ) => {
195+ this . parseData ( data as RooflineModelData [ ] ) ;
196+ this . loadingAnalysis = false ;
197+ } ) ;
198+ }
199+
181200 parseData ( data ?: RooflineModelData [ ] ) {
182201 if ( ! google ?. visualization ) {
183202 console . log ( 'gviz lib is not loaded yet.' ) ;
@@ -203,6 +222,11 @@ export class RooflineModel implements OnDestroy {
203222 this . processScatterDataOp ( ) ;
204223 }
205224
225+ hasValidTimeScaleMultiplier ( ) : boolean {
226+ return this . deviceIndicators . timeScaleMultiplier > 0 &&
227+ this . deviceIndicators . timeScaleMultiplier !== 1 ;
228+ }
229+
206230 /** parse the device information from the original dataset */
207231 parseDeviceInfoData ( dataTableRaw : google . visualization . DataTable ) {
208232 this . deviceIndicators = {
@@ -211,6 +235,8 @@ export class RooflineModel implements OnDestroy {
211235 hasMegacore : ! ! Number ( dataTableRaw . getTableProperty ( 'megacore' ) ) ,
212236 isGpu : dataTableRaw . getTableProperty ( 'device_type' )
213237 . startsWith ( NVIDIA_GPU_TYPE_PREFIX ) ,
238+ timeScaleMultiplier :
239+ Number ( dataTableRaw . getTableProperty ( 'time_scale_multiplier' ) ) || 1 ,
214240 } ;
215241
216242 this . deviceInfoArray = DEVICE_INFO . reduce (
@@ -250,13 +276,25 @@ export class RooflineModel implements OnDestroy {
250276 curInfo . context +=
251277 '(if yes, the analysis assumes Megacore where an HLO runs on both TensorCores utilizing the full chip\'s resources so that the rooflines are twice higher)' ;
252278 curInfo . value = this . deviceIndicators . hasMegacore ? 'Yes' : 'No' ;
279+ } else if (
280+ cur . id === 'time_scale_multiplier' &&
281+ ! this . hasValidTimeScaleMultiplier ( ) ) {
282+ curInfo . display = false ;
253283 }
254284 }
255- const value = this . dataTableRaw ! . getTableProperty ( cur . id ) ;
285+ let value = this . dataTableRaw ! . getTableProperty ( cur . id ) ;
286+ value = cur . type === 'number' ? Number ( value ) : value ;
287+ if ( [
288+ 'peak_flop_rate' , 'peak_vmem_read_bw' , 'peak_vmem_write_bw'
289+ ] . includes ( cur . id ) ) {
290+ curInfo . value = this . applyScalingFactor ?
291+ ( value * this . deviceIndicators . timeScaleMultiplier ) . toFixed ( 2 ) :
292+ value ;
293+ }
256294 acc . push ( {
257295 // convert numeric value to numbers, as some ridge numbers will be
258296 // used as axis values in chart
259- value : cur . type === 'number' ? Number ( value ) : value ,
297+ value,
260298 // put cur at last to overwrite with preprocessed data
261299 ...curInfo ,
262300 } ) ;
@@ -1185,6 +1223,11 @@ export class RooflineModel implements OnDestroy {
11851223 }
11861224 }
11871225
1226+ toggleScalingFactor ( ) {
1227+ this . applyScalingFactor = ! this . applyScalingFactor ;
1228+ this . updateAnalysis ( ) ;
1229+ }
1230+
11881231 ngOnDestroy ( ) {
11891232 setLoadingState ( false , this . store ) ;
11901233 this . destroyed . next ( ) ;
0 commit comments