I am making a program that utilizes GTK and in the program a server is created. The GUI and server work well. I am also able to thread it. OMP is compiled and I have tested it with the OMP Hello World which is computed in C. It works and from the outputs come out obviously randomized. However when I try to run the server in parallel after I press a button with this code:
char * ip;
int por;
#pragma omp parallel num_threads(1) private(ip, por)
{
ip = (char *)gtk_entry_get_text(GTK_ENTRY(IP));
por = atoi((char *)gtk_entry_get_text(GTK_ENTRY(port)));
startServer(ip, por);
}
And obviously the include file #include <omp.h>
.
GTK does what it is supposed to do and the server starts and takes connections. However it isn't run in parallel. The reason I know this is because the GUI becomes unresponsive and frozen.
This is the command I use to compile it:clang++ -std=c++11 -Xpreprocessor -fopenmp -L/usr/local/opt/llvm/lib httpServerv2.cpp `pkg-config --cflags --libs gtk+-3.0` -lomp
httpServerv2.cpp is the name of my c++ file. I have to use clang++ with the tag -std=c++11 so that threading will work. Which does work. The rest of the tags are for gtk and openmp. Is there something wrong with the way I am starting it? Because it is not running in parrallel.
UPDATE
So I figured out that it is running in parallel, just not the way I thought it should. What I thought was going to happen was that the program would just call the omp parallel and then the rest of the program would be able to continue to run while the program I wanted to run in parallel, in this case my server, just ran on another CPU. What I didn't realize was that after you call the parallel program, it actually waits for the processes to finish before the code can continue. Is there a way to make it so that the program doesn't wait for the processes to finish?
Something like the thread module has for the thread to detach, just for OMP.