Skip to content

Commit

Permalink
Improve performance of simple convolution functions
Browse files Browse the repository at this point in the history
  • Loading branch information
octu0 committed Apr 12, 2021
1 parent 7661853 commit e6d7fd5
Show file tree
Hide file tree
Showing 77 changed files with 17 additions and 16 deletions.
3 changes: 2 additions & 1 deletion blurry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ Func edge_fn(Func input, Param<int32_t> width, Param<int32_t> height){
Func gx = Func("gx");
gx(x, y) = (in(x + 1, y) - in(x - 1, y)) / 2;

Func edge = Func("edge");
Func edge = Func("edgedetect");
Expr pow_gy = fast_pow(gy(x, y), 2);
Expr pow_gx = fast_pow(gx(x, y), 2);
Expr magnitude = pow_gy + pow_gx;
Expand All @@ -909,6 +909,7 @@ Func edge_fn(Func input, Param<int32_t> width, Param<int32_t> height){
edge.compute_root()
.parallel(ch);

in.compute_root();
return edge;
}

Expand Down
10 changes: 5 additions & 5 deletions edge.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ package blurry

/*
#cgo CFLAGS: -I${SRCDIR}/include
#cgo darwin LDFLAGS: -L${SRCDIR}/lib -lruntime_osx -ledge_osx -ldl -lm
#cgo linux LDFLAGS: -L${SRCDIR}/lib -lruntime_linux -ledge_linux -ldl -lm
#cgo darwin LDFLAGS: -L${SRCDIR}/lib -lruntime_osx -ledgedetect_osx -ldl -lm
#cgo linux LDFLAGS: -L${SRCDIR}/lib -lruntime_linux -ledgedetect_linux -ldl -lm
#include <stdlib.h>
#include <string.h>
#include "bridge.h"
#ifdef __APPLE__
#include "libedge_osx.h"
#include "libedgedetect_osx.h"
#elif __linux__
#include "libedge_linux.h"
#include "libedgedetect_linux.h"
#endif
int libedge(unsigned char *src, int32_t width, int32_t height, unsigned char *out) {
Expand All @@ -25,7 +25,7 @@ int libedge(unsigned char *src, int32_t width, int32_t height, unsigned char *ou
return 1;
}
int ret = edge(in_rgba_buf, width, height, out_rgba_buf);
int ret = edgedetect(in_rgba_buf, width, height, out_rgba_buf);
free_buf(in_rgba_buf);
free_buf(out_rgba_buf);
return ret;
Expand Down
10 changes: 5 additions & 5 deletions include/libedge_osx.h → include/libedgedetect_linux.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef HALIDE__libedge_osx_h
#define HALIDE__libedge_osx_h
#ifndef HALIDE__libedgedetect_linux_h
#define HALIDE__libedgedetect_linux_h
#include <stdint.h>

// Forward declarations of the types used in the interface
Expand Down Expand Up @@ -41,13 +41,13 @@ extern "C" {
#endif

HALIDE_FUNCTION_ATTRS
int edge(struct halide_buffer_t *_src_buffer, int32_t _width, int32_t _height, struct halide_buffer_t *_edge_buffer);
int edgedetect(struct halide_buffer_t *_src_buffer, int32_t _width, int32_t _height, struct halide_buffer_t *_edgedetect_buffer);

HALIDE_FUNCTION_ATTRS
int edge_argv(void **args);
int edgedetect_argv(void **args);

HALIDE_FUNCTION_ATTRS
const struct halide_filter_metadata_t *edge_metadata();
const struct halide_filter_metadata_t *edgedetect_metadata();

#ifdef __cplusplus
} // extern "C"
Expand Down
10 changes: 5 additions & 5 deletions include/libedge_linux.h → include/libedgedetect_osx.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef HALIDE__libedge_linux_h
#define HALIDE__libedge_linux_h
#ifndef HALIDE__libedgedetect_osx_h
#define HALIDE__libedgedetect_osx_h
#include <stdint.h>

// Forward declarations of the types used in the interface
Expand Down Expand Up @@ -41,13 +41,13 @@ extern "C" {
#endif

HALIDE_FUNCTION_ATTRS
int edge(struct halide_buffer_t *_src_buffer, int32_t _width, int32_t _height, struct halide_buffer_t *_edge_buffer);
int edgedetect(struct halide_buffer_t *_src_buffer, int32_t _width, int32_t _height, struct halide_buffer_t *_edgedetect_buffer);

HALIDE_FUNCTION_ATTRS
int edge_argv(void **args);
int edgedetect_argv(void **args);

HALIDE_FUNCTION_ATTRS
const struct halide_filter_metadata_t *edge_metadata();
const struct halide_filter_metadata_t *edgedetect_metadata();

#ifdef __cplusplus
} // extern "C"
Expand Down
Binary file modified lib/libblockmozaic_linux.a
Binary file not shown.
Binary file modified lib/libblockmozaic_osx.a
Binary file not shown.
Binary file modified lib/libboxblur_linux.a
Binary file not shown.
Binary file modified lib/libboxblur_osx.a
Binary file not shown.
Binary file modified lib/libbrightness_linux.a
Binary file not shown.
Binary file modified lib/libbrightness_osx.a
Binary file not shown.
Binary file modified lib/libcanny_dilate_linux.a
Binary file not shown.
Binary file modified lib/libcanny_dilate_osx.a
Binary file not shown.
Binary file modified lib/libcanny_linux.a
Binary file not shown.
Binary file modified lib/libcanny_morphology_close_linux.a
Binary file not shown.
Binary file modified lib/libcanny_morphology_close_osx.a
Binary file not shown.
Binary file modified lib/libcanny_morphology_open_linux.a
Binary file not shown.
Binary file modified lib/libcanny_morphology_open_osx.a
Binary file not shown.
Binary file modified lib/libcanny_osx.a
Binary file not shown.
Binary file modified lib/libcloneimg_linux.a
Binary file not shown.
Binary file modified lib/libcloneimg_osx.a
Binary file not shown.
Binary file modified lib/libcontrast_linux.a
Binary file not shown.
Binary file modified lib/libcontrast_osx.a
Binary file not shown.
Binary file modified lib/libdilation_linux.a
Binary file not shown.
Binary file modified lib/libdilation_osx.a
Binary file not shown.
Binary file removed lib/libedge_osx.a
Binary file not shown.
Binary file renamed lib/libedge_linux.a → lib/libedgedetect_linux.a
Binary file not shown.
Binary file added lib/libedgedetect_osx.a
Binary file not shown.
Binary file modified lib/libemboss_linux.a
Binary file not shown.
Binary file modified lib/libemboss_osx.a
Binary file not shown.
Binary file modified lib/liberosion_linux.a
Binary file not shown.
Binary file modified lib/liberosion_osx.a
Binary file not shown.
Binary file modified lib/libgammacorrection_linux.a
Binary file not shown.
Binary file modified lib/libgammacorrection_osx.a
Binary file not shown.
Binary file modified lib/libgaussianblur_linux.a
Binary file not shown.
Binary file modified lib/libgaussianblur_osx.a
Binary file not shown.
Binary file modified lib/libgradient_linux.a
Binary file not shown.
Binary file modified lib/libgradient_osx.a
Binary file not shown.
Binary file modified lib/libgrayscale_linux.a
Binary file not shown.
Binary file modified lib/libgrayscale_osx.a
Binary file not shown.
Binary file modified lib/libhighpass_linux.a
Binary file not shown.
Binary file modified lib/libhighpass_osx.a
Binary file not shown.
Binary file modified lib/libinvert_linux.a
Binary file not shown.
Binary file modified lib/libinvert_osx.a
Binary file not shown.
Binary file modified lib/liblaplacian_linux.a
Binary file not shown.
Binary file modified lib/liblaplacian_osx.a
Binary file not shown.
Binary file modified lib/libmatch_template_ncc_linux.a
Binary file not shown.
Binary file modified lib/libmatch_template_ncc_osx.a
Binary file not shown.
Binary file modified lib/libmatch_template_sad_linux.a
Binary file not shown.
Binary file modified lib/libmatch_template_sad_osx.a
Binary file not shown.
Binary file modified lib/libmatch_template_ssd_linux.a
Binary file not shown.
Binary file modified lib/libmatch_template_ssd_osx.a
Binary file not shown.
Binary file modified lib/libmatch_template_zncc_linux.a
Binary file not shown.
Binary file modified lib/libmatch_template_zncc_osx.a
Binary file not shown.
Binary file modified lib/libmorphology_close_linux.a
Binary file not shown.
Binary file modified lib/libmorphology_close_osx.a
Binary file not shown.
Binary file modified lib/libmorphology_gradient_linux.a
Binary file not shown.
Binary file modified lib/libmorphology_gradient_osx.a
Binary file not shown.
Binary file modified lib/libmorphology_open_linux.a
Binary file not shown.
Binary file modified lib/libmorphology_open_osx.a
Binary file not shown.
Binary file modified lib/libprepare_ncc_template_linux.a
Binary file not shown.
Binary file modified lib/libprepare_ncc_template_osx.a
Binary file not shown.
Binary file modified lib/libprepare_zncc_template_linux.a
Binary file not shown.
Binary file modified lib/libprepare_zncc_template_osx.a
Binary file not shown.
Binary file modified lib/libprepared_match_template_ncc_linux.a
Binary file not shown.
Binary file modified lib/libprepared_match_template_ncc_osx.a
Binary file not shown.
Binary file modified lib/libprepared_match_template_zncc_linux.a
Binary file not shown.
Binary file modified lib/libprepared_match_template_zncc_osx.a
Binary file not shown.
Binary file modified lib/librotate0_linux.a
Binary file not shown.
Binary file modified lib/librotate0_osx.a
Binary file not shown.
Binary file modified lib/librotate180_linux.a
Binary file not shown.
Binary file modified lib/librotate180_osx.a
Binary file not shown.
Binary file modified lib/librotate270_linux.a
Binary file not shown.
Binary file modified lib/librotate270_osx.a
Binary file not shown.
Binary file modified lib/librotate90_linux.a
Binary file not shown.
Binary file modified lib/librotate90_osx.a
Binary file not shown.
Binary file modified lib/libsobel_linux.a
Binary file not shown.
Binary file modified lib/libsobel_osx.a
Binary file not shown.

0 comments on commit e6d7fd5

Please sign in to comment.