precice / precice/python-bindings
Reduce overhead of read_data and write_data
Nessuno ha ancora preso questa issue.
- Lingua principale
- Cython
- Stelle
- 30
- Fork
- 19
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
In this discourse thread, I tracked down the increased duration spent in the "do-nothing solver" down to read_data and write_data.
Most logical explanation would be the additional
- input
vertex_idsandvaluesare copied to a vector, even though passingnp.reshape(X, -1)to the preCICE API suffices and prevents copies. - output values are allocated, then passed to the API, then allocated to build an
np.array - we do a lot of additional error checking (which is good)
Example of rhoVW on solver2, being vectorial data of large mesh:
- Time measured in preCICE: 7ms (note: this doesn't allocate)
- Time measured in Python: 40ms (including overhead from activating profiling in python, this needs to allocate, so overhead scales with size)
Notes:
- With some tweaking I can get this down to 30ms. This makes the function actually shorter, simpler, and easier to follow.
np.flatten()copies the input, whilenp.reshapedoesn't if it can avoid it.- The majority of the generated code seems to be error handling, which we could potentially be avoided by using the CPP API directly for calls to
getDataDimensionsand do this in one place. - This overhead could be profiled with something like https://github.com/precice/precice/issues/1647
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dai punti di ingresso dei binding Python read_data e write_data, usando il thread Discourse collegato per comprendere l’overhead segnalato e le note relative a reshape, alle allocazioni e al controllo degli errori. Confronta i tempi misurati lato Python con quelli di preCICE, quindi verifica che le funzioni mantengano il loro comportamento evitando al contempo copie e allocazioni non necessarie.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- numpy, python
- Ambito
- api, performance
- Tipo di issue
- Refactoring
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100