bsc-pm / nanox

Nanos++ is a runtime designed to serve as runtime support in parallel environments. It is mainly used to support OmpSs, a extension to OpenMP developed at BSC.
https://pm.bsc.es/nanox
GNU Lesser General Public License v3.0
38 stars 15 forks source link

Fix < operator so that DepsRegion can be used as key in std::map #9

Closed ac101m closed 4 years ago

ac101m commented 4 years ago

By default STL will use the < operator for the key type when inserting or looking up a key/value pair in std::map. DepsRegion has an overridden < operator and is used as a key value in a few maps in the cregions plugin. However the operator didn't take account of the end address of the region. This caused funky things to happen.

ac101m commented 4 years ago

A further thought, modifying the < operator solves the problem but I don't think the < operator is very idiomatic in this case. How can you state that one range of memory is less than or greater than another? Best practice would probably be to remove the operator and specialise std::less or write a comparator instead. Here's an example: https://stackoverflow.com/questions/1102392/how-can-i-use-stdmaps-with-user-defined-types-as-key I can do this if you think it is worthwhile.

vlopezh commented 4 years ago

Thank you for your contribution and sorry for the delay in the merge process.