Skip to content

Instantly share code, notes, and snippets.

@chockenberry
Last active June 14, 2021 08:42
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chockenberry/2afe4d0f1f9caddc81de to your computer and use it in GitHub Desktop.
Save chockenberry/2afe4d0f1f9caddc81de to your computer and use it in GitHub Desktop.
In the next version of iPulse, I'd like to show GPU statistics. Unfortunately, the format
for these statistics is vendor specfic (see the "Performance Statistics" dictionary below.)
In order to cover as many devices as possible, I'd like you to run the following commands
from your Terminal:
$ sysctl hw.model
$ ioreg -r -d 1 -w 0 -c "IOAccelerator"
You can help me read the results by putting them in a code block (triple backticks).
I'll add a few of my Macs to get this list started. Thanks for your help!
@cgarman
Copy link

cgarman commented Nov 8, 2015

hw.model: MacPro5,1

+-o AMDCypressGraphicsAccelerator  <class AMDCypressGraphicsAccelerator, id 0x10000038d, registered, matched, active, busy 0 (0 ms), retain 698>
    {
      "IOClass" = "AMDCypressGraphicsAccelerator"
      "dpm" = 1
      "IOKitDebug" = 0
      "AccelNativeDMARowByteAlignment" = 256
      "IOVARendererID" = 16908290
      "IODVDBundleName" = "AMDRadeonVADriver"
      "AccelCaps" = 15
      "IOGLBundleName" = "AMDRadeonX3000GLDriver"
      "IOProviderClass" = "IOPCIDevice"
      "ATIEnableWideBlitSupport" = Yes
      "IOProbeScore" = 200
      "SurfaceList" = ({"surfaceType"="ctx","width"=1254,"height"=1344,"pid"=373},{"surfaceType"="ctx","width"=325,"height"=23,"pid"=3984},{"surfaceType"="ctx","width"=1543,"height"=1300,"pid"=2734},{"surfaceType"="ctx","width"=370,"height"=1289,"pid"=373},{"surfaceType"="ctx","width"=1010,"height"=663,"pid"=2734},{"surfaceType"="ctx","width"=1543,"height"=1278,"pid"=2734},{"surfaceType"="ctx","width"=449,"height"=430,"pid"=395},{"surfaceType"="ctx","width"=1543,"height"=1278,"pid"=2734},{"surfaceType"="ctx","width"=1543,"height"=1300,"pid"=2734},{"surfaceType"="ctx","width"=370,"height"=1214,"pid"=373})
      "IOSourceVersion" = "0.0.0.0.0"
      "PerformanceStatisticsAccum" = {"removeFromGARTWaitTime"=0,"orphanedNonReusableVidMemoryCount"=0,"orphanedReusableVidMemoryHitRate"=53,"command2DBytesPerSample"=0,"swapCompleteVideoWaitTime"=0,"commandBytesPerSample"=0,"surfacePageOutBytesPerSample"=0,"orphanedReusableSysMemoryHitRate"=0,"HWChannel DMA | Commands Submitted"=0,"freeDataBufferGLWaitTime"=0,"freeCommandBufferVideoWaitTime"=0,"dataBufferCount"=0,"freeContextBufferCLWaitTime"=0,"textureCount"=18446744073703748386,"surfaceReadLockIdleWaitTime"=0,"freeDataBufferWaitTime"=0,"freeCommandBuffer2DWaitTime"=0,"orphanedReusableSysMemoryBytes"=0,"orphanedReusableSysMemoryCount"=0,"HWChannel PM4 | Commands Completed"=3,"textureWaitTime"=0,"finishAll2DWaitTime"=0,"orphanedNonReusableSysMemoryCount"=0,"IOSurfacePageOutBytesPerSample"=0,"gartMapInBytesPerSample"=0,"HWChannel UVD | Commands Completed"=0,"dataBytesPerSample"=0,"swapBytesPerSample"=0,"surfaceCount"=999303,"clientGLWaitTime"=0,"texturePageOutWaitTime"=0,"surfaceCopyInWaitTime"=0,"surfaceCopyOutWaitTime"=0,"gartMapOutBytesPerSample"=0,"texturePageInBytesPerSample"=0,"gartCacheBytes"=33554432,"freeContextBuffer2DWaitTime"=0,"volatileSurfaceCount"=112,"orphanedReusableVidMemoryBytes"=108134400,"contextGLSwitchCount"=0,"orphanedReusableVidMemoryCount"=6,"freeCommandBufferGLWaitTime"=0,"HWChannel PM4 | Commands Submitted"=4,"freeContextBufferVideoWaitTime"=0,"context2DCount"=3,"bufferSwapCount"=0,"orphanedNonReusableVidMemoryBytes"=0,"vramFreeBytes"=193261504,"contextGLCount"=132,"commandVideoBytesPerSample"=0,"finish2DWaitTime"=0,"gartSizeBytes"=2147483648,"context2DSwitchCount"=0,"recoveryCount"=0,"HWChannel DMA | Commands Completed"=0,"gartUsedBytes"=8650752,"surfaceWriteLockIdleWaitTime"=0,"finishGLWaitTime"=0,"HWChannel UVD | Commands Submitted"=0,"texturePageInWaitTime"=0,"finishCLWaitTime"=0,"finishVideoWaitTime"=0,"freeContextBufferGLWaitTime"=0,"contextCLCount"=2,"swapCompleteGLWaitTime"=0,"freeSurfaceBackingWaitTime"=0,"orphanedNonReusableSysMemoryBytes"=0,"contextVideoSwitchCount"=0,"surfacePageInBytesPerSample"=0,"surfaceSetShapeIdleWaitTime"=0,"freeCommandBufferCLWaitTime"=0,"gartFreeBytes"=2138832896,"hardwareSubmitWaitTime"=0,"bufferFlipCount"=0,"commandGLBytesPerSample"=0,"swapComplete2DWaitTime"=0,"contextVideoCount"=0,"hardwareWaitTime"=0,"freeSurfaceSwapBufferWaitTime"=0,"IOSurfacePageInBytesPerSample"=0,"contextCLSwitchCount"=0,"texturePageOutBytesPerSample"=0}
      "ATY,cbits" = 589824
      "ATY,intrev" = 2
      "IOAccelRevision" = 2
      "IOCFPlugInTypes" = {"ACCF0000-0000-0000-0000-000a2789904e"="IOAccelerator2D.plugin"}
      "InternalStatisticsAccm" = {}
      "IOMatchCategory" = "IOAccelerator"
      "CFBundleIdentifier" = "com.apple.AMDRadeonX3000"
      "ATIUseTearingWideBlit" = No
      "PerformanceStatistics" = {"removeFromGARTWaitTime"=0,"orphanedNonReusableVidMemoryCount"=0,"orphanedReusableVidMemoryHitRate"=53,"command2DBytesPerSample"=0,"swapCompleteVideoWaitTime"=0,"commandBytesPerSample"=0,"surfacePageOutBytesPerSample"=0,"orphanedReusableSysMemoryHitRate"=0,"HWChannel DMA | Commands Submitted"=0,"freeDataBufferGLWaitTime"=1606798306,"freeCommandBufferVideoWaitTime"=0,"dataBufferCount"=6,"freeContextBufferCLWaitTime"=0,"textureCount"=18446744073703748386,"surfaceReadLockIdleWaitTime"=0,"freeDataBufferWaitTime"=0,"freeCommandBuffer2DWaitTime"=0,"orphanedReusableSysMemoryBytes"=0,"orphanedReusableSysMemoryCount"=0,"HWChannel PM4 | Commands Completed"=6363563,"textureWaitTime"=0,"finishAll2DWaitTime"=0,"orphanedNonReusableSysMemoryCount"=0,"IOSurfacePageOutBytesPerSample"=18446744072909164544,"gartMapInBytesPerSample"=0,"HWChannel UVD | Commands Completed"=0,"dataBytesPerSample"=0,"swapBytesPerSample"=0,"surfaceCount"=999303,"clientGLWaitTime"=18446744072348514661,"texturePageOutWaitTime"=0,"surfaceCopyInWaitTime"=0,"surfaceCopyOutWaitTime"=315298347,"gartMapOutBytesPerSample"=0,"texturePageInBytesPerSample"=1626288128,"gartCacheBytes"=33554432,"freeContextBuffer2DWaitTime"=0,"volatileSurfaceCount"=139,"orphanedReusableVidMemoryBytes"=108134400,"contextGLSwitchCount"=0,"orphanedReusableVidMemoryCount"=6,"freeCommandBufferGLWaitTime"=0,"HWChannel PM4 | Commands Submitted"=6363563,"freeContextBufferVideoWaitTime"=0,"context2DCount"=3,"bufferSwapCount"=27659,"orphanedNonReusableVidMemoryBytes"=0,"vramFreeBytes"=193261504,"contextGLCount"=132,"commandVideoBytesPerSample"=0,"finish2DWaitTime"=0,"gartSizeBytes"=2147483648,"context2DSwitchCount"=0,"recoveryCount"=0,"HWChannel DMA | Commands Completed"=0,"gartUsedBytes"=8646656,"surfaceWriteLockIdleWaitTime"=0,"finishGLWaitTime"=1408654,"HWChannel UVD | Commands Submitted"=0,"texturePageInWaitTime"=0,"finishCLWaitTime"=0,"finishVideoWaitTime"=0,"freeContextBufferGLWaitTime"=0,"contextCLCount"=2,"swapCompleteGLWaitTime"=6305163,"freeSurfaceBackingWaitTime"=0,"orphanedNonReusableSysMemoryBytes"=0,"contextVideoSwitchCount"=0,"surfacePageInBytesPerSample"=0,"surfaceSetShapeIdleWaitTime"=0,"freeCommandBufferCLWaitTime"=0,"gartFreeBytes"=2138836992,"hardwareSubmitWaitTime"=0,"bufferFlipCount"=0,"commandGLBytesPerSample"=0,"swapComplete2DWaitTime"=0,"contextVideoCount"=0,"hardwareWaitTime"=18446744073346533459,"freeSurfaceSwapBufferWaitTime"=0,"IOSurfacePageInBytesPerSample"=2122207232,"contextCLSwitchCount"=0,"texturePageOutBytesPerSample"=1417490432}
      "InternalStatistics" = {}
      "sensor-properties" = ({"zone"=<00000002>,"location"="GPU","name"="gpu-sensor","polling-period"=<0000000100000000>,"version"=<00000002>,"sample-period"=<0000000000989800>,"sensor-id"=<00000006>,"device_type"=<"gpu-sensor">,"reg"=<00000002>})
      "IOPCIMatch" = "0x68981002 0x68991002"
      "GpuDebugPolicy" = 0
    }

@adamkmccarthy
Copy link

hw.model: MacBookPro11,1

+-o IntelAccelerator  <class IntelAccelerator, id 0x1000003b4, registered, matched, active, busy 0 (0 ms), retain 111>
    {
      "IOClass" = "IntelAccelerator"
      "IOPCIClassMatch" = "0x03000000&0xff000000"
      "AccelCaps" = 15
      "IODVDBundleName" = "AppleIntelHD5000GraphicsVADriver"
      "IOGLBundleName" = "AppleIntelHD5000GraphicsGLDriver"
      "IOProviderClass" = "IOPCIDevice"
      "CompactVRAM" = 1
      "ForceDisableEDRAM" = 0
      "MetalPluginName" = "AppleIntelHD5000GraphicsMTLDriver"
      "IOProbeScore" = 1000
      "SurfaceList" = ({"surfaceType"="ctx","width"=2560,"height"=1600,"pid"=192})
      "IOSourceVersion" = "0.0.0.0.0"
      "PerformanceStatisticsAccum" = {"orphanedReusableVidMemoryHitRate"=0,"texturePageOutBytes"=0,"swapCompleteVideoWaitTime"=0,"orphanedReusableSysMemoryHitRate"=52,"dataBufferCount"=0,"oolTexturePageInBytes"=0,"textureCount"=2300,"iosurfaceTextureCreationCount"=0,"surfaceReadLockIdleWaitTime"=0,"freeDataBufferWaitTime"=0,"orphanedReusableSysMemoryBytes"=995348480,"ioSurfaceReadOutBytes"=0,"agprefTextureCreationCount"=0,"orphanedReusableSysMemoryCount"=791,"finishAll2DWaitTime"=0,"orphanedNonReusableSysMemoryCount"=0,"surfaceTextureCreationCount"=0,"ioSurfacePageOutBytes"=0,"surfaceBufferReadOutBytes"=0,"textureReadOutBytes"=0,"gartMapInBytesPerSample"=0,"dataBytesPerSample"=0,"swapBytesPerSample"=0,"surfaceCount"=9082,"Device Unit 0 Utilization %"=0,"clientGLWaitTime"=0,"surfaceCopyInWaitTime"=0,"surfaceCopyOutWaitTime"=0,"gartMapOutBytesPerSample"=0,"ioSurfacePageInBytes"=0,"gartCacheBytes"=134217728,"volatileSurfaceCount"=0,"vramEvictionWaitTime"=0,"oolTextureCreationBytes"=0,"freeToAllocGPUAddressWaitTime"=0,"oolTextureCreationCount"=0,"Device Unit 1 Utilization %"=0,"orphanedReusableVidMemoryCount"=0,"orphanedReusableVidMemoryBytes"=0,"context2DCount"=3,"inUseSysMemoryBytes"=18446744072714203136,"bufferSwapCount"=0,"orphanedNonReusableVidMemoryBytes"=0,"contextGLCount"=12,"finish2DWaitTime"=0,"Device Unit 2 Utilization %"=0,"gartSizeBytes"=1610612736,"recoveryCount"=0,"stdTexturePageInBytes"=0,"agprefTextureCreationBytes"=0,"gartUsedBytes"=565760000,"surfaceWriteLockIdleWaitTime"=0,"finishGLWaitTime"=0,"surfaceBufferPageInBytes"=0,"iosurfaceTextureCreationBytes"=0,"finishCLWaitTime"=0,"finishVideoWaitTime"=0,"contextCLCount"=0,"freeSurfaceBackingWaitTime"=0,"Device Unit 3 Utilization %"=0,"swapCompleteGLWaitTime"=0,"orphanedNonReusableSysMemoryBytes"=0,"inUseVidMemoryBytes"=0,"agpTextureCreationBytes"=0,"stdTextureCreationBytes"=0,"agpTextureCreationCount"=0,"stdTextureCreationCount"=0,"surfaceSetShapeIdleWaitTime"=0,"gartFreeBytes"=1044852736,"hardwareSubmitWaitTime"=0,"bufferFlipCount"=0,"textureVolunteerUnloadBytes"=0,"swapComplete2DWaitTime"=0,"surfaceBufferPageOutBytes"=0,"contextVideoCount"=0,"hardwareWaitTime"=0,"freeSurfaceSwapBufferWaitTime"=0,"orphanedNonReusableVidMemoryCount"=0}
      "IOAccelRevision" = 2
      "IOCFPlugInTypes" = {"ACCF0000-0000-0000-0000-000a2789904e"="IOAccelerator2D.plugin"}
      "IOPCIPrimaryMatch" = "0x0d268086 0x0a268086 0x0a2e8086 0x0d228086 0x04128086"
      "InternalStatisticsAccm" = {}
      "IOMatchCategory" = "IOAccelerator"
      "CFBundleIdentifier" = "com.apple.driver.AppleIntelHD5000Graphics"
      "IOGVAScaler" = "Gen75"
      "PanicOnGPUHang" = 0
      "IOGVABGRAEnc" = "Gen75"
      "PerformanceStatistics" = {"orphanedReusableVidMemoryHitRate"=0,"texturePageOutBytes"=0,"swapCompleteVideoWaitTime"=0,"orphanedReusableSysMemoryHitRate"=52,"dataBufferCount"=18446744073709551612,"oolTexturePageInBytes"=18446744071704637440,"Device Utilization % at cur p-state"=2,"iosurfaceTextureCreationCount"=1792,"textureCount"=2300,"freeDataBufferWaitTime"=0,"surfaceReadLockIdleWaitTime"=0,"orphanedReusableSysMemoryBytes"=995348480,"ioSurfaceReadOutBytes"=182710272,"agprefTextureCreationCount"=9,"orphanedReusableSysMemoryCount"=791,"finishAll2DWaitTime"=0,"orphanedNonReusableSysMemoryCount"=0,"surfaceTextureCreationCount"=877,"ioSurfacePageOutBytes"=0,"surfaceBufferReadOutBytes"=7512064,"textureReadOutBytes"=0,"gartMapInBytesPerSample"=0,"dataBytesPerSample"=0,"swapBytesPerSample"=0,"surfaceCount"=9082,"Device Unit 0 Utilization %"=2,"clientGLWaitTime"=8304587,"surfaceCopyInWaitTime"=0,"surfaceCopyOutWaitTime"=0,"gartMapOutBytesPerSample"=0,"ioSurfacePageInBytes"=1723707392,"gartCacheBytes"=134217728,"volatileSurfaceCount"=0,"vramEvictionWaitTime"=0,"oolTextureCreationBytes"=986947584,"freeToAllocGPUAddressWaitTime"=0,"oolTextureCreationCount"=3942,"Device Unit 1 Utilization %"=0,"orphanedReusableVidMemoryCount"=0,"orphanedReusableVidMemoryBytes"=0,"context2DCount"=3,"inUseSysMemoryBytes"=18446744072714203136,"bufferSwapCount"=793,"orphanedNonReusableVidMemoryBytes"=0,"contextGLCount"=12,"finish2DWaitTime"=0,"Device Unit 2 Utilization %"=0,"gartSizeBytes"=1610612736,"recoveryCount"=0,"stdTexturePageInBytes"=1974272,"agprefTextureCreationBytes"=430080,"gartUsedBytes"=565760000,"surfaceWriteLockIdleWaitTime"=0,"finishGLWaitTime"=0,"surfaceBufferPageInBytes"=50049024,"iosurfaceTextureCreationBytes"=698777600,"finishCLWaitTime"=0,"finishVideoWaitTime"=0,"contextCLCount"=0,"Device Unit 3 Utilization %"=0,"freeSurfaceBackingWaitTime"=0,"swapCompleteGLWaitTime"=0,"orphanedNonReusableSysMemoryBytes"=0,"inUseVidMemoryBytes"=0,"agpTextureCreationBytes"=104022016,"stdTextureCreationBytes"=697712640,"agpTextureCreationCount"=830,"stdTextureCreationCount"=3303,"surfaceSetShapeIdleWaitTime"=0,"gartFreeBytes"=1044852736,"hardwareSubmitWaitTime"=0,"bufferFlipCount"=0,"textureVolunteerUnloadBytes"=0,"swapComplete2DWaitTime"=0,"surfaceBufferPageOutBytes"=0,"Device Utilization %"=1,"hardwareWaitTime"=91213026,"contextVideoCount"=0,"freeSurfaceSwapBufferWaitTime"=0,"orphanedNonReusableVidMemoryCount"=0}
      "InternalStatistics" = {}
      "VRAM,totalMB" = 1536
      "MetalCoalesce" = 0
      "IOGVACodec" = "Gen75"
      "IOVARendererID" = 17301508
    }

@aaronvandoren
Copy link

Were you ever able to calculate GPU processor usage % for GPU drivers that don't have the properties 'Device Utilization %' or 'GPU Core Utilization'?

@chockenberry
Copy link
Author

chockenberry commented Aug 1, 2019

Here is the code I landed on:

NSNumber *gpuUtilization = nil;
if (performanceProperties[@"Device Utilization %"]) {
	// chockenberry
	// iMac15,1 - AMDRadeonX4000
	
	// alanhussey
	// MacBookPro11,3 - GeForce
	// MacBookPro11,3 - AppleIntelHD5000Graphics
	
	// poreed
	// MacBookPro8,2 - AMDRadeonX3000
	
	// tkrajacic
	// MacBookPro10,1 - GeForce
	// MacBookPro10,1 - AppleIntelHD4000Graphics
	
	// therayjay
	// Macmini6,2 - AppleIntelHD4000Graphics
	
	// hotchkiss
	// MacbookPro11,5 - AMDRadeonX4000
	// MacbookPro11,5 - AppleIntelHD5000Graphics

	// owlboy
	// iMac12,2 - AMDRadeonX3000
	
	// bmike
	// MacBook8,1 - AppleIntelBDWGraphics
	
	// chrisbulow
	// MacBookPro11,1 - AppleIntelHD5000Graphics
	
	// eportlance
	// iMac12,2 - AMDRadeonX3000
	
	// bmike
	// Macmini6,2 - AppleIntelHD4000Graphics
	
	// bmike
	// MacPro6,1 - AMDRadeonX4000
	// MacPro6,1 - AMDRadeonX4000
	
	// eportlance
	// MacBookPro12,1 - AppleIntelBDWGraphics
	
	// msealand
	// iMac13,2 - GeForce
	
	// samsonjs
	// iMac15,1 - AMDRadeonX4000
	// iMac15,1 - AppleIntelHD5000Graphics
	
	// bmike
	// MacBookPro10,2
	
	// JackoPlane
	// iMac13,2 - AppleIntelHD4000Graphics
	
	gpuUtilization = performanceProperties[@"Device Utilization %"];
}
else if (performanceProperties[@"GPU Core Utilization"]) {
	// chockenberry
	// MacPro4,1 - GeForceTesla
	// MacPro4,1 - GeForceTesla
	
	// alanhussey
	// MacBookPro11,3 (value = 120000000)
	
	// thejayray
	// Macmini4,1 - GeForceTesla
	
	// samsonjs
	// MacBookPro6,2 - GeForceTesla
	
	// ender3
	// Macmini3,1 - GeForce
	
	// bmike
	// iMac13,2 - GeForce
	
	// msealand
	// iMac13,2 - GeForce (value = 0)
	
	// JackoPLane
	// iMac13,2 - GeForce (value = 60000000)
	
	gpuUtilization = performanceProperties[@"GPU Core Utilization"];
}
else {
	// no GPU statistics
	
	// IntelHD3000
	
	// chockenberry
	// MacBookAir4,2 - AppleIntelHD3000Graphics
	
	// poreed
	// MacBookPro8,2 - AppleIntelHD3000Graphics
	
	// tobiasmboelz
	// iMac11,1 - ATIRadeonX2000
	
	// owlboy
	// iMac12,2 - AppleIntelHD3000Graphics
	
	// commandtab
	// MacBookPro11,2 - AppleIntelHD5000Graphics (???)

	// owlboy
	// Macmini5,1 - AppleIntelHD3000Graphics
	
	// eportelance
	// iMac12,2 - AppleIntelHD3000Graphics
	
	// bmike
	// Macmini5,3 - AppleIntelHD3000Graphics
	
	// samsonjs
	// MacBook1,1 - AppleIntelGMA950
	
	// bmike
	// iMac13,2 - AppleIntelHD4000Graphics
}
if (gpuUtilization) {
	long rawGpuUtilization = gpuUtilization.longValue;
	if (rawGpuUtilization > 100) {
		rawGpuUtilization = rawGpuUtilization / 10000000; // scale down "GPU Core Utilization"
	}
        ...

@aaronvandoren
Copy link

Thank you so much!

This is almost exactly what I've landed on as well. Turns out some newer GPU drivers also have a property called "GPU Activity(%)" which is pretty much the same as "Device Utilization %".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment