The following quick test code uses a querying thread and an array of interfaces to communicated with individual threads to query their local tile id.
Code: Select all
#include <xs1.h>
#include <print.h>
#include <platform.h>
#define NUM_CORES 3
interface IdQuery {
int GetCoreId();
};
void CoreIdentifier(interface IdQuery server sv) {
while (1) {
select {
case sv.GetCoreId() -> int coreId:
coreId = get_local_tile_id();
break;
}
}
}
void CoreQuerier(interface IdQuery client cl[nThreads], unsigned int nThreads) {
for(int i = 0; i < nThreads; ++ i) {
// [BREAKPOINT HERE]
printintln(cl[nThreads].GetCoreId());
}
}
int main() {
interface IdQuery test[NUM_CORES];
par {
on tile[0]: CoreQuerier(test, NUM_CORES);
par (int i = 0; i < NUM_CORES; ++i) {
on tile[i]: CoreIdentifier(test[i]);
}
}
return 0;
}
It clearly shows that although I have declared and array of 3 interfaces, that the third element is simple the same as the second (indeed if you make the array larger, all elements past the second are equal to the second).
This is simply a small compact example, but this is currently blocking what I am working on (and I'd rather not re-write it all with channels, interfaces are rather nice). I may well have done something stupid but if I have it's not immediately apparent to me and I'd be very grateful if someone could have a look and confirm if this is a bug or something else.