Skip to content

Commit 05ebf8d

Browse files
committed
Clang-format.
1 parent 20f9187 commit 05ebf8d

6 files changed

+22
-29
lines changed

src/ApproximationTables.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ const std::vector<Approximation> table_log = {
243243
{OO::MULPE_MAE, {9.077671e-17, 2.980232e-08, 2.000e+00}, {1.185618e-17, 7.323494e-09, 7.284e-01}, {+9.999999968426e-01, -5.000010022894e-01, +3.333352677374e-01, -2.499137788257e-01, +1.997704915474e-01, -1.685521799690e-01, +1.500791323679e-01, -1.190706400136e-01, +5.196620089570e-02}},
244244
};
245245

246-
247246
// clang-format on
248247
} // namespace
249248

src/IROperator.cpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -1400,16 +1400,15 @@ Expr fast_sin_cos_v2(const Expr &x_full, bool is_sin, ApproximationPrecision pre
14001400
Expr k = cast<int>(k_real);
14011401
Expr k_mod4 = k % 4;
14021402
Expr sin_usecos = is_sin ? ((k_mod4 == 1) || (k_mod4 == 3)) : ((k_mod4 == 0) || (k_mod4 == 2));
1403-
//sin_usecos = !sin_usecos;
1403+
// sin_usecos = !sin_usecos;
14041404
Expr flip_sign = is_sin ? (k_mod4 > 1) : ((k_mod4 == 1) || (k_mod4 == 2));
14051405

14061406
// Reduce the angle modulo pi/2: i.e., to the angle within the quadrant.
14071407
Expr x = x_full - k_real * constant(type, PI_OVER_TWO);
14081408
x = select(sin_usecos, constant(type, PI_OVER_TWO) - x, x);
14091409

1410-
14111410
const Internal::Approximation *approx = Internal::best_sin_approximation(precision, type);
1412-
//const Internal::Approximation *approx = Internal::best_cos_approximation(precision);
1411+
// const Internal::Approximation *approx = Internal::best_cos_approximation(precision);
14131412
const std::vector<double> &c = approx->coefficients;
14141413
Expr x2 = x * x;
14151414
Expr result = constant(type, c.back());
@@ -1424,17 +1423,17 @@ Expr fast_sin_cos_v2(const Expr &x_full, bool is_sin, ApproximationPrecision pre
14241423
} // namespace
14251424

14261425
Expr fast_sin(const Expr &x, ApproximationPrecision precision) {
1427-
//return fast_sin_cos(x, true);
1426+
// return fast_sin_cos(x, true);
14281427
Expr native_is_fast = target_has_feature(Target::Vulkan);
14291428
return select(native_is_fast && precision.allow_native_when_faster,
1430-
sin(x), fast_sin_cos_v2(x, true, precision));
1429+
sin(x), fast_sin_cos_v2(x, true, precision));
14311430
}
14321431

14331432
Expr fast_cos(const Expr &x, ApproximationPrecision precision) {
1434-
//return fast_sin_cos(x, false);
1433+
// return fast_sin_cos(x, false);
14351434
Expr native_is_fast = target_has_feature(Target::Vulkan);
14361435
return select(native_is_fast && precision.allow_native_when_faster,
1437-
cos(x), fast_sin_cos_v2(x, false, precision));
1436+
cos(x), fast_sin_cos_v2(x, false, precision));
14381437
}
14391438

14401439
// A vectorizable atan and atan2 implementation.

src/IROperator.h

