MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / main

Function main

examples/benchmarks/blas.cpp:24–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22}
23
24int main(int argc, char** argv) {
25 double peak = 0;
26 try {
27 int device = argc > 1 ? atoi(argv[1]) : 0;
28 setDevice(device);
29
30 const std::string dtype(argc > 2 ? argv[2] : "f32");
31 const af_dtype dt = (dtype == "f16" ? f16 : f32);
32
33 if (dt == f16)
34 printf("Device %d isHalfAvailable ? %s\n", device,
35 isHalfAvailable(device) ? "yes" : "no");
36
37 info();
38
39 printf("Benchmark N-by-N matrix multiply at %s \n", dtype.c_str());
40 for (int n = 128; n <= 2048; n += 128) {
41 printf("%4d x %4d: ", n, n);
42 A = constant(1, n, n, dt);
43 double time = timeit(fn); // time in seconds
44 double gflops = 2.0 * powf(n, 3) / (time * 1e9);
45 if (gflops > peak) peak = gflops;
46
47 printf(" %4.0f Gflops\n", gflops);
48 fflush(stdout);
49 }
50 } catch (af::exception& e) {
51 fprintf(stderr, "%s\n", e.what());
52 throw;
53 }
54
55 printf(" ### peak %g GFLOPS\n", peak);
56
57 return 0;
58}

Callers

nothing calls this directly

Calls 5

isHalfAvailableFunction · 0.85
infoFunction · 0.85
constantFunction · 0.85
timeitFunction · 0.85
setDeviceFunction · 0.50

Tested by

no test coverage detected