Skip to content

Commit

Permalink
sw: Make tests agnostic of core num
Browse files Browse the repository at this point in the history
  • Loading branch information
colluca committed Jul 28, 2024
1 parent 54aeece commit 1b2177c
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 36 deletions.
2 changes: 1 addition & 1 deletion sw/dnn/softmax/src/softmax.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static inline void softmax_layer(softmax_layer_t const l) {

// printf("row_offset: %d, ldI: %d\n", row_offset, ldI);
softmax_fp32(&ifmap[row_offset], &ofmap[row_offset], ldI, batch_offset,
l.batch_size, l.seq_len / 8, l.input_samples);
l.batch_size, l.seq_len / compute_num, l.input_samples);

} else {
snrt_cluster_hw_barrier();
Expand Down
4 changes: 4 additions & 0 deletions sw/snRuntime/src/omp/omp.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ static inline unsigned omp_get_thread_num(void) {
return snrt_cluster_core_idx();
}

static inline unsigned omp_get_num_threads(void) {
return snrt_cluster_compute_core_num();
}

static inline void parallelRegion(int32_t argc, void *data,
void (*fn)(void *, uint32_t),
int num_threads) {
Expand Down
2 changes: 1 addition & 1 deletion sw/tests/caq.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <snrt.h>

#define NUM_WORKERS 8
#define NUM_WORKERS 4

// To prevent X reads on non-CAQ-proofed systems, we need a sync
inline void fp_sync() {
Expand Down
2 changes: 1 addition & 1 deletion sw/tests/caq_frep.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <snrt.h>

#define NUM_WORKERS 8
#define NUM_WORKERS 4

// To prevent X reads on non-CAQ-proofed systems, we need a sync
inline void fp_sync() {
Expand Down
7 changes: 6 additions & 1 deletion sw/tests/non_null_exitcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@
// Should be used as a test to check that the simulator or whoever
// is running the program actually captures an error when it occurs.

int main() { return 14; }
// Minimum number of cores the hardware must have for this test to pass
#define MIN_CORES 4

int main() {
if (snrt_cluster_core_idx() < MIN_CORES) return 14;
}
17 changes: 10 additions & 7 deletions sw/tests/openmp_for_static_schedule.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "snrt.h"

#define AXPY_N 64
#define NTHREADS 8

unsigned __attribute__((noinline)) static_schedule(void) {
static double *data_x, *data_y, data_a;
Expand All @@ -24,13 +23,17 @@ unsigned __attribute__((noinline)) static_schedule(void) {
// Compute AXPY
#pragma omp parallel firstprivate(data_a, data_x, data_y)
{
int nthreads = omp_get_num_threads();
// DM, rep, bound, stride, data
__builtin_ssr_setup_1d_r(0, 0, AXPY_N / NTHREADS - 1, sizeof(double),
&data_x[AXPY_N / 8 * omp_get_thread_num()]);
__builtin_ssr_setup_1d_r(1, 0, AXPY_N / NTHREADS - 1, sizeof(double),
&data_y[AXPY_N / 8 * omp_get_thread_num()]);
__builtin_ssr_setup_1d_w(2, 0, AXPY_N / NTHREADS - 1, sizeof(double),
&data_y[AXPY_N / 8 * omp_get_thread_num()]);
__builtin_ssr_setup_1d_r(
0, 0, AXPY_N / nthreads - 1, sizeof(double),
&data_x[AXPY_N / nthreads * omp_get_thread_num()]);
__builtin_ssr_setup_1d_r(
1, 0, AXPY_N / nthreads - 1, sizeof(double),
&data_y[AXPY_N / nthreads * omp_get_thread_num()]);
__builtin_ssr_setup_1d_w(
2, 0, AXPY_N / nthreads - 1, sizeof(double),
&data_y[AXPY_N / nthreads * omp_get_thread_num()]);
__builtin_ssr_enable();
#pragma omp for schedule(static)
for (unsigned i = 0; i < AXPY_N; i++) {
Expand Down
2 changes: 1 addition & 1 deletion sw/tests/openmp_parallel.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ unsigned __attribute__((noinline)) parallel_section(void) {
tx = read_csr(minstret) - tx;
__atomic_add_fetch(&sum, 10, __ATOMIC_RELAXED);
}
return sum != 8 * 10;
return sum != snrt_cluster_compute_core_num() * 10;
}

int main() {
Expand Down
23 changes: 0 additions & 23 deletions sw/tests/team_global.c

This file was deleted.

2 changes: 1 addition & 1 deletion target/snitch_cluster/sw/run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ runs:
- elf: tests/build/varargs_2.elf
- elf: tests/build/zero_mem.elf
- elf: tests/build/non_null_exitcode.elf
retcode: 126
retcode: 56
- elf: tests/build/caq.elf
- elf: tests/build/caq_frep.elf
simulators: [vsim, vcs, verilator] # banshee does not model FREP timing
Expand Down

0 comments on commit 1b2177c

Please sign in to comment.