-1
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,6 @@ Expr fast_sin(const Expr &x, ApproximationPrecision precision = {ApproximationPr
10131013
Expr fast_cos(const Expr &x, ApproximationPrecision precision = {ApproximationPrecision::MULPE, 0, 1e-5});
10141014
// @}
10151015

1016-
10171016
/** Fast vectorizable approximations for arctan and arctan2 for Float(32).
10181017
*
10191018
* Desired precision can be specified as either a maximum absolute error (MAE) or

test/correctness/fast_function_approximations.cpp

+7-9
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ struct FunctionToTest {
4343
TestRange2D extended;
4444
std::function<Expr(Expr x, Expr y)> make_reference;
4545
std::function<Expr(Expr x, Expr y, Halide::ApproximationPrecision)> make_approximation;
46-
int max_mulpe_precise{0}; // max MULPE allowed when MAE query was <= 1e-6
47-
int max_mulpe_extended{0}; // max MULPE allowed when MAE query was <= 1e-6
46+
int max_mulpe_precise{0}; // max MULPE allowed when MAE query was <= 1e-6
47+
int max_mulpe_extended{0}; // max MULPE allowed when MAE query was <= 1e-6
4848
int test_bits{0xff};
4949
} functions_to_test[] = {
5050
// clang-format off
@@ -141,7 +141,6 @@ struct PrecisionToTest {
141141
{{ApproximationPrecision::MULPE_MAE, 0, 5e-7}, "MULPE+MAE"},
142142
};
143143

144-
145144
int main(int argc, char **argv) {
146145
Target target = get_jit_target_from_environment();
147146
setlocale(LC_NUMERIC, "");
@@ -166,17 +165,17 @@ int main(int argc, char **argv) {
166165
for (const std::pair<TestRange2D, std::string> &test_range_and_name : ranges) {
167166
TestRange2D range = test_range_and_name.first;
168167
printf("Testing fast_%s on its %s range ([%f, %f], [%f, %f])...\n", ftt.name.c_str(), test_range_and_name.second.c_str(),
169-
range.x.l, range.x.u, range.y.l, range.y.u);
168+
range.x.l, range.x.u, range.y.l, range.y.u);
170169
// Reference:
171170
Expr arg_x = range.x.l * (1.0f - t0) + range.x.u * t0;
172171
Expr arg_y = range.y.l * (1.0f - t1) + range.y.u * t1;
173172
Func ref_func{ftt.name + "_ref"};
174173
ref_func(x, y) = ftt.make_reference(arg_x, arg_y);
175-
ref_func.realize(out_ref); // No schedule: scalar evaluation using libm calls on CPU.
174+
ref_func.realize(out_ref); // No schedule: scalar evaluation using libm calls on CPU.
176175
out_ref.copy_to_host();
177176
for (const PrecisionToTest &test : precisions_to_test) {
178177
Halide::ApproximationPrecision prec = test.precision;
179-
prec.allow_native_when_faster = false; // We want to actually validate our approximation.
178+
prec.allow_native_when_faster = false; // We want to actually validate our approximation.
180179

181180
Func approx_func{ftt.name + "_approx"};
182181
approx_func(x, y) = ftt.make_approximation(arg_x, arg_y, prec);
@@ -211,8 +210,8 @@ int main(int argc, char **argv) {
211210
}
212211

213212
printf(" fast_%s Approx[%s-optimized, TargetMAE=%.0e] | MaxAbsError: %.4e | MaxULPError: %'14d | MaxMantissaError: %2d",
214-
ftt.name.c_str(), test.objective.c_str(), prec.constraint_max_absolute_error,
215-
max_absolute_error, max_ulp_error, max_mantissa_error);
213+
ftt.name.c_str(), test.objective.c_str(), prec.constraint_max_absolute_error,
214+
max_absolute_error, max_ulp_error, max_mantissa_error);
216215

217216
if (test_range_and_name.second == "precise") {
218217
if ((ftt.test_bits & VALIDATE_MAE_ON_PRECISE)) {
@@ -261,4 +260,3 @@ int main(int argc, char **argv) {
261260
printf("Passed %d / %d accuracy tests.\n", num_tests_passed, num_tests);
262261
printf("Success!\n");
263262
}
264-

test/correctness/fast_trigonometric.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ int main(int argc, char **argv) {
3030
const float cos_x_ref = cos(x);
3131
if (std::abs(sin_x_ref - sin_x) > 1e-5) {
3232
fprintf(stderr, "fast_sin(%.6f) = %.20f not equal to %.20f\n", x, sin_x, sin_x_ref);
33-
//exit(1);
33+
// exit(1);
3434
}
3535
if (std::abs(cos_x_ref - cos_x) > 1e-5) {
3636
fprintf(stderr, "fast_cos(%.6f) = %.20f not equal to %.20f\n", x, cos_x, cos_x_ref);
37-
//exit(1);
37+
// exit(1);
3838
}
3939
}
4040
printf("Success!\n");

test/performance/fast_function_approximations.cpp

+7-9
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ int main(int argc, char **argv) {
152152

153153
// Print results for this function
154154
printf(" %s : %9.5f ns per evaluation [per invokation: %6.3f ms]\n",
155-
ftt.name.c_str(),
156-
pipeline_time_ref * pipeline_time_to_ns_per_evaluation,
157-
pipeline_time_ref * 1e3);
155+
ftt.name.c_str(),
156+
pipeline_time_ref * pipeline_time_to_ns_per_evaluation,
157+
pipeline_time_ref * 1e3);
158158

159159
for (PrecisionToTest &precision : precisions_to_test) {
160160
double approx_pipeline_time;
@@ -163,7 +163,7 @@ int main(int argc, char **argv) {
163163
{
164164
Func approx_func{ftt.name + "_approx"};
165165
Halide::ApproximationPrecision prec = precision.precision;
166-
prec.allow_native_when_faster = false; // Always test the actual tabular functions.
166+
prec.allow_native_when_faster = false; // Always test the actual tabular functions.
167167
approx_func(x, y) = sum(ftt.make_approximation(arg_x, arg_y, arg_z, prec));
168168
schedule(approx_func);
169169
approx_func.compile_jit();
@@ -180,14 +180,13 @@ int main(int argc, char **argv) {
180180
{
181181
Func approx_func{ftt.name + "_approx_maybe_native"};
182182
Halide::ApproximationPrecision prec = precision.precision;
183-
prec.allow_native_when_faster = true; // Now make sure it's always at least as fast!
183+
prec.allow_native_when_faster = true; // Now make sure it's always at least as fast!
184184
approx_func(x, y) = sum(ftt.make_approximation(arg_x, arg_y, arg_z, prec));
185185
schedule(approx_func);
186186
approx_func.compile_jit();
187187
approx_maybe_native_pipeline_time = benchmark([&]() { approx_func.realize(buffer_out); buffer_out.device_sync(); }, bcfg);
188188
}
189189

190-
191190
// Check for speedup
192191
bool should_be_faster = true;
193192
for (Target::Feature f : ftt.not_faster_on) {
@@ -197,7 +196,6 @@ int main(int argc, char **argv) {
197196
}
198197
if (should_be_faster) num_tests++;
199198

200-
201199
printf(" [force_approx");
202200
if (pipeline_time_ref < approx_pipeline_time * 0.90) {
203201
printf(" %6.1f%% slower", -100.0f * (1.0f - approx_pipeline_time / pipeline_time_ref));
@@ -208,11 +206,11 @@ int main(int argc, char **argv) {
208206
}
209207
} else if (pipeline_time_ref < approx_pipeline_time * 1.10) {
210208
printf(" equally fast (%+5.1f%% faster)",
211-
100.0f * (1.0f - approx_pipeline_time / pipeline_time_ref));
209+
100.0f * (1.0f - approx_pipeline_time / pipeline_time_ref));
212210
if (should_be_faster) num_passed++;
213211
} else {
214212
printf(" %4.1f%% faster",
215-
100.0f * (1.0f - approx_pipeline_time / pipeline_time_ref));
213+
100.0f * (1.0f - approx_pipeline_time / pipeline_time_ref));
216214
if (should_be_faster) num_passed++;
217215
}
218216
printf("]");

0 commit comments

Comments
 (0)