-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Templates vs. arguments #145
Comments
@blwiner since it seems we can convert most of the compile-time parameters to function arguments, which can be determined at run-time, the question now is whether the emulation would benefit from this change. |
@aehart thanks for looking into this. I should talk more with the others developing on the emulation side. Perhaps this could be a discussion point at the HLS Chat this week? |
Yes, I think we can do this. |
Here is a version of the TrackletCalculator without any template parameters: firmware-hls/TrackletAlgorithm/TrackletCalculator.h Lines 210 to 259 in 17f4ef3
It's overloaded to accommodate the different possible types of inner and outer stubs. I think that means the types of the corresponding memories need to be determined at build-time, so that the compiler knows which version to call. Not sure how much of a limitation that is, but we could also pass the memory arrays as generic pointers (say, |
from a code style point of view pointer to void sounds error-prone and probably not a great idea from safety either. |
@pwittich I think I agree with that. And I'm not even sure it would pass muster with the CMSSW code guidelines. A better solution would probably be to define a dummy In any case, it should be possible to define a generic function interface for the emulation, if the emulation folks think that would be useful. |
@aehart I think your suggestion of a dummy
But I think I would prefer something simpler like storing The use of |
If we did introduce a common base class, that would allow you to create a common vector containing pointers to all the memories in the project (or just the memories of a certain template class like Another potential option for you is |
To test whether we need to use template parameters in the definitions of our processing modules, as we have assumed so far, I reorganized the TC so that the current template parameters in the top-level template function are passed as function arguments instead. Compare the top-level template function on the master branch:
firmware-hls/TrackletAlgorithm/TrackletCalculator.h
Lines 186 to 197 in 88e4783
with that on the template_purge branch:
firmware-hls/TrackletAlgorithm/TrackletCalculator.h
Lines 193 to 208 in 5d8b1b3
In making this change, I had to introduce new template parameters for the inner and outer region types, since these are passed as parameters to the memory classes that define our interfaces. I don't see an obvious way around this. The inner and outer region types, however, do not change with each instance of the TC as the previous set of parameters did (e.g., all L1L2 TCs will have InnerRegion = BARRELPS and OuterRegion = BARRELPS, etc.). An alternative to this would be to keep just the seed as the only template parameter, and determine the inner and outer region types from it, as is currently done on the master branch.
Below is a comparison of the timing and resource utilization, all from the post-implementation reports, for a VU7P. The version on the template_purge branch has slightly worse timing and some of the resources shifted around, but overall it seems to be very similar to the version on the master branch.
I think this demonstrates that we can convert most of our template parameters to function arguments. This doesn't necessarily change anything about how we export IP cores for the firmware, but using function arguments might be more convenient for the HLS-based emulation.
The text was updated successfully, but these errors were encountered: