Skip to content

ggml-threading.cpp #7576

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

ggml-threading.cpp #7576

wants to merge 2 commits into from

Conversation

kunnis
Copy link
Contributor

@kunnis kunnis commented May 27, 2024

Move all the threading related stuff to it's own file as discussed in the text of #6915

I picked cpp because I was thinking we'd use std::thread so we won't have to maintain two implementations of the thread operations. It'll also let us use std::mutex and std::atomic, and those primitives will likely be faster than our own implementations. However, this would just be the leading structural change. My goal with this PR is to not make any functional changes, and then we can do separate tests of the actual functional changes.

@slaren @ggerganov Do you think I'm headed in the right direction with the structural changes? I still need to do some more testing and self-reviews and I've only tested this really in windows so far, but I want to make sure I'm not headed in the wrong direction.

@github-actions github-actions bot added build Compilation issues ggml changes relating to the ggml tensor library for machine learning labels May 28, 2024
@mofosyne mofosyne added the Review Complexity : Medium Generally require more time to grok but manageable by beginner to medium expertise level label May 28, 2024
@kunnis
Copy link
Contributor Author

kunnis commented May 28, 2024

I'll need to update for #7598

Comment on lines +19 to +22
extern void atomic_store(atomic_int* ptr, LONG val);
extern LONG atomic_load(atomic_int* ptr);
extern LONG atomic_fetch_add(atomic_int* ptr, LONG inc);
extern LONG atomic_fetch_sub(atomic_int* ptr, LONG dec);
Copy link
Member

Choose a reason for hiding this comment

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

I think it is very important that these functions are inlined, so they cannot be made extern. Additionally, we cannot export symbols with these names, because they are very likely to create conflicts. Same with the pthread and sched_yield stuff.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see. Valid points.

That's the exact kind of feedback I was looking for. Thanks.

Comment on lines +115 to +116
extern void set_numa_thread_affinity(int thread_n);
extern void clear_numa_thread_affinity(void);
Copy link
Member

Choose a reason for hiding this comment

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

Same issue here, we cannot export functions with these names. At least they need a ggml_ prefix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Compilation issues ggml changes relating to the ggml tensor library for machine learning Review Complexity : Medium Generally require more time to grok but manageable by beginner to medium expertise level
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants