Replies: 12 comments 24 replies
-
One option that seems sensible is for PSyclone (or even fparser?) to have its own 'module' files like a Fortran compiler does. @sergisiso suggested that this could just be some sort of serialisation of the SymbolTable for a particular file. Tagging @schreiberx and @hiker as they've been involved in this discussion too. |
Beta Was this translation helpful? Give feedback.
-
OK, so the difference is that the AutoSearch variant doesn't use PSyIR? That's not what we do at the moment. Also, if we're going to cache things anyway, I don't think that's a major concern? |
Beta Was this translation helpful? Give feedback.
-
I know this won't convince some of you to not do caching but note that parsing for "import dependencies" can be made MUCH faster because most of the time fparser is doing the recursive descent inside routines but for dependencies only the top-level public symbols are needed, and these are pretty fast to parse. We could have a mode that stops the recursion at routine declarations. We can also design a gradual parsing in fparser, for the "now also get me the tree of this particular routine that I want to inline". |
Beta Was this translation helpful? Give feedback.
-
Some status update: I worked on restructuring the code.
The other "global" cache file will be then updates if the checksum of all other cached files changes. Quite easy :-) |
Beta Was this translation helpful? Give feedback.
-
First of all, it might be worth considering #2681 - Fab already writes dependency files, and while we certainly do not want to have a dependency on Fab, using a compatible file format (json based atm) would have some benefits (reduce need to parse file in fab again). Of course, atm it only contains information useful for building. But if we could write our information to include the information used by fab, that might be good. One problem that I didn't see addressed - if we write one 'cache' file per source file ... how do we find the source file? Do we use a one directory for all cached files? Do we then need to think of name duplication (same file name in two directories?) Or do we need to provide 'search directories' (like for a compiler)? I am also a bit confused what is cached where. I understand that atm it's the fparser tree, but it's done in PSyclone (or??) Wouldn't it be useful to do this in fparser? This way, other applications (like Fab) could get some benefit? |
Beta Was this translation helpful? Give feedback.
-
I also wanted to add a particular information I think is very relevant (and might have caused misunderstandings): |
Beta Was this translation helpful? Give feedback.
-
I agree with Joerg on the fparser caching => fparser should do it. That way other people will benefit, not just PSyclone and Poseidon users. |
Beta Was this translation helpful? Give feedback.
-
It should be as transparent as possible. If the Module Manager decides it needs the parse tree then it should ask fparser. I would say that whether or not fparser uses an existing, pickled parse tree or not is up to it. As your timings helpfully show, fparser is not the fastest thing in the world so anyone using it will benefit from well designed caching (or at least, the ability to use such caching). We need to give some thought to how this will be controlled (probably an option to the parser constructor?) and where any such files are to be put. It will probably be helpful to follow normal compiler behaviour for this and think of the pickled parse trees as fparser 'mod' files. Following this logic, by default such files would then be written to wherever a compiler would put them (gfortran supports |
Beta Was this translation helpful? Give feedback.
-
@hiker It looks like you wrote the ModuleManager to handle files before being preprocessed since you also check for a .f90 file ending with a comment related to preprocessed files. Is this right? Is there any reason for that why this is in psyclone? I'd see this more as part of a build system (Fab?). |
Beta Was this translation helpful? Give feedback.
-
I worked on a multiplexer solution to choose the ModuleManager via a ModuleManagerMultiplexer: The main points are:
@hiker If you're worried about such a restructuring of the module manager, this could also be rewritten in the original form that there's the original ModuleManager class (+ just a few tweaks to it). In addition, there would be a new set_module_manager() method allowing the specification of which class will be instantiated and returned by the get_singleton() method. Maybe that's a good compromise. In this way, you can use whatever you developed, and I can hook in my own ModuleManager from Poseidon - or even leave it in Poseidon, which will avoid a lot of coverage tests. |
Beta Was this translation helpful? Give feedback.
-
Is there any agreement on how to handle multiple modules if processed by psyclone (e.g., finding the right routine matching a call)? I see these two options: a) All containers have to be part of the same FileContainer. Consequently, they can be all accessed by going to the root node and traversing down. b) All containers can be stored in more than one FileContainer - e.g. by loading .f90 files individually. Consequently, this requires some management behind it which would be, e.g., the ModuleManager. If going for (b) (which looks like the best solution), this would require a ModuleManager to, e.g., walk over the different containers. It there an agreement that the ModuleManager should be used for accessing other modules? |
Beta Was this translation helpful? Give feedback.
-
Caching is now available with this PR in This doesn't change anything in the ModuleManager except for an option to activate caching. |
Beta Was this translation helpful? Give feedback.
-
There has been a lot of discussion in Teams about the caching of PSyIR/parse tree/module information. The main problem that we have is that PSyclone is invoked once per source file and therefore there can be an awful lot of repeated parsing/processing for a large code-base.
Beta Was this translation helpful? Give feedback.
All reactions