Skip to content

Commit

Permalink
WIP: add wce test.
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-valente committed Jan 17, 2024
1 parent 6fbe0a2 commit 27a2a6e
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 1 deletion.
2 changes: 2 additions & 0 deletions carfield.mk
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ $(PULPD_ROOT)/pulp-runtime: $(PULPD_ROOT)
$(MAKE) -C $(PULPD_ROOT) pulp-runtime
$(PULPD_ROOT)/regression-tests: $(PULPD_ROOT)
$(MAKE) -C $(PULPD_ROOT) regression-tests
cd $(PULPD_ROOT)/regression-tests
git checkout 0bd8077565153178d0449ec23bb25811630634dc

# For independent boot of an island, we allow to compile the binary standalone.
.PHONY: safed-sw-build
Expand Down
5 changes: 4 additions & 1 deletion sw/sw.mk
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ CAR_ELFLOAD_BLOCKING_SAFED_SRC_C := $(CAR_SW_DIR)/tests/bare-metal/hostd/safed_o
CAR_ELFLOAD_BLOCKING_SAFED_PATH := $(basename $(CAR_ELFLOAD_BLOCKING_SAFED_SRC_C))
CAR_ELFLOAD_PULPD_SRC_C := $(CAR_SW_DIR)/tests/bare-metal/hostd/pulp-offload.c
CAR_ELFLOAD_PULPD_PATH := $(basename $(CAR_ELFLOAD_PULPD_SRC_C))
CAR_ELFLOAD_PULPD_INTF_SRC_C := $(CAR_SW_DIR)/tests/bare-metal/hostd/pulp-offload-intf.c
CAR_ELFLOAD_PULPD_INTF_PATH := $(basename $(CAR_ELFLOAD_PULPD_INTF_SRC_C))

CAR_SW_TEST_SRCS_S = $(wildcard $(CAR_SW_DIR)/tests/bare-metal/hostd/*.S)
CAR_SW_TEST_SRCS_C = $(filter-out $(CAR_ELFLOAD_BLOCKING_SAFED_SRC_C) $(CAR_ELFLOAD_PULPD_SRC_C), $(wildcard $(CAR_SW_DIR)/tests/bare-metal/hostd/*.c))
CAR_SW_TEST_SRCS_C = $(filter-out $(CAR_ELFLOAD_BLOCKING_SAFED_SRC_C) $(CAR_ELFLOAD_PULPD_SRC_C) $(CAR_ELFLOAD_PULPD_INTF_PATH), $(wildcard $(CAR_SW_DIR)/tests/bare-metal/hostd/*.c))

CAR_SW_TEST_DRAM_DUMP = $(CAR_SW_TEST_SRCS_S:.S=.car.dram.dump) $(CAR_SW_TEST_SRCS_C:.c=.car.dram.dump)
CAR_SW_TEST_DRAM_SLM = $(CAR_SW_TEST_SRCS_S:.S=.car.dram.slm) $(CAR_SW_TEST_SRCS_C:.c=.car.dram.slm)
Expand Down Expand Up @@ -104,6 +106,7 @@ include $(CAR_SW_DIR)/tests/bare-metal/pulpd/sw.mk

car-pulpd-sw-offload-tests:
$(call offload_tests_template,$(PULPD_HEADER_TARGETS),pulpd,$(CAR_ELFLOAD_PULPD_SRC_C),$(CAR_ELFLOAD_PULPD_PATH))
$(call offload_tests_template,$(PULPD_HEADER_TARGETS),pulpd,$(CAR_ELFLOAD_PULPD_INTF_SRC_C),$(CAR_ELFLOAD_PULPD_INTF_PATH))

# Litmus tests
LITMUS_REPO := https://github.com/pulp-platform/CHERI-Litmus.git
Expand Down
112 changes: 112 additions & 0 deletions sw/tests/bare-metal/hostd/pulp-offload-intf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// Copyright 2023 ETH Zurich and University of Bologna.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
//
// Yvan Tortorella <[email protected]>
//
// Bare-metal offload test for the PULP cluster

#include <stdio.h>
#include <stdint.h>

#include "car_memory_map.h"
#include "car_util.h"
#include "dif/clint.h"
#include "dif/uart.h"
#include "params.h"
#include "regs/cheshire.h"
#include "csr.h"
#include "util.h"
#include "payload.h"
#include "printf.h"

long int * buffer; // 8 bytes * 256 * 1024 byte = 2 MB

void read_from_cache(int l1_way_size, int stride) {
asm volatile("": : :"memory");
for(int j = 0; j < l1_way_size; j++)
{
* ( ( volatile long int * ) &buffer[j] );
}
asm volatile("": : :"memory");
for(int j = 0; j < l1_way_size; j++)
{
* ( ( volatile long int * ) &buffer[(j+0)*stride]);
}
asm volatile("": : :"memory");
}

int sweep(int stride)
{

int l1_way_size = 4 * 1024 / 8;
int working_set = l1_way_size * stride * 8;

long unsigned cycle_start;

for(int i = 0; i < 10; i++)
{
if(i==1)
{
cycle_start = get_mcycle();
}
read_from_cache(l1_way_size, stride);
}

long unsigned cycles = get_mcycle() - cycle_start;

#ifdef VERBOSE
printf("%3dKB , %6d \r\n",
working_set / 1024, (int)cycles);
#endif

return (int)cycles;
}

int main(void)
{
// Set the LLC as LLC
axi_llc_reg32_all_cache(&__base_llc);
int pulp_ret_val = 0;
// Init the HW
// PULP Island
#ifdef LCL
car_enable_domain(CAR_PULP_RST);
char str[] = "Cluster boot.\r\n";
uint32_t rtc_freq = *reg32(&__base_regs, CHESHIRE_RTC_FREQ_REG_OFFSET);
uint64_t reset_freq = clint_get_core_freq(rtc_freq, 2500);

load_binary();

volatile uint32_t pulp_boot_default = 0x78008080;
volatile uint32_t pulp_ret_val = 0;

pulp_cluster_set_bootaddress(pulp_boot_default);

uart_init(&__base_uart, reset_freq, 115200);
uart_write_str(&__base_uart, str, sizeof(str));
uart_write_flush(&__base_uart);

pulp_cluster_start();
#endif

long unsigned cycles[5];
int j=0;
for( int i = 4; i<128; i=i*2){
cycles[j] = sweep(i);
j++;
}

#ifdef LCL
pulp_cluster_wait_eoc();

pulp_ret_val = pulp_cluster_get_return();
#endif


for(int i=0;i<5;i++)
printf("%d\r\n",cycles[i]);

return pulp_ret_val;

}

0 comments on commit 27a2a6e

Please sign in to comment.