-
Notifications
You must be signed in to change notification settings - Fork 50
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
Each task process only use one CPU? #279
Comments
On some systems, srun is not sufficient to run an MPI job properly; you need to use salloc and mpirun or mpiexec to run multi-node jobs properly. Does the command
behave differently than
In general, Grappa CPU usage will be high whether or not a task is idle---it busy-waits for new work to minimize startup latency. |
Can grappa process reach CPU usage of #include <thread>
#include <vector>
int main(int argc, char *argv[]) {
std::vector<std::thread> threads(2);
for (auto& thr : threads) {
thr = std::thread([](){
while(1){
}
});
}
for (auto& thr : threads) {
thr.join();
}
} then I run the program with srun I also wirte a simple grappa app #include <Grappa.hpp>
void app_main(int argc, char *argv[]) {
Grappa::CompletionEvent ce(2);
for(int i=0;i<2;i++){
Grappa::spawn([&ce]{
while(1){
}
ce.complete();
});
}
ce.wait();
}
int main(int argc, char *argv[]) {
Grappa::init(&argc,&argv);
Grappa::run([=]{
app_main(argc,argv);
});
Grappa::finalize();
} then I run the program with srun |
First, the program void app_main(int argc, char *argv[]) {
Grappa::on_all_cores([] {
Grappa::CompletionEvent ce(2);
for(int i=0;i<2;i++){
Grappa::spawn([&ce]{
while(1){
}
ce.complete();
});
}
ce.wait();
});
} When you call To answer your question directly, each Grappa process is bound to a CPU core. If you want to use more cores, you run more processes. |
Do you have plan to improve Grappa to support multiple CPU cores per process? @nelsonje @bmyerz I think it's quite different between If you guys agree with me but do not plan to do it, I'd like to have a try. Do you have any ideas? |
My concern would be that doing so would complicate the programming model. The difficulty of mixing access to global variables by having some tasks So, rather than corrupt the existing memory semantics, I suggest you On Tue, Apr 26, 2016 at 5:26 AM, Sun Chenggen [email protected]
|
I'm curious to hear what your specific motivation to implement multi-threaded Grappa processes is? Grappa's programming model provides its own shared memory abstraction. Is it that you want to implement core-to-core communication with intra-process shared memory because you think it will be faster? Then you might change the implementation of Grappa to be multithreaded without changing its user API. Or, do you just want to be able to use existing multithreaded applications within a Grappa program? If so, then it should be possible to tweak the code (found within this function I think https://github.com/uwsampa/grappa/blob/master/system/Grappa.cpp#L359) that pins Grappa processes to cores so that when you spawn a pthread in your Grappa process your pthread is allowed to run on another core than the core the main pthread is running on. Be warned: if you spawn more pthreads you should not have them call Grappa APIs. Grappa's APIs assume they are being called by only the main pthread. |
I use
srun -N2 -n4 ...
to start a grappa application, but I notice the CPU usage of each process is about100%
, seems like it only use one CPU. How can I config the CPU number for grappa application?The text was updated successfully, but these errors were encountered: