Skip to content

Commit

Permalink
[sw] Manually test PULP Cluster offload
Browse files Browse the repository at this point in the history
  • Loading branch information
sermazz committed Jan 28, 2025
1 parent 6f07441 commit 1ac1f80
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions sw/tests/testClusterOffload.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -14,6 +15,7 @@
#include <stdint.h>

#define TESTVAL 0x050CCE55
#define TESTVAL_CLUSTER 0xdeadbeef

// static uint32_t *clintPointer = (uint32_t *)CLINT_CTRL_BASE;

Expand All @@ -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);
Expand Down Expand Up @@ -61,4 +79,4 @@ int main() {
}
return (count + TESTVAL+result);
// }
}
}

0 comments on commit 1ac1f80

Please sign in to comment.