Revision: 400
http://assorted.svn.sourceforge.net/assorted/?rev=400&view=rev
Author: yangzhang
Date: 2008-02-12 23:58:00 -0800 (Tue, 12 Feb 2008)
Log Message:
-----------
added libnuma env info
Modified Paths:
--------------
numa-bench/trunk/src/avail.cc
Modified: numa-bench/trunk/src/avail.cc
===================================================================
--- numa-bench/trunk/src/avail.cc 2008-02-13 03:26:47 UTC (rev 399)
+++ numa-bench/trunk/src/avail.cc 2008-02-13 07:58:00 UTC (rev 400)
@@ -1,7 +1,38 @@
+//
+// Dump environment information provided by libnuma.
+//
+
+#include <iostream>
+#include <iomanip>
#include <numa.h>
+#include <commons/check.h>
+
+using namespace commons;
+using namespace std;
+
int
main()
{
- return numa_available() < 0;
+ if (numa_available() < 0) {
+ cout << "no numa" << endl;
+ } else {
+ for (int node = 0; node <= numa_max_node(); node++) {
+ // Print node sizes.
+ long long free, size = numa_node_size64(node, &free);
+ check(-1 != size);
+ cout << "node " << node << " size " << size << " free " << free << " cpus ";
+
+ // Print node CPUs.
+ const int buflen = 512;
+ unsigned long buffer[buflen];
+ check(0 == numa_node_to_cpus(node, buffer, buflen));
+ // TODO # cpus?
+ for (int i = 0; i < 1; i++) {
+ cout << hex << setfill('0') << setw(4) << buffer[i] << dec << ' ';
+ }
+ cout << endl;
+ }
+ }
+ return 0;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|