Skip to content

Commit

Permalink
[software] Complete data generation for tests and systolic apps
Browse files Browse the repository at this point in the history
  • Loading branch information
mbertuletti committed Sep 25, 2024
1 parent 044f70b commit e5a9c2f
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 12 deletions.
4 changes: 1 addition & 3 deletions software/apps/systolic/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ RUNTIME_DIR := $(abspath $(SOFTWARE_DIR)/runtime)
include $(RUNTIME_DIR)/runtime.mk

APPS := $(patsubst $(APPS_DIR)/%/main.c,%,$(shell find $(APPS_DIR) -name "main.c"))
DATA := $(patsubst %.args,%.h,$(shell find $(APPS_DIR) -name "data.args"))
ALLPYS := $(patsubst %.py,%.h,$(wildcard $(DATA_DIR)/*.py))
BINARIES := $(addprefix $(BIN_DIR)/,$(APPS))

# Define the rule to build all applications
Expand All @@ -26,7 +24,7 @@ $(APPS): % : $(BIN_DIR)/% $(APPS_DIR)/Makefile $(shell find $(RUNTIME_DIR)/**.{S
# Check if the config is set to systolic
ifeq ($(config),systolic)
.PHONY: $(BINARIES)
$(BINARIES): $(BIN_DIR)/%: %/main.c.o $(RUNTIME) $(LINKER_SCRIPT) $(DATA) $(ALLPYS) update_opcodes
$(BINARIES): $(BIN_DIR)/%: %/main.c.o $(RUNTIME) $(LINKER_SCRIPT) data_%.h update_opcodes
mkdir -p $(dir $@)
$(RISCV_CC) -Iinclude $(RISCV_LDFLAGS) -o $@ $< $(RUNTIME) -T$(RUNTIME_DIR)/link.ld
$(RISCV_OBJDUMP) $(RISCV_OBJDUMP_FLAGS) -D $@ > $@.dump
Expand Down
7 changes: 7 additions & 0 deletions software/data/gendata_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,12 @@ def print_file(header, defines, arrays, filename):
arrays = [(result[i], *arrays[i]) for i in range(len(arrays))]
print_file(header, defnes, arrays, filename)

elif (app_name == "fence") | (app_name == "memcpy"):

result = blas.generate_iarray(
**{name: value for name, value in defnes}, my_type=my_type)
arrays = [(result, *arrays[0])]
print_file(header, defnes, arrays, filename)

else:
print("No need for data generation.")
24 changes: 22 additions & 2 deletions software/data/gendata_params.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"cfft_radix4_q16": {
"type": "int16",
"defines": [
("N_CSAMPLES", 1024)
("N_CSAMPLES", 64)
]
"arrays": [
("int16_t", "l2_pSrc")
Expand All @@ -35,7 +35,7 @@
"cfft_radix2_q16": {
"type": "int16",
"defines": [
("N_CSAMPLES", 1024)
("N_CSAMPLES", 256)
]
"arrays": [
("int16_t", "l2_pSrc")
Expand Down Expand Up @@ -129,4 +129,24 @@
]
}

"fence": {
"type": "int32",
"defines": [
("array_N", 12288)
]
"arrays": [
("int32_t", "l2_data")
]
},

"memcpy": {
"type": "int32",
"defines": [
("array_N", 2048)
]
"arrays": [
("int32_t", "l2_data")
]
},

}
8 changes: 8 additions & 0 deletions software/data/gendatalib_blas.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
from scipy import signal


def generate_iarray(array_N=16, my_type=np.float32):

# Create random array of integers
MAX = 2**31
A = np.random.randint(-MAX, MAX - 1, size=(array_N)).astype(my_type)
return A


def generate_fmatmul(matrix_M=16, matrix_N=16,
matrix_P=16, my_type=np.float32):

Expand Down
4 changes: 1 addition & 3 deletions software/tests/baremetal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ RUNTIME_DIR := $(abspath $(SOFTWARE_DIR)/runtime)
include $(RUNTIME_DIR)/runtime.mk

TESTS := $(patsubst $(TESTS_DIR)/%/main.c,%,$(shell find $(TESTS_DIR) -name "main.c"))
DATA := $(patsubst %.args,%.h,$(shell find $(TESTS_DIR) -name "data.args"))
ALLPYS := $(patsubst %.py,%.h,$(wildcard $(DATA_DIR)/*.py))
BINARIES := $(addprefix $(BIN_DIR)/,$(TESTS))

# Make all applications
Expand All @@ -26,7 +24,7 @@ all: $(TESTS)
$(TESTS): % : $(BIN_DIR)/% $(TESTS_DIR)/Makefile $(shell find $(RUNTIME_DIR)/**.{S,c,h,ld} -type f)

.PHONY: $(BINARIES)
$(BINARIES): $(BIN_DIR)/%: %/main.c.o $(RUNTIME) $(LINKER_SCRIPT) $(DATA) $(ALLPYS) update_opcodes
$(BINARIES): $(BIN_DIR)/%: %/main.c.o $(RUNTIME) $(LINKER_SCRIPT) data_%.h update_opcodes
mkdir -p $(dir $@)
$(RISCV_CC) -Iinclude $(RISCV_LDFLAGS) -o $@ $< $(RUNTIME) -T$(RUNTIME_DIR)/link.ld
$(RISCV_OBJDUMP) $(RISCV_OBJDUMP_FLAGS) -D $@ > $@.dump
Expand Down
1 change: 0 additions & 1 deletion software/tests/baremetal/fence/data.args

This file was deleted.

2 changes: 1 addition & 1 deletion software/tests/baremetal/fence/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <stdint.h>
#include <string.h>

#include "data.h"
#include "data_fence.h"
#include "dma.h"
#include "encoding.h"
#include "mempool_dma_frontend.h"
Expand Down
1 change: 0 additions & 1 deletion software/tests/baremetal/memcpy/data.args

This file was deleted.

2 changes: 1 addition & 1 deletion software/tests/baremetal/memcpy/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <stdint.h>
#include <string.h>

#include "data.h"
#include "data_memcpy.h"
#include "dma.h"
#include "encoding.h"
#include "mempool_dma_frontend.h"
Expand Down

0 comments on commit e5a9c2f

Please sign in to comment.