[Feature request] Redirect stderr messages to exceptions
Some of the loopy scan realization code calls dim_max/dim_min on ISL sets that may be unbounded, and ISL prints a message to stderr although the exception is caught:
>>> knl = lp.make_kernel(
"{[i,j,k]: 0<=i<n and 0<=j<=i and 0<=k<10}",
"out[i] = sum(j, j)")
>>> lp.realize_reduction(knl, force_outer_iname_for_scan="k")
isl/isl_tab_pip.c:499: unbounded optimum
I don't think there is an easy way to avoid hitting the above error message algorithmically.
I'd like to avoid random stderr output in islpy. I think the error message is useful, so it should probably be part of the exception message that is thrown by islpy.
The error handling code is here:
void isl_handle_error(isl_ctx *ctx, enum isl_error error, const char *msg,
const char *file, int line)
{
if (!ctx)
return;
isl_ctx_set_error(ctx, error);
switch (ctx->opt->on_error) {
case ISL_ON_ERROR_WARN:
fprintf(stderr, "%s:%d: %s\n", file, line, msg);
return;
case ISL_ON_ERROR_CONTINUE:
return;
case ISL_ON_ERROR_ABORT:
fprintf(stderr, "%s:%d: %s\n", file, line, msg);
abort();
return;
}
}
Right now, my current solution is loopy@ff43c095. Ideally, we would like to capture the error output as opposed to having it go to stderr
.
I can't think of a robust, portable way of capturing the output. My feeling is that this part of the code should be rewritten.
@inducer: Do you agree and do you think it makes sense to send a patch to Sven and then back-port the changes to our version of islpy?