-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Julia #14
Julia #14
Conversation
CMakeLists.txt
Outdated
@@ -114,6 +114,7 @@ add_executable(test_algo ${PERF_SOURCES}) | |||
target_link_libraries(test_algo | |||
algos | |||
"${binary_dir}/lib/libopencv_ts.a" | |||
"${binary_dir}/lib/libopencv_imgcodecs.so" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add "${binary_dir}/install/lib/libopencv_imgcodecs.so"
to target_link_libraries(algos
instead:
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -92,6 +92,7 @@ target_include_directories(algos PRIVATE
target_link_libraries(algos
"${binary_dir}/install/lib/libopencv_core.so"
"${binary_dir}/install/lib/libopencv_imgproc.so"
+ "${binary_dir}/install/lib/libopencv_imgcodecs.so"
)
@dkurt Добавил наивную реализацю на halide. На моем x86 работает заметно медленнее референсной. Cейчас буду мерить, заодно подготовлю бенчмарки на завтра. Или есть задачи актуальнее? Стала ли лучше картинка? |
@IgorErin, да, всё супер! Если увеличить |
src/julia.cpp
Outdated
void halide_julia(uint8_t* dst, int height, int width) { | ||
static const uint8_t step_bound = 255; | ||
static const uint8_t upper_bound = 4; | ||
|
||
Buffer output(dst, width, height); | ||
|
||
Var x, y; | ||
|
||
Complex c(cr, ci); | ||
|
||
Expr x_ranged; | ||
x_ranged = halide_julia_norm(x, height); | ||
|
||
Expr y_ranged; | ||
y_ranged = halide_julia_norm(y, width); | ||
|
||
Func julia; | ||
Var t; | ||
julia(x, y, t) = Complex(x_ranged, y_ranged); | ||
|
||
// loop | ||
RDom index(1, step_bound); | ||
Complex current = julia(x, y, index - 1); | ||
julia(x, y, index) = current * current + c; | ||
|
||
Expr esc_cond = Complex(julia(x, y, index)).magnitude_squared() < upper_bound; | ||
Tuple first_escape = argmin(esc_cond); | ||
|
||
// proj to result | ||
Func result; | ||
result(x, y) = cast<uint8_t>(first_escape[0]); | ||
|
||
result.realize(output); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void halide_julia(uint8_t* dst, int height, int width) { | |
static const uint8_t step_bound = 255; | |
static const uint8_t upper_bound = 4; | |
Buffer output(dst, width, height); | |
Var x, y; | |
Complex c(cr, ci); | |
Expr x_ranged; | |
x_ranged = halide_julia_norm(x, height); | |
Expr y_ranged; | |
y_ranged = halide_julia_norm(y, width); | |
Func julia; | |
Var t; | |
julia(x, y, t) = Complex(x_ranged, y_ranged); | |
// loop | |
RDom index(1, step_bound); | |
Complex current = julia(x, y, index - 1); | |
julia(x, y, index) = current * current + c; | |
Expr esc_cond = Complex(julia(x, y, index)).magnitude_squared() < upper_bound; | |
Tuple first_escape = argmin(esc_cond); | |
// proj to result | |
Func result; | |
result(x, y) = cast<uint8_t>(first_escape[0]); | |
result.realize(output); | |
} | |
void halide_julia(uint8_t* dst, int height, int width) { | |
#ifdef __riscv | |
// add later | |
#else | |
static const uint8_t step_bound = 255; | |
static const uint8_t upper_bound = 4; | |
Buffer output(dst, width, height); | |
Var x, y; | |
Complex c(cr, ci); | |
Expr x_ranged; | |
x_ranged = halide_julia_norm(x, height); | |
Expr y_ranged; | |
y_ranged = halide_julia_norm(y, width); | |
Func julia; | |
Var t; | |
julia(x, y, t) = Complex(x_ranged, y_ranged); | |
// loop | |
RDom index(1, step_bound); | |
Complex current = julia(x, y, index - 1); | |
julia(x, y, index) = current * current + c; | |
Expr esc_cond = Complex(julia(x, y, index)).magnitude_squared() < upper_bound; | |
Tuple first_escape = argmin(esc_cond); | |
// proj to result | |
Func result; | |
result(x, y) = cast<uint8_t>(first_escape[0]); | |
result.realize(output); | |
#endif | |
} |
Done: