Skip to content

Commit c7d9580

Browse files
Add halide_error_streaming_vscale_invalid runtime error
Revert the changes in halide_error_vscale_invalid to avoid potential runtime breaking changes.
1 parent c860160 commit c7d9580

4 files changed

Lines changed: 21 additions & 7 deletions

File tree

src/CodeGen_ARM.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,7 @@ void CodeGen_ARM::compile_func(const LoweredFunc &f,
13361336
internal_assert(!in_streaming) << "Streaming mode in non-internal linkage func is unexpected\n";
13371337
Expr runtime_vscale = Call::make(Int(32), Call::get_runtime_vscale, {}, Call::PureIntrinsic);
13381338
Expr compiletime_vscale = Expr(effective_vscale);
1339-
std::vector<Expr> args{simple_name, std::string(""), runtime_vscale, compiletime_vscale};
1339+
std::vector<Expr> args{simple_name, runtime_vscale, compiletime_vscale};
13401340
Expr error = Call::make(Int(32), "halide_error_vscale_invalid", args, Call::Extern);
13411341
func.body = Block::make(AssertStmt::make(runtime_vscale == compiletime_vscale, error), func.body);
13421342
}
@@ -1345,8 +1345,8 @@ void CodeGen_ARM::compile_func(const LoweredFunc &f,
13451345
// because streaming task is basically internal linkage.
13461346
Expr runtime_vscale = Call::make(Int(32), Call::get_runtime_streaming_vscale, {}, Call::PureIntrinsic);
13471347
Expr compiletime_vscale = Expr(target.sme_streaming_vector_bits() / 128);
1348-
std::vector<Expr> args{simple_name, std::string("streaming"), runtime_vscale, compiletime_vscale};
1349-
Expr error = Call::make(Int(32), "halide_error_vscale_invalid", args, Call::Extern);
1348+
std::vector<Expr> args{simple_name, runtime_vscale, compiletime_vscale};
1349+
Expr error = Call::make(Int(32), "halide_error_streaming_vscale_invalid", args, Call::Extern);
13501350
func.body = Block::make(AssertStmt::make(runtime_vscale == compiletime_vscale, error), func.body);
13511351
}
13521352
}

src/runtime/HalideRuntime.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,10 @@ enum halide_error_code_t {
12791279

12801280
/** Profiling failed for a pipeline invocation. */
12811281
halide_error_code_cannot_profile_pipeline = -48,
1282+
1283+
/** "vscale" value of Streaming Scalable Vector detected in runtime does not
1284+
* match the streaming vscale value used in compilation. */
1285+
halide_error_code_streaming_vscale_invalid = -49,
12821286
};
12831287

12841288
/** Halide calls the functions below on various error conditions. The
@@ -1354,7 +1358,8 @@ extern int halide_error_storage_bound_too_small(void *user_context, const char *
13541358
int provided_size, int required_size);
13551359
extern int halide_error_device_crop_failed(void *user_context);
13561360
extern int halide_error_split_factor_not_positive(void *user_context, const char *func_name, const char *orig, const char *outer, const char *inner, const char *factor_str, int factor);
1357-
extern int halide_error_vscale_invalid(void *user_context, const char *func_name, const char *prefix, int runtime_vscale, int compiletime_vscale);
1361+
extern int halide_error_vscale_invalid(void *user_context, const char *func_name, int runtime_vscale, int compiletime_vscale);
1362+
extern int halide_error_streaming_vscale_invalid(void *user_context, const char *func_name, int runtime_vscale, int compiletime_vscale);
13581363
// @}
13591364

13601365
/** Optional features a compilation Target can have.

src/runtime/errors.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,20 @@ WEAK int halide_error_split_factor_not_positive(void *user_context, const char *
300300
return halide_error_code_split_factor_not_positive;
301301
}
302302

303-
WEAK int halide_error_vscale_invalid(void *user_context, const char *func_name, const char *prefix, int runtime_vscale, int compiletime_vscale) {
303+
WEAK int halide_error_vscale_invalid(void *user_context, const char *func_name, int runtime_vscale, int compiletime_vscale) {
304304
error(user_context)
305305
<< "The function " << func_name
306-
<< " is compiled with the assumption that " << prefix << " vscale of Scalable Vector is " << compiletime_vscale
307-
<< ". However, the detected runtime " << prefix << " vscale is " << runtime_vscale << ".";
306+
<< " is compiled with the assumption that vscale of Scalable Vector is " << compiletime_vscale
307+
<< ". However, the detected runtime vscale is " << runtime_vscale << ".";
308308
return halide_error_code_vscale_invalid;
309309
}
310310

311+
WEAK int halide_error_streaming_vscale_invalid(void *user_context, const char *func_name, int runtime_vscale, int compiletime_vscale) {
312+
error(user_context)
313+
<< "The function " << func_name
314+
<< " is compiled with the assumption that streaming vscale of Scalable Vector is " << compiletime_vscale
315+
<< ". However, the detected runtime streaming vscale is " << runtime_vscale << ".";
316+
return halide_error_code_streaming_vscale_invalid;
317+
}
318+
311319
} // extern "C"

src/runtime/runtime_api.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ extern "C" __attribute__((used)) void *halide_runtime_api_functions[] = {
8989
(void *)&halide_error_unaligned_host_ptr,
9090
(void *)&halide_error_storage_bound_too_small,
9191
(void *)&halide_error_device_crop_failed,
92+
(void *)&halide_error_streaming_vscale_invalid,
9293
(void *)&halide_error_vscale_invalid,
9394
(void *)&halide_float16_bits_to_double,
9495
(void *)&halide_float16_bits_to_float,

0 commit comments

Comments
 (0)