-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sw] Manually test PULP Cluster offload
- Loading branch information
Showing
1 changed file
with
22 additions
and
4 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,8 @@ | |
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Moritz Scherer <[email protected]> | ||
// Arpan Prasad <[email protected]> | ||
// Sergio Mazzola <[email protected]> | ||
|
||
// Simple offload test. Set the trap handler first, offload a function, retrieve | ||
// return value from cluster. Does not currently take care of stack | ||
|
@@ -14,6 +15,7 @@ | |
#include <stdint.h> | ||
|
||
#define TESTVAL 0x050CCE55 | ||
#define TESTVAL_CLUSTER 0xdeadbeef | ||
|
||
// static uint32_t *clintPointer = (uint32_t *)CLINT_CTRL_BASE; | ||
|
||
|
@@ -27,9 +29,25 @@ | |
// } | ||
|
||
int32_t testReturn() { | ||
return TESTVAL; | ||
} | ||
int32_t result; | ||
|
||
int32_t hartId; | ||
asm("csrr %0, mhartid" : "=r"(hartId)::); | ||
|
||
|
||
asm volatile ( | ||
"li t0, 0xdeadbeef\n" // Load immediate value into t0 (x5) | ||
"mv a0, t0\n" // Move t0 into a0 (x10) | ||
"mv %0, a0\n" // Move a0 into the output variable (C) | ||
: "=r"(result) // Output operand | ||
: // No input operands | ||
: "t0", "a0" // Clobbered registers | ||
); | ||
|
||
result = result + hartId; | ||
|
||
return result; | ||
} | ||
int main() { | ||
// setupInterruptHandler(clusterTrapHandler); | ||
// offloadToCluster(testReturn, 0); | ||
|
@@ -61,4 +79,4 @@ int main() { | |
} | ||
return (count + TESTVAL+result); | ||
// } | ||
} | ||
} |