Commit 24032548 authored by Ignacio Losiggio's avatar Ignacio Losiggio
Browse files

cuadrados: Agregada implementación en AVX2

parent 875e659a
......@@ -11,7 +11,7 @@ FILTROS = Cuadrados Manchas Offset Ruido Sharpen
FILTROS_OBJ = $(addsuffix .o, $(FILTROS)) $(addsuffix _asm.o, $(FILTROS)) \
$(addsuffix _c.o, $(FILTROS)) Manchas_mvec.o Manchas_simple.o \
Offset_avx.o
Offset_avx.o Cuadrados_avx.o
LIBS_OBJS = libbmp.o imagenes.o utils.o
MAIN_OBJS = tp2.o cli.o
MAIN_OBJS_CON_PATH = $(addprefix $(BUILD_DIR)/, $(MAIN_OBJS))
......
......@@ -10,8 +10,14 @@ void Cuadrados_asm (uint8_t *src, uint8_t *dst, int width, int height,
void Cuadrados_c (uint8_t *src, uint8_t *dst, int width, int height,
int src_row_size, int dst_row_size);
void Cuadrados_avx (uint8_t *src, uint8_t *dst, int width, int height,
int src_row_size, int dst_row_size);
typedef void (Cuadrados_fn_t) (uint8_t*, uint8_t*, int, int, int, int);
static Cuadrados_fn_t* implementaciones[] = {
Cuadrados_c, Cuadrados_asm, Cuadrados_avx
};
void leer_params_Cuadrados(configuracion_t *config, int argc, char *argv[]) {
......@@ -19,7 +25,7 @@ void leer_params_Cuadrados(configuracion_t *config, int argc, char *argv[]) {
void aplicar_Cuadrados(configuracion_t *config)
{
Cuadrados_fn_t *Cuadrados = SWITCH_C_ASM( config, Cuadrados_c, Cuadrados_asm );
Cuadrados_fn_t *Cuadrados = implementaciones[config->tipo_filtro];
buffer_info_t info = config->src;
Cuadrados(info.bytes, config->dst.bytes, info.width, info.height,
info.row_size, config->dst.row_size);
......
section .rodata
BLACK: times 8 dd 0xFF000000
section .text
global Cuadrados_avx
Cuadrados_avx:
; rdi = uint8_t *src
; rsi = uint8_t *dst
; rdx = int width
; rcx = int height
; r8 = int src_row_size
; r9 = int dst_row_size
; Ajusto por los marcos
sub rdx, 8
shr rdx, 3
; rax = int height
lea rax, [rcx - 8]
vmovdqu ymm7, [BLACK]
; r10 = r8 * 3
lea r10, [r8 + r8*2]
black_start:
lea rcx, [rdx*4 + 4]
.x_loop:
vmovdqu [rsi], ymm7
lea rsi, [rsi + 32]
loop .x_loop
lea rdi, [rdi + r8 * 4]
y_loop:
movdqa [rsi], xmm7
lea rdi, [rdi + 16]
lea rsi, [rsi + 16]
mov rcx, rdx
.x_loop:
vmovdqu ymm0, [rdi]
vpmaxub ymm0, ymm0, [rdi + 4]
vpmaxub ymm0, ymm0, [rdi + 8]
vpmaxub ymm0, ymm0, [rdi + 12]
vpmaxub ymm0, ymm0, [rdi + r8]
vpmaxub ymm0, ymm0, [rdi + r8 + 4]
vpmaxub ymm0, ymm0, [rdi + r8 + 8]
vpmaxub ymm0, ymm0, [rdi + r8 + 12]
vpmaxub ymm0, ymm0, [rdi + r8*2]
vpmaxub ymm0, ymm0, [rdi + r8*2 + 4]
vpmaxub ymm0, ymm0, [rdi + r8*2 + 8]
vpmaxub ymm0, ymm0, [rdi + r8*2 + 12]
vpmaxub ymm0, ymm0, [rdi + r10]
vpmaxub ymm0, ymm0, [rdi + r10 + 4]
vpmaxub ymm0, ymm0, [rdi + r10 + 8]
vpmaxub ymm0, ymm0, [rdi + r10 + 12]
vmovdqu [rsi], ymm0
lea rdi, [rdi + 32]
lea rsi, [rsi + 32]
loop .x_loop
movdqa [rsi], xmm7
lea rdi, [rdi + 16]
lea rsi, [rsi + 16]
dec rax
jnz y_loop
black_end:
lea rcx, [rdx*4 + 4]
.x_loop:
vmovdqu [rsi], ymm7
lea rsi, [rsi + 32]
loop .x_loop
ret
......@@ -20,7 +20,7 @@ FILTROS = Cuadrados Manchas Offset Ruido Sharpen
FILTROS_OBJ = $(addsuffix .o, $(FILTROS)) $(addsuffix _asm.o, $(FILTROS)) \
$(addsuffix _c.o, $(FILTROS)) Manchas_mvec.o Manchas_simple.o \
Offset_avx.o
Offset_avx.o Cuadrados_avx.o
FILTROS_OBJ_CON_PATH = $(addprefix $(BUILD_DIR)/, $(FILTROS_OBJ))
.PHONY: filtros clean
......
......@@ -17,6 +17,10 @@ for imagen in archivos:
ok = verificar('Offset', '', 5, 'avx', imagen)
todos_ok = todos_ok and ok
for imagen in archivos:
ok = verificar('Cuadrados', '', 5, 'avx', imagen)
todos_ok = todos_ok and ok
for imagen in archivos:
ok = verificar('Manchas', '100', 5, 'mvec', imagen)
todos_ok = todos_ok and ok
......
......@@ -49,6 +49,11 @@ for s in ${SIZESMEM[*]}; do
if [ $ret -ne 0 ]; then exit -1; fi
done
for s in ${SIZESMEM[*]}; do
run_test "$TP2ALU" Cuadrados avx "$TESTINDIR/$img1.$s.bmp" ""
if [ $ret -ne 0 ]; then exit -1; fi
done
# Manchas
for s in ${SIZESMEM[*]}; do
run_test "$TP2ALU" Manchas asm "$TESTINDIR/$img1.$s.bmp" "100"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment