Skip to content

Commit 34b4553

Browse files
Apply pre-commit auto-fixes
1 parent 6223372 commit 34b4553

2 files changed

Lines changed: 58 additions & 30 deletions

File tree

doc/BuildingHalideWithCMake.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ building the core pieces of Halide.
150150
| [flatbuffers] | `~=23.5.26` | `WITH_SERIALIZATION=ON` | |
151151
| [wabt] | `==1.0.39` | `Halide_WASM_BACKEND=wabt` | Does not have a stable API; exact version required. |
152152
| [V8] | trunk | `Halide_WASM_BACKEND=V8` | Difficult to build. See [WebAssembly.md] |
153-
| [WAMR] | `>=2.4.3` | `Halide_WASM_BACKEND=WAMR` | Built natively as static library from source. |
153+
| [WAMR] | `>=2.4.3` | `Halide_WASM_BACKEND=WAMR` | Built natively as static library from source. |
154154
| [Python] | `>=3.10` | `WITH_PYTHON_BINDINGS=ON` | |
155155
| [pybind11] | `~=2.11.1` | `WITH_PYTHON_BINDINGS=ON` | |
156156

@@ -455,8 +455,8 @@ apply when `WITH_TESTS=ON`:
455455

456456
The following option selects the execution engine for in-process WASM testing:
457457

458-
| Option | Default | Description |
459-
| --------------------- | ------- | ---------------------------------------------------------------------------------------- |
458+
| Option | Default | Description |
459+
| --------------------- | ------- | ------------------------------------------------------------------------------------------------ |
460460
| `Halide_WASM_BACKEND` | `wabt` | Select the backend for WASM testing. Can be `wabt`, `V8`, `WAMR` or a false value such as `OFF`. |
461461

462462
## Installing

src/WasmExecutor.cpp

Lines changed: 55 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2314,16 +2314,34 @@ float sinf_native(wasm_exec_env_t exec_env, float x) {
23142314
return ::sinf(x);
23152315
}
23162316

2317-
double sin_native(wasm_exec_env_t exec_env, double x) { return ::sin(x); }
2318-
double cos_native(wasm_exec_env_t exec_env, double x) { return ::cos(x); }
2319-
double exp_native(wasm_exec_env_t exec_env, double x) { return ::exp(x); }
2320-
double log_native(wasm_exec_env_t exec_env, double x) { return ::log(x); }
2321-
double pow_native(wasm_exec_env_t exec_env, double x, double y) { return ::pow(x, y); }
2317+
double sin_native(wasm_exec_env_t exec_env, double x) {
2318+
return ::sin(x);
2319+
}
2320+
double cos_native(wasm_exec_env_t exec_env, double x) {
2321+
return ::cos(x);
2322+
}
2323+
double exp_native(wasm_exec_env_t exec_env, double x) {
2324+
return ::exp(x);
2325+
}
2326+
double log_native(wasm_exec_env_t exec_env, double x) {
2327+
return ::log(x);
2328+
}
2329+
double pow_native(wasm_exec_env_t exec_env, double x, double y) {
2330+
return ::pow(x, y);
2331+
}
23222332

2323-
float cosf_native(wasm_exec_env_t exec_env, float x) { return ::cosf(x); }
2324-
float expf_native(wasm_exec_env_t exec_env, float x) { return ::expf(x); }
2325-
float logf_native(wasm_exec_env_t exec_env, float x) { return ::logf(x); }
2326-
float powf_native(wasm_exec_env_t exec_env, float x, float y) { return ::powf(x, y); }
2333+
float cosf_native(wasm_exec_env_t exec_env, float x) {
2334+
return ::cosf(x);
2335+
}
2336+
float expf_native(wasm_exec_env_t exec_env, float x) {
2337+
return ::expf(x);
2338+
}
2339+
float logf_native(wasm_exec_env_t exec_env, float x) {
2340+
return ::logf(x);
2341+
}
2342+
float powf_native(wasm_exec_env_t exec_env, float x, float y) {
2343+
return ::powf(x, y);
2344+
}
23272345

23282346
float extendhfsf2_native(wasm_exec_env_t exec_env, int32_t in) {
23292347
return (float)float16_t::make_from_bits(in);
@@ -2391,17 +2409,29 @@ int32_t strlen_native(wasm_exec_env_t exec_env, int32_t s_ptr) {
23912409
return 0;
23922410
}
23932411

2394-
#define DEFINE_WAMR_MATH_1(name) \
2395-
float name##f_native(wasm_exec_env_t exec_env, float x) { return ::name##f(x); } \
2396-
double name##_native(wasm_exec_env_t exec_env, double x) { return ::name(x); }
2412+
#define DEFINE_WAMR_MATH_1(name) \
2413+
float name##f_native(wasm_exec_env_t exec_env, float x) { \
2414+
return ::name##f(x); \
2415+
} \
2416+
double name##_native(wasm_exec_env_t exec_env, double x) { \
2417+
return ::name(x); \
2418+
}
23972419

