-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pulp-offload-intf.c
to stimulate and test CVA6-PULP cluster interference
#255
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
27a2a6e
WIP: add wce test.
luca-valente 23030de
Fix `buffer` accesses in `pulp-offload-intf.c`
luca-valente 94171ef
Let `pulp_boot_default` be defined by `elf2header.py`
luca-valente d1b2465
Point to yt/carfield branch for the `regression_tests`
luca-valente ddc9c04
Fix `carfield.mk` indentation
luca-valente File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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,120 @@ | ||
// 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 | ||
// | ||
// Luca Valente <[email protected]> | ||
// | ||
// Bare-metal offload test for the PULP cluster with interference | ||
|
||
#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" | ||
|
||
#define LCL | ||
|
||
long int buffer[128]; | ||
|
||
void read_from_cache(int l1_way_size, int stride) { | ||
asm volatile("": : :"memory"); | ||
for(volatile int j = 0; j < l1_way_size; j++) | ||
{ | ||
* ( ( volatile long int * ) &buffer[j] ); | ||
} | ||
asm volatile("": : :"memory"); | ||
for(volatile int j = 0; j < l1_way_size; j++) | ||
{ | ||
* ( ( volatile long int * ) &buffer[j*stride]); | ||
} | ||
asm volatile("": : :"memory"); | ||
} | ||
|
||
long unsigned sweep(int stride) | ||
{ | ||
|
||
int l1_way_size = 4 * 1024 / 8; | ||
int working_set = l1_way_size * stride * 8; | ||
|
||
volatile 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); | ||
} | ||
|
||
volatile long unsigned cycles = get_mcycle() - cycle_start; | ||
|
||
#ifdef VERBOSE | ||
printf("%3dKB , %6d \r\n", | ||
working_set / 1024, (int)cycles); | ||
#endif | ||
|
||
return cycles; | ||
} | ||
|
||
int main(void) | ||
{ | ||
// Set the LLC as LLC | ||
axi_llc_reg32_all_cache(&__base_llc); | ||
writew(0x18,CAR_HYPERBUS_CFG_BASE_ADDR+0x18); | ||
volatile uint32_t 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 = ELF_BOOT_ADDR; | ||
|
||
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 | ||
|
||
#ifdef VERBOSE | ||
printf("Buffer: %x\n", buffer); | ||
#endif | ||
|
||
volatile 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]); | ||
|
||
printf("Done\n"); | ||
|
||
return pulp_ret_val; | ||
|
||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think that doing:
Would work the same or might break? So we don't have to add dedicated variables for each new test we add (not sure it would work though).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto, we can append to the genric source variable
CAR_ELFLOAD_PULPD_SRC_C
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it would work.
CAR_ELFLOAD_PULPD_SRC_C
(i.e.$(CAR_SW_DIR)/tests/bare-metal/hostd/pulp-offload.c
) is used as an argument ofoffload_tests_template
. We would need to add a secondfor
loop there to check all the source files and execute the command$(CHS_SW_CC) $(CAR_SW_INCLUDES) $(CHS_SW_CCFLAGS) -c $(3) -o $(4).$(basename $(notdir $(header))).car.o;
2 times, with$(3)
beingpulp-offload.c
andpulp-offload-intf.c
in the second iteration. Without adding thefor
loop, we would pass two files with twomain
to the cc compiler and it would break.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree. @alex96295 what do you think?