Skip to content

Quick fix to multithreading issue by refining specialization of contravariant vectors#62

Merged
tristanmontoya merged 3 commits intomainfrom
tm/refine_specialization_contravariant_vectors
Jan 15, 2025
Merged

Quick fix to multithreading issue by refining specialization of contravariant vectors#62
tristanmontoya merged 3 commits intomainfrom
tm/refine_specialization_contravariant_vectors

Conversation

@tristanmontoya
Copy link
Member

@tristanmontoya tristanmontoya commented Jan 14, 2025

This is an attempt to fix the problem @benegee noted in #61, in which the cases which use "standard" Trixi.jl solvers (i.e. not those for PDEs on surfaces) return an error when multiple threads are used, due to TrixiAtmo.jl's specialized get_contravariant_vector method for PtrArray types being called inadvertently. I'm not super familiar with the workings of PtrArray, but looking at the StrideArraysCore.jl code, I was able to figure out what type parameters would be associated with a 2D mesh in 3D space, and therefore hard-coded the dispatch for those dimensions. With this change, the issues in #61 are no longer encountered.

@codecov
Copy link

codecov bot commented Jan 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.45%. Comparing base (e7c1de7) to head (5af6773).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #62      +/-   ##
==========================================
- Coverage   89.46%   89.45%   -0.01%     
==========================================
  Files          20       20              
  Lines        1803     1802       -1     
==========================================
- Hits         1613     1612       -1     
  Misses        190      190              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@benegee benegee left a comment

Choose a reason for hiding this comment

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

Great fix. Thanks a lot @tristanmontoya !
I am not super familiar with this either, but obviously your specialization works and it contains NDIMS as well as NDIMS_AMBIENT, so it cannot interfere with Trixi's function anymore. The only concern would be that the type is too specific now and does not cover all your cases. If this not an issue, we could go for it.

@benegee benegee linked an issue Jan 14, 2025 that may be closed by this pull request
@tristanmontoya
Copy link
Member Author

tristanmontoya commented Jan 15, 2025

Great fix. Thanks a lot @tristanmontoya ! I am not super familiar with this either, but obviously your specialization works and it contains NDIMS as well as NDIMS_AMBIENT, so it cannot interfere with Trixi's function anymore. The only concern would be that the type is too specific now and does not cover all your cases. If this not an issue, we could go for it.

Thanks! It covers all the cases we use now, and doesn't have a significant impact on performance. We can look for another solution if needed later on.

@tristanmontoya tristanmontoya merged commit 13611fc into main Jan 15, 2025
8 checks passed
@tristanmontoya tristanmontoya deleted the tm/refine_specialization_contravariant_vectors branch January 15, 2025 04:10
@ranocha
Copy link
Member

ranocha commented Jan 15, 2025

It would be great to add some CI tests running an example with multiple threads to ensure that the bug does not occur anymore

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Overwritten get_contravariant_vectors leading to error

3 participants