| 61 | } |
| 62 | |
| 63 | void Benchmark() { |
| 64 | const bool symm_lhs = std::is_floating_point<LhsScalar>::value || |
| 65 | GetBoolEnvVarOrFalse("SYMM_LHS"); |
| 66 | const bool symm_rhs = std::is_floating_point<RhsScalar>::value || |
| 67 | GetBoolEnvVarOrFalse("SYMM_RHS"); |
| 68 | const bool benchmark_cubic = GetBoolEnvVarOrFalse("RUY_BENCHMARK_CUBIC"); |
| 69 | std::vector<BenchmarkShape> shapes; |
| 70 | if (benchmark_cubic) { |
| 71 | #ifdef _WIN32 |
| 72 | _putenv_s("QUICK_BENCHMARK", "1"); |
| 73 | #else |
| 74 | setenv("QUICK_BENCHMARK", "1", 0); |
| 75 | #endif |
| 76 | std::vector<int> sizes; |
| 77 | for (int i = 16; i <= 4096; i *= 2) { |
| 78 | sizes.push_back(i); |
| 79 | if (i < 4096) { |
| 80 | sizes.push_back(i * 3 / 2); |
| 81 | } |
| 82 | } |
| 83 | for (int i : sizes) { |
| 84 | BenchmarkShape shape; |
| 85 | shape.rows = i; |
| 86 | shape.cols = i; |
| 87 | shape.depth = i; |
| 88 | shape.symm_lhs = symm_lhs; |
| 89 | shape.symm_rhs = symm_rhs; |
| 90 | shapes.push_back(shape); |
| 91 | } |
| 92 | } else { |
| 93 | BenchmarkShape shape; |
| 94 | shape.rows = GetIntEnvVarOrZero("ROWS"); |
| 95 | shape.cols = GetIntEnvVarOrZero("COLS"); |
| 96 | shape.depth = GetIntEnvVarOrZero("DEPTH"); |
| 97 | if (!shape.rows || !shape.depth || !shape.cols) { |
| 98 | fprintf(stderr, |
| 99 | "Please specify positive sizes with these env vars: ROWS, DEPTH, " |
| 100 | "COLS.\n"); |
| 101 | exit(1); |
| 102 | } |
| 103 | shape.symm_lhs = symm_lhs; |
| 104 | shape.symm_rhs = symm_rhs; |
| 105 | shapes.push_back(shape); |
| 106 | } |
| 107 | |
| 108 | for (int i = 0; i < shapes.size(); i++) { |
| 109 | const auto& shape = shapes[i]; |
| 110 | const auto& results = BenchmarkRCC<TestSetType>(shape); |
| 111 | if (i == 0) { |
| 112 | if (benchmark_cubic) { |
| 113 | printf("size"); |
| 114 | for (const auto& result : results) { |
| 115 | printf(",%s", PathName(*result).c_str()); |
| 116 | } |
| 117 | printf("\n"); |
| 118 | } else { |
| 119 | printf("path,shape,Gop/s\n"); |
| 120 | } |