Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@chrisc-xmos
Copy link

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.

@xhuw
Copy link
Contributor

xhuw commented Oct 2, 2023

I have thought a little about this and the change I have been thinking of would be

// names and order inspired by argc and argv
main_tileN(int chanendc, chanend* chanendv);

Where chanendv is an array of chanendc chanends, and chanendv[n] is NULL for the current tile.

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 xgdb and xrun. The current multi-tile main.xc throws away the argc/argv and they are not accessible in the application code. This might be solvable without modifying the main prototype... but the below could be a complete solution:

main_tileN(int chanendc, chanend* chanendv, int argc, char** argv);

That's getting unwieldy again for the newcomer though. Maybe some clever macro magic could solve everything?



// c3
#if ((PLATFORM_SUPPORTS_TILE_3 == 1) && (PLATFORM_USES_TILE_3 == 1))
Copy link
Contributor

@xhuw xhuw Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great suggestion. I have updated the PR to include a new header file main_tile.h which provides this.


// c3
#if ((PLATFORM_SUPPORTS_TILE_3 == 1) && (PLATFORM_USES_TILE_3 == 1))
#ifdef ARGS_STARTED
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would usually agree on this point and I agree it's not a perfect solution. However, I put in two mitigations:

  1. 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.
  2. The proposed changes are guarded by the define MINIMISE_MAIN_TILE_ARGS. If this is not set the prototypes are unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants