Skip to content

Commit

Permalink
Xyi/sw clean gemmx dr (#275)
Browse files Browse the repository at this point in the history
* clean dead code for dr

* delete gemm and gemm-conv lib

* delete streamer-gemm and streamer-gemm-add-c lib

* rm lib include

* rm lib include

* add hw paramters

* rm streamer-simd

* fix refactor for ld data
  • Loading branch information
xiaoling-yi authored Aug 26, 2024
1 parent 0fa8d44 commit a6037ce
Show file tree
Hide file tree
Showing 24 changed files with 44 additions and 1,490 deletions.
8 changes: 4 additions & 4 deletions target/snitch_cluster/sw/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ else
RUNTIME = runtime/rtl
endif

SUBDIRS += math $(RUNTIME) snax/mac snax/gemm snax/streamer-gemm snax/streamer-simd snax/data-reshuffler snax/streamer-gemm-add-c snax/streamer-gemm-conv snax/streamer-gemm-conv-simd snax/xdma snax/hypercorex apps tests
SUBDIRS += math $(RUNTIME) snax/mac snax/data-reshuffler snax/streamer-gemm-conv-simd snax/xdma snax/hypercorex apps tests

.PHONY: all $(SUBDIRS)

all: $(SUBDIRS)

# Explicit dependency of apps on runtime
apps: math $(RUNTIME) snax/mac snax/gemm snax/streamer-gemm snax/streamer-simd snax/data-reshuffler snax/streamer-gemm-add-c snax/streamer-gemm-conv snax/streamer-gemm-conv-simd snax/xdma snax/hypercorex
apps: math $(RUNTIME) snax/mac snax/data-reshuffler snax/streamer-gemm-conv-simd snax/xdma snax/hypercorex
$(MAKE) -C $@ TARGET=$(TARGET)

# Explicit dependency of tests on runtime
tests: math $(RUNTIME) snax/mac snax/gemm snax/streamer-gemm snax/streamer-simd snax/data-reshuffler snax/streamer-gemm-add-c snax/streamer-gemm-conv snax/streamer-gemm-conv-simd snax/xdma snax/hypercorex
tests: math $(RUNTIME) snax/mac snax/data-reshuffler snax/streamer-gemm-conv-simd snax/xdma snax/hypercorex
$(MAKE) -C $@ $(TARGET)

runtime/rtl runtime/banshee runtime/rtl-generic math snax/mac snax/gemm snax/streamer-gemm snax/streamer-simd snax/data-reshuffler snax/streamer-gemm-add-c snax/streamer-gemm-conv snax/streamer-gemm-conv-simd snax/xdma snax/hypercorex:
runtime/rtl runtime/banshee runtime/rtl-generic math snax/mac snax/data-reshuffler snax/streamer-gemm-conv-simd snax/xdma snax/hypercorex:
$(MAKE) -C $@ $(TARGET)
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int main() {
// Transfer data from L3 to L1
// Using DMA only
if (snrt_is_dm_core()) {
load_a_chrunk_of_data(local_in, DataIn, input_data_len);
snrt_dma_start_1d(local_in, DataIn, input_data_len * sizeof(int8_t));
}

// Wait for DMA to finish
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,9 @@ APP = snax-streamer-gemm-conv-simd

INCDIRS = data

INCDIRS += ../../snax/streamer-gemm/include
INCDIRS += ../../snax/streamer-gemm-conv-simd/include
INCDIRS += ../../snax/gemm/include
INCDIRS += ../../snax/streamer-simd/include

# Include this binary in the final build
RISCV_LDFLAGS += ../../snax/streamer-gemm/build/snax-streamer-gemm-lib.o
RISCV_LDFLAGS += ../../snax/gemm/build/snax-gemm-lib.o
RISCV_LDFLAGS += ../../snax/streamer-simd/build/snax-streamer-simd-lib.o
RISCV_LDFLAGS += ../../snax/streamer-gemm-conv-simd/build/snax-streamer-gemm-conv-simd-lib.o

SRCS = src/snax-streamer-gemm-conv-simd.c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@

#include "data.h"

#include "snax-gemm-lib.h"
#include "snax-gemm-params.h"

#include "snax-streamer-gemm-lib.h"
#include "snax-streamer-simd-lib.h"
#include "snax-gemmx-params.h"

#include "snax-streamer-gemm-conv-simd-lib.h"

Expand All @@ -36,9 +32,10 @@ int main() {
// Transfer data from L3 to L1
// Using DMA only
if (snrt_is_dm_core()) {
load_conv_input_data(Nbatch, H + 2 * pad_h, W + 2 * pad_w, Cin, local_a,
A);
load_weight_data(Cout, Kh, Kw, Cin, local_b, B);
snrt_dma_start_1d(
local_a, A,
Nbatch * (H + 2 * pad_h) * (W + 2 * pad_w) * Cin * sizeof(int8_t));
snrt_dma_start_1d(local_b, B, Cout * Kh * Kw * Cin * sizeof(int8_t));
}

// Wait for DMA to finish
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@

#pragma once

#define spatial_len_0 8
#define spatial_len_1 8
#define spatial_len (spatial_len_0 * spatial_len_1)

// Set STREAMER configuration CSR
void set_data_reshuffler_csr(int tempLoop0_in, int tempLoop1_in,
int tempLoop2_in, int tempLoop3_in,
Expand All @@ -39,19 +35,5 @@ void wait_data_reshuffler();

uint32_t read_data_reshuffler_perf_counter();

void load_data_reshuffler_test_data(int tempLoop0, int tempLoop1,
int tempStride0, int tempStride1,
int spatialStride1, int8_t* base_ptr_local,
int8_t* base_ptr_l2);

uint32_t check_data_reshuffler_result(int tempLoop0, int tempLoop1,
int tempStride0, int tempStride1,
int spatialStride1,
int8_t* base_ptr_local,
int8_t* base_ptr_l2);

void load_a_chrunk_of_data(int8_t* base_ptr_local, int8_t* base_ptr_l2,
int len);

uint32_t test_a_chrunk_of_data(int8_t* base_ptr_local, int8_t* base_ptr_l2,
int len);
Original file line number Diff line number Diff line change
Expand Up @@ -71,74 +71,10 @@ void start_data_reshuffler() { write_csr(984, 1); }
void wait_data_reshuffler() { write_csr(984, 0); }

uint32_t read_data_reshuffler_perf_counter() {
uint32_t perf_counter = read_csr(982);
uint32_t perf_counter = read_csr(983);
return perf_counter;
}

void load_data_reshuffler_test_data(int tempLoop0, int tempLoop1,
int tempStride0, int tempStride1,
int spatialStride1, int8_t* base_ptr_local,
int8_t* base_ptr_l2) {
int8_t* addr_in;
int8_t* addr_In;

for (int loop1 = 0; loop1 < tempLoop1; loop1++) {
for (int loop0 = 0; loop0 < tempLoop0; loop0++) {
for (int spatial_i_1 = 0; spatial_i_1 < spatial_len_1;
spatial_i_1++) {
addr_in = base_ptr_local + loop1 * tempStride1 +
loop0 * tempStride0 + spatial_i_1 * spatialStride1;
addr_In = base_ptr_l2 + loop1 * tempLoop0 * spatial_len +
loop0 * spatial_len + spatial_i_1 * spatial_len_1;
snrt_dma_start_1d(addr_in, addr_In,
spatial_len_0 * sizeof(int8_t));
}
}
}
}

uint32_t check_data_reshuffler_result(int tempLoop0, int tempLoop1,
int tempStride0, int tempStride1,
int spatialStride1,
int8_t* base_ptr_local,
int8_t* base_ptr_l2) {
int8_t* addr_out;
int8_t* addr_Out;
uint32_t error = 0;

for (int loop1 = 0; loop1 < tempLoop1; loop1++) {
for (int loop0 = 0; loop0 < tempLoop0; loop0++) {
for (int spatial_i_1 = 0; spatial_i_1 < spatial_len_1;
spatial_i_1++) {
for (int spatial_i_0 = 0; spatial_i_0 < spatial_len_0;
spatial_i_0++) {
addr_out = base_ptr_local + loop1 * tempStride1 +
loop0 * tempStride0 +
spatial_i_1 * spatialStride1 + spatial_i_0;
addr_Out = base_ptr_l2 + loop1 * tempLoop0 * spatial_len +
loop0 * spatial_len +
spatial_i_1 * spatial_len_1 + spatial_i_0;
if ((int8_t)*addr_out != (int8_t)*addr_Out) {
printf(
"Error: after reshuffle addr_out = %d at address "
"%x, golden addr_Out = %d at address %x \n",
(int8_t)*addr_out, addr_out, (int8_t)*addr_Out,
addr_Out);
error++;
}
}
}
}
}

return error;
}

void load_a_chrunk_of_data(int8_t* base_ptr_local, int8_t* base_ptr_l2,
int len) {
snrt_dma_start_1d(base_ptr_local, base_ptr_l2, len * sizeof(int8_t));
}

uint32_t test_a_chrunk_of_data(int8_t* base_ptr_local, int8_t* base_ptr_l2,
int len) {
uint32_t error = 0;
Expand Down
82 changes: 0 additions & 82 deletions target/snitch_cluster/sw/snax/gemm/Makefile

This file was deleted.

59 changes: 0 additions & 59 deletions target/snitch_cluster/sw/snax/gemm/include/snax-gemm-lib.h

This file was deleted.

Loading

0 comments on commit a6037ce

Please sign in to comment.