Skip to content

Commit

Permalink
[error] [opengl] Better error message when int64 or sparse SNode not …
Browse files Browse the repository at this point in the history
…supported for OpenGL (#1783)

* [error] [opengl] Better error message when int64 or sparse SNode not supported for OpenGL

* fix

* [skip ci] missed listman

* [skip ci] enforce code format

Co-authored-by: Taichi Gardener <[email protected]>
  • Loading branch information
archibate and taichi-gardener authored Aug 27, 2020
1 parent 0077ccb commit 1be827e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
7 changes: 5 additions & 2 deletions taichi/backends/metal/struct_metal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,11 @@ class StructCompiler {
emit(" SNodeRep_{} rep_;", snty_name);
emit("}};");
} else {
TI_ERROR("SNodeType={} not supported on Metal", snode_type_name(snty));
TI_NOT_IMPLEMENTED;
TI_ERROR(
"SNodeType={} not supported on OpenGL\n"
"Consider use ti.init(ti.cpu) or ti.init(ti.cuda) if you "
"want to use sparse data structures",
snode_type_name(snode.type));
}
emit("");
}
Expand Down
9 changes: 8 additions & 1 deletion taichi/backends/opengl/codegen_opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,13 @@ class KernelGen : public IRVisitor {
// Note that the following two functions not only returns the corresponding
// data type, but also **records** the usage of `i64` and `f64`.
std::string opengl_data_type_short_name(DataType dt) {
if (dt == DataType::i64)
if (dt == DataType::i64) {
if (!TI_OPENGL_REQUIRE(used, GL_ARB_gpu_shader_int64)) {
TI_ERROR(
"Extension GL_ARB_gpu_shader_int64 not supported on your OpenGL");
}
used.int64 = true;
}
if (dt == DataType::f64)
used.float64 = true;
return data_type_short_name(dt);
Expand Down Expand Up @@ -811,6 +816,7 @@ class KernelGen : public IRVisitor {

void generate_struct_for_kernel(OffloadedStmt *stmt) {
TI_ASSERT(stmt->task_type == OffloadedStmt::TaskType::struct_for);
used.listman = true;
const std::string glsl_kernel_name = make_kernel_name();
emit("void {}()", glsl_kernel_name);
this->glsl_kernel_name_ = glsl_kernel_name;
Expand All @@ -829,6 +835,7 @@ class KernelGen : public IRVisitor {

void generate_clear_list_kernel(OffloadedStmt *stmt) {
TI_ASSERT(stmt->task_type == OffloadedStmt::TaskType::clear_list);
used.listman = true;
const std::string glsl_kernel_name = make_kernel_name();
emit("void {}()", glsl_kernel_name);
this->glsl_kernel_name_ = glsl_kernel_name;
Expand Down
7 changes: 5 additions & 2 deletions taichi/backends/opengl/struct_opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ void OpenglStructCompiler::generate_types(const SNode &snode) {
snode_info.stride = snode_child_info.stride * n + extension; // my stride
snode_info.elem_stride = snode_child_info.stride; // my child stride
} else {
TI_ERROR("SNodeType={} not supported on OpenGL",
snode_type_name(snode.type));
TI_ERROR(
"SNodeType={} not supported on OpenGL\n"
"Consider use ti.init(ti.cpu) or ti.init(ti.cuda) if you "
"want to use sparse data structures",
snode_type_name(snode.type));
TI_NOT_IMPLEMENTED;
}
}
Expand Down

0 comments on commit 1be827e

Please sign in to comment.