2398-
#define DEFINE_WAMR_MATH_2(name) \
2399-
float name##f_native(wasm_exec_env_t exec_env, float x, float y) { return ::name##f(x, y); } \
2400-
double name##_native(wasm_exec_env_t exec_env, double x, double y) { return ::name(x, y); }
2420+
#define DEFINE_WAMR_MATH_2(name) \
2421+
float name##f_native(wasm_exec_env_t exec_env, float x, float y) { \
2422+
return ::name##f(x, y); \
2423+
} \
2424+
double name##_native(wasm_exec_env_t exec_env, double x, double y) { \
2425+
return ::name(x, y); \
2426+
}
24012427

2402-
#define DEFINE_WAMR_MATH_3(name) \
2403-
float name##f_native(wasm_exec_env_t exec_env, float x, float y, float z) { return ::name##f(x, y, z); } \
2404-
double name##_native(wasm_exec_env_t exec_env, double x, double y, double z) { return ::name(x, y, z); }
2428+
#define DEFINE_WAMR_MATH_3(name) \
2429+
float name##f_native(wasm_exec_env_t exec_env, float x, float y, float z) { \
2430+
return ::name##f(x, y, z); \
2431+
} \
2432+
double name##_native(wasm_exec_env_t exec_env, double x, double y, double z) { \
2433+
return ::name(x, y, z); \
2434+
}
24052435

24062436
DEFINE_WAMR_MATH_1(acos)
24072437
DEFINE_WAMR_MATH_1(acosh)
@@ -2432,7 +2462,7 @@ wasm32_ptr_t hostbuf_to_wasmbuf_wamr(wasm_module_inst_t instance, const halide_b
24322462
const size_t dims_size_in_bytes = sizeof(halide_dimension_t) * src->dimensions;
24332463
const size_t dims_offset = sizeof(wasm_halide_buffer_t);
24342464
const size_t mem_needed_base = sizeof(wasm_halide_buffer_t) + dims_size_in_bytes;
2435-
2465+
24362466
// We need the host data to be 16-byte aligned.
24372467
// We over-allocate by 16 bytes to allow for alignment adjustment.
24382468
const size_t host_offset_base = align_up(mem_needed_base, 16);
@@ -2445,7 +2475,7 @@ wasm32_ptr_t hostbuf_to_wasmbuf_wamr(wasm_module_inst_t instance, const halide_b
24452475

24462476
// Calculate aligned host address in Wasm space
24472477
uint64_t host_wbuf = wbuf + host_offset_base;
2448-
uint64_t aligned_host_wbuf = (host_wbuf + 15) & ~15; // Align to 16
2478+
uint64_t aligned_host_wbuf = (host_wbuf + 15) & ~15; // Align to 16
24492479
size_t host_offset = aligned_host_wbuf - wbuf;
24502480

24512481
wasm_halide_buffer_t *dst = (wasm_halide_buffer_t *)native_ptr;
@@ -2547,7 +2577,6 @@ WasmModuleContents::WasmModuleContents(
25472577
store(wabt::interp::Store(calc_features(halide_module.target())))
25482578
#endif
25492579

2550-
25512580
{
25522581

25532582
#if WITH_WABT || WITH_V8 || WITH_WAMR
@@ -2625,8 +2654,7 @@ WasmModuleContents::WasmModuleContents(
26252654
{"fmax", (void *)fmax_native, "(FF)F", NULL},
26262655

26272656
{"fmaf", (void *)fmaf_native, "(fff)f", NULL},
2628-
{"fma", (void *)fma_native, "(FFF)F", NULL}
2629-
};
2657+
{"fma", (void *)fma_native, "(FFF)F", NULL}};
26302658
wasm_runtime_register_natives("env", native_symbols, sizeof(native_symbols) / sizeof(NativeSymbol));
26312659

26322660
char error_buf[128];
@@ -2862,7 +2890,7 @@ int WasmModuleContents::run(const void *const *args) {
28622890

28632891
wasm_runtime_set_custom_data(instance, jit_user_context);
28642892

2865-
int32_t export_count = wasm_runtime_get_export_count(module);
2893+
int32_t export_count = wasm_runtime_get_export_count(module);
28662894
wasm_function_inst_t func = nullptr;
28672895
std::string func_name;
28682896
for (int32_t i = 0; i < export_count; i++) {
@@ -2918,15 +2946,15 @@ int WasmModuleContents::run(const void *const *args) {
29182946
}
29192947
}
29202948

2921-
wasm_runtime_init_thread_env();
2949+
wasm_runtime_init_thread_env();
29222950

29232951
wasm_val_t results[1];
29242952
bool call_success = wasm_runtime_call_wasm_a(exec_env, func, 1, results, wamr_args_vals.size(), wamr_args_vals.data());
29252953
internal_assert(call_success) << "wasm_runtime_call_wasm_a failed: " << wasm_runtime_get_exception(instance);
29262954

2927-
int result = results[0].of.i32;
2955+
int result = results[0].of.i32;
29282956

2929-
wasm_runtime_destroy_thread_env();
2957+
wasm_runtime_destroy_thread_env();
29302958

29312959
if (result == 0) {
29322960
for (size_t i = 0; i < arguments.size(); i++) {

0 commit comments

Comments
 (0)