-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added hardware tile group shared mem load store regression test
- Loading branch information
1 parent
e73fc6d
commit c241572
Showing
4 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
software/spmd/bsg_cuda_lite_runtime/hardware_shared_mem_load_store/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
######################################################### | ||
# Network Configutaion | ||
# If not configured, Will use default Values | ||
bsg_global_X ?= $(bsg_tiles_X) | ||
bsg_global_Y ?= $(bsg_tiles_Y)+1 | ||
|
||
######################################################### | ||
#Tile group configuration | ||
# If not configured, Will use default Values | ||
bsg_tiles_org_X ?= 0 | ||
bsg_tiles_org_Y ?= 1 | ||
|
||
# If not configured, Will use default Values | ||
bsg_tiles_X ?= 4 | ||
bsg_tiles_Y ?= 4 | ||
|
||
|
||
all: main.run | ||
|
||
|
||
KERNEL_NAME ?=kernel_hardware_shared_mem_load_store | ||
|
||
OBJECT_FILES=main.o kernel_hardware_shared_mem_load_store.o | ||
|
||
include ../../Makefile.include | ||
|
||
|
||
main.riscv: $(LINK_SCRIPT) $(OBJECT_FILES) $(SPMD_COMMON_OBJECTS) $(BSG_MANYCORE_LIB) ../../common/crt.o | ||
$(RISCV_LINK) $(OBJECT_FILES) $(SPMD_COMMON_OBJECTS) -L. "-l:$(BSG_MANYCORE_LIB)" -o $@ $(RISCV_LINK_OPTS) | ||
|
||
|
||
main.o: Makefile | ||
|
||
include ../../../mk/Makefile.tail_rules |
76 changes: 76 additions & 0 deletions
76
...uda_lite_runtime/hardware_shared_mem_load_store/kernel_hardware_shared_mem_load_store.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// * This kernel loads a memory block from DRAM into hardware | ||
// tile group shared memory, and stores it back to another | ||
// array to DRAM to be compared. | ||
// * Tile group dimensions are fixed at 4x4. | ||
|
||
// TEMPLATE_TG_DIM_X/Y must be defined before bsg_manycore.h is | ||
// included. bsg_tiles_X and bsg_tiles_Y must also be defined for | ||
// legacy reasons, but they are deprecated. | ||
|
||
|
||
#define TEMPLATE_TG_DIM_X 4 | ||
#define TEMPLATE_TG_DIM_Y 4 | ||
#define TEMPLATE_BLOCK_SIZE 1024 | ||
#define TEMPLATE_STRIPE_SIZE 1 | ||
#define bsg_tiles_X TEMPLATE_TG_DIM_X | ||
#define bsg_tiles_Y TEMPLATE_TG_DIM_Y | ||
|
||
#include <bsg_manycore.h> | ||
#include "kernel_hardware_shared_mem_load_store.hpp" | ||
#include <bsg_tile_group_barrier.hpp> | ||
#include "bsg_shared_mem.hpp" | ||
|
||
using namespace bsg_manycore; | ||
|
||
|
||
bsg_barrier<bsg_tiles_X, bsg_tiles_Y> barrier; | ||
|
||
|
||
template <int TG_DIM_X, | ||
int TG_DIM_Y, | ||
int BLOCK_SIZE, | ||
int STRIPE_SIZE, | ||
typename T> | ||
int __attribute__ ((noinline)) | ||
hardware_shared_mem_load_store(T *A, T *B) { | ||
|
||
// Declare tile-group shared memory | ||
TileGroupSharedMem<T, BLOCK_SIZE, TG_DIM_X, TG_DIM_Y, STRIPE_SIZE> A_sh; | ||
|
||
for (int iter_x = __bsg_id; iter_x < BLOCK_SIZE; iter_x += TG_DIM_X * TG_DIM_Y) { | ||
A_sh[iter_x] = A[iter_x]; | ||
} | ||
|
||
barrier.sync(); | ||
|
||
for (int iter_x = __bsg_id; iter_x < BLOCK_SIZE; iter_x += TG_DIM_X * TG_DIM_Y) { | ||
B[iter_x] = A_sh[iter_x]; | ||
} | ||
|
||
barrier.sync(); | ||
|
||
return 0; | ||
} | ||
|
||
|
||
extern "C" { | ||
int __attribute__ ((noinline)) kernel_hardware_shared_mem_load_store(float *A, | ||
float *sum, | ||
uint32_t WIDTH, | ||
uint32_t block_size) { | ||
int rc; | ||
bsg_cuda_print_stat_kernel_start(); | ||
|
||
rc = hardware_shared_mem_load_store <TEMPLATE_TG_DIM_X, | ||
TEMPLATE_TG_DIM_Y, | ||
TEMPLATE_BLOCK_SIZE, | ||
TEMPLATE_STRIPE_SIZE> (A, | ||
sum); | ||
|
||
barrier.sync(); | ||
|
||
bsg_cuda_print_stat_kernel_end(); | ||
|
||
return rc; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...uda_lite_runtime/hardware_shared_mem_load_store/kernel_hardware_shared_mem_load_store.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#ifndef __KERNEL_HARDWARE_SHARED_MEM_LOAD_STORE_HPP | ||
#define __KERNEL_HARDWARE_SHARED_MEM_LOAD_STORE_HPP | ||
#include <cstdint> | ||
|
||
#endif //__KERNEL_HARDWARE_SHARED_MEM_LOAD_STROE_HPP |
1 change: 1 addition & 0 deletions
1
software/spmd/bsg_cuda_lite_runtime/hardware_shared_mem_load_store/main.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../main/main.c |