Add MINIMISE_MAIN_TILE_ARGS define in tile_map.xc #23
Add MINIMISE_MAIN_TILE_ARGS define in tile_map.xc #23chrisc-xmos wants to merge 18 commits intoxmos:developfrom
Conversation
…es on 2 tile applications
|
I have thought a little about this and the change I have been thinking of would be Where Benefit of this is that it could easily be extended to support arbitrary tiles which the XTC tools support. A further thought which might be worth considering. The XTC tools support passing command line parameters through That's getting unwieldy again for the newcomer though. Maybe some clever macro magic could solve everything? |
There was a problem hiding this comment.
would be good to have the function prototypes in a header file. This could then be included by the C file which defines the functions. This allows the user to get compile time (as opposed to link time) errors when they define it incorrectly.
There was a problem hiding this comment.
This is a great suggestion. I have updated the PR to include a new header file main_tile.h which provides this.
There was a problem hiding this comment.
Functions whose prototype changes based on macro definitions cause confusion IMO. You need to run the preprocessor on this code before you can know what the function you need to define is.
Open to being persuaded otherwise if there are reasons behind doing it this way
There was a problem hiding this comment.
I would usually agree on this point and I agree it's not a perfect solution. However, I put in two mitigations:
- I added text to the README describing what I believe will be the most common setup (a two-tile system). The README is ordered so that users wanting the simple prototypes get the prototypes and all the information they need to configure the build to use those prototypes.
- The proposed changes are guarded by the define MINIMISE_MAIN_TILE_ARGS. If this is not set the prototypes are unchanged.
…customer's application code which will cause errors to be spotted at compile time
The current tile_map.xc usage provides flexibility but is a little unfriendly for 2 tile applications. The proposed change maintains the existing prototypes for the main_tilen entry points unless MINIMISE_MAIN_TILE_ARGS is defined during preprocessing.
When MINIMISE_MAIN_TILE_ARGS is defined, the preprocessing removes all unused chanends from the prototypes. For a 2 tile application (tiles 0 and 1) the preprocessed tile main becomes:
extern "C" {
void main_tile0(chanend c1);
void main_tile1(chanend c0);
}
int main(void) {
chan c_t0_t1;
par {
on tile[0] : main_tile0(c_t0_t1);
on tile[1] : main_tile1(c_t0_t1);
}
return 0;
}
This is likely to be a more palatable starting point for new customers.
Marking as work in progress as there are not automated tests.