OpenMP parallelize grid initialization (set_epsilon)#3166
Draft
Luochenghuang wants to merge 2 commits intoNanoComp:masterfrom
Draft
OpenMP parallelize grid initialization (set_epsilon)#3166Luochenghuang wants to merge 2 commits intoNanoComp:masterfrom
Luochenghuang wants to merge 2 commits intoNanoComp:masterfrom
Conversation
The grid initialization loop in set_chi1inv iterates over all grid points to compute the inverse permittivity tensor. At high resolutions (e.g., 178M points at resolution 200), this takes minutes on a single core. Parallelize the loop with OpenMP (PLOOP_OVER_IVECS_C) when the material function is thread-safe (standard C++ geometry objects, not Python callbacks). The trivial[] flags use OpenMP reduction. A new virtual method material_function::is_thread_safe() returns false by default (safe for Python callbacks). The geom_epsilon subclass overrides it to return true unless MATERIAL_USER materials are present. Measured speedup: 30.7s -> 3.2s at resolution 100 (9.7x with 22 cores). Set OMP_NUM_THREADS to control parallelism.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3166 +/- ##
==========================================
+ Coverage 73.81% 73.90% +0.09%
==========================================
Files 18 18
Lines 5423 5454 +31
==========================================
+ Hits 4003 4031 +28
- Misses 1420 1423 +3 🚀 New features to boost your workflow:
|
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The grid initialization loop in
set_chi1inviterates over all grid points to compute the inverse permittivity tensor. At high resolutions, this takes awhile on a single core.Parallelize the loop with OpenMP (
PLOOP_OVER_IVECS_C) when the material function is thread-safe (standard C++ geometry objects, not Python callbacks). Thetrivial[]flags use OpenMP reduction.A new virtual method
material_function::is_thread_safe()returns false by default (safe for Python callbacks). Thegeom_epsilonsubclass overrides it to return true unlessMATERIAL_USERmaterials are present.Measured speedup: 30.7s -> 3.2s with 22M voxels (9.7x speed using 22 cores). Set
OMP_NUM_THREADSto control parallelism.