-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Refactor] Use switch-case instead of "static std::map" in taichi/lang_util.cpp #1750
Comments
Hello! I've left one PR so far, and I'd be interested in taking this. |
A lot of thanks to @aryansoman for refactoring most of the functions! Now we are almost there, the only function left is Lines 306 to 336 in c3f1a5d
Suggested solution: Let's not use switch case in this special case. Note that |
Hi, I think it is not a difficult work, let me take it! :) |
This is fully done. A lot of thanks to @Hanke98 and @aryansoman! |
Where to refactor
taichi/lang_util.cpp
has quite a few functions (e.g.,data_type_name
,data_type_format
) that uses astatic std::map
to store input-output mapping.taichi/taichi/lang_util.cpp
Lines 67 to 88 in a58a9af
What's wrong with the current design
When multiple threads are calling the function with the static map uninitialized, there will be parallel writes to the "std::map". This may cause a segmentation fault.
How to refactor
Example
The code above should be changed into something like
Additional comments
This is a good starting point for newcomers. Please leave a note if you have contributed < 3 PRs and to take this :-)
Open a draft PR if you want early feedback. It is suggested to ask for a review from me after the first function is refactored before apply your modification to all functions in that file.
The text was updated successfully, but these errors were encountered: