@@ -2181,19 +2181,18 @@ def test_get_stats_l1():
21812181 # Get L1 statistics (basic operation counts)
21822182 cufile .get_stats_l1 (stats .ptr )
21832183
2184- # Verify actual field values
2185- # Access numpy recarray fields: read_ops returns a recarray with 'ok' and 'err' fields
2186- read_ops_ok = int (stats .read_ops ['ok' ][0 ])
2187- write_ops_ok = int (stats .write_ops ['ok' ][0 ])
2184+ # Verify actual field values using OpCounter class for cleaner access
2185+ read_ops = cufile .OpCounter .from_data (stats .read_ops )
2186+ write_ops = cufile .OpCounter .from_data (stats .write_ops )
21882187 read_bytes = int (stats .read_bytes )
21892188 write_bytes = int (stats .write_bytes )
21902189
2191- assert read_ops_ok > 0 , f"Expected read operations, got { read_ops_ok } "
2192- assert write_ops_ok > 0 , f"Expected write operations, got { write_ops_ok } "
2190+ assert read_ops . ok > 0 , f"Expected read operations, got { read_ops . ok } "
2191+ assert write_ops . ok > 0 , f"Expected write operations, got { write_ops . ok } "
21932192 assert read_bytes > 0 , f"Expected read bytes, got { read_bytes } "
21942193 assert write_bytes > 0 , f"Expected write bytes, got { write_bytes } "
21952194
2196- logging .info (f"Stats: reads={ read_ops_ok } , writes={ write_ops_ok } , "
2195+ logging .info (f"Stats: reads={ read_ops . ok } , writes={ write_ops . ok } , "
21972196 f"read_bytes={ read_bytes } , write_bytes={ write_bytes } " )
21982197
21992198 # Stop statistics collection
@@ -2284,7 +2283,13 @@ def test_get_stats_l2():
22842283 write_hist_total = int (stats .write_size_kb_hist .sum ())
22852284 assert read_hist_total > 0 or write_hist_total > 0 , "Expected L2 histogram data"
22862285
2287- logging .info (f"L2 Stats: read_hist_total={ read_hist_total } , write_hist_total={ write_hist_total } " )
2286+ # L2 also contains L1 basic stats - verify using OpCounter class
2287+ basic_stats = cufile .StatsLevel1 .from_data (stats .basic )
2288+ read_ops = cufile .OpCounter .from_data (basic_stats .read_ops )
2289+ write_ops = cufile .OpCounter .from_data (basic_stats .write_ops )
2290+
2291+ logging .info (f"L2 Stats: read_hist_total={ read_hist_total } , write_hist_total={ write_hist_total } , "
2292+ f"basic_reads={ read_ops .ok } , basic_writes={ write_ops .ok } " )
22882293
22892294 # Stop statistics collection
22902295 cufile .stats_stop ()
@@ -2376,17 +2381,24 @@ def test_get_stats_l3():
23762381 num_gpus = int (stats .num_gpus )
23772382 assert num_gpus >= 0 , f"Expected valid GPU count, got { num_gpus } "
23782383
2379- # Check if we have at least one GPU with stats
2380- # per_gpu_stats is a numpy recarray with shape (16,)
2384+ # Check if we have at least one GPU with stats using PerGpuStats class
23812385 gpu_with_data = False
23822386 for i in range (min (num_gpus , 16 )):
2383- gpu_stats = stats .per_gpu_stats [i ]
2384- # Access scalar values from the recarray element
2385- if int (gpu_stats ['n_total_reads' ][0 ]) > 0 or int (gpu_stats ['read_bytes' ][0 ]) > 0 :
2387+ # Access per-GPU stats using PerGpuStats class
2388+ # stats.per_gpu_stats has shape (1, 16), we need to get [0] first to get the (16,) array
2389+ # then slice [i:i+1] to get a 1-d array view (required by from_data)
2390+ per_gpu_array = stats .per_gpu_stats [0 ] # Get the (16,) array
2391+ gpu_stats = cufile .PerGpuStats .from_data (per_gpu_array [i :i + 1 ])
2392+ if gpu_stats .n_total_reads > 0 or gpu_stats .read_bytes > 0 :
23862393 gpu_with_data = True
23872394 break
23882395
2389- logging .info (f"L3 Stats: num_gpus={ num_gpus } , gpu_with_data={ gpu_with_data } " )
2396+ # L3 also contains L2 detailed stats (which includes L1 basic stats)
2397+ detailed_stats = cufile .StatsLevel2 .from_data (stats .detailed )
2398+ read_hist_total = int (detailed_stats .read_size_kb_hist .sum ())
2399+
2400+ logging .info (f"L3 Stats: num_gpus={ num_gpus } , gpu_with_data={ gpu_with_data } , "
2401+ f"detailed_read_hist={ read_hist_total } " )
23902402
23912403 # Stop statistics collection
23922404 cufile .stats_stop ()
0 commit comments