Dear all,
I would like to use OpenMP with a code that uses the Openbabel library, and I am facing problems. I have copied an example of a simple code below. I have tried with Openbabel 2.3.2 and 2.4.1. I am compiling with: g++ -O3 -Wall -std=c++11 -Wno-uninitialized -I/home/nicolas/Programs/Openbabel_2.3.2/include/openbabel-2.0 -lm -fopenmp -c File.cpp -o File.o g++ File.o -o File.exe -rdynamic /home/nicolas/Programs/Openbabel_2.3.2/lib/libopenbabel.so -Wl,-rpath,/home/nicolas/Programs/Openbabel_2.3.2/lib -fopenmp When using the following, it works and produces 20 files (Ligand_0_x.xyz with x from 0 to 19): export OMP_NUM_THREADS=1 ./File.exe When I set export OMP_NUM_THREADS=4, it fails with: ============================== *** Open Babel Warning in Translate Cannot perform atom type translation: table cannot find requested types. Erreur de segmentation (core dumped) Can someone please help me fixing it. I am now wondering if it is possible to mix OpenMP and Openbabel. Thank you Nicolas *********************************************** #include <openbabel/mol.h> #include <openbabel/obconversion.h> #include <openbabel/forcefield.h> #include <openbabel/atom.h> #include <omp.h> using namespace std; int main(int nbarg, char * argv[]) { #pragma omp parallel for for (int x=0 ; x < 20 ; x++) { //Convert thread index and x in string ostringstream threadFlow; threadFlow << omp_get_thread_num(); string thread = threadFlow.str(); ostringstream xFlow; xFlow << x; string counter = xFlow.str(); //Read the input file OpenBabel::OBMol obMol; OpenBabel::OBConversion obConversion; OpenBabel::OBFormat *format = obConversion.FormatFromExt("Molecule.pdb"); obConversion.SetInFormat(format); obConversion.ReadFile(&obMol, "Molecule.pdb"); //Convert the object in xyz string outputFileName = "Ligand_" + thread + "_" + counter + ".xyz"; obConversion.SetOutFormat("xyz"); obMol.SetTitle(outputFileName); obConversion.WriteFile(&obMol, outputFileName); } return 0; } ------------------------------------------------------------------------------ The Command Line: Reinvented for Modern Developers Did the resurgence of CLI tooling catch you by surprise? Reconnect with the command line and become more productive. Learn the new .NET and ASP.NET CLI. Get your free copy! http://sdm.link/telerik _______________________________________________ OpenBabel-discuss mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/openbabel-discuss |
Dear all, Did anyone ever manage to use both openMP and openBabel in the same code? Thank you. Nicolas 2016-10-29 9:11 GMT+02:00 Nicolas Cheron <[hidden email]>:
------------------------------------------------------------------------------ Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE. Training and support from Colfax. Order your platform today. http://sdm.link/xeonphi _______________________________________________ OpenBabel-discuss mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/openbabel-discuss |
Administrator
|
Sorry - forgot to reply.
Do you need OpenMP on the Open Babel side (i.e. if not, turn off it off)? Your original email didn't make it clear whether it was just the client code that needed OpenMP, or you are compiling OB with OpenMP support also. The warning may indicate that your BABEL_DATADIR is not set correctly, though I'm not sure. Regards, - Noel On 8 November 2016 at 07:46, Nicolas Cheron <[hidden email]> wrote: > Dear all, > > Did anyone ever manage to use both openMP and openBabel in the same code? > > Thank you. > > Nicolas > > > 2016-10-29 9:11 GMT+02:00 Nicolas Cheron <[hidden email]>: >> >> Dear all, >> >> I would like to use OpenMP with a code that uses the Openbabel library, >> and I am facing problems. I have copied an example of a simple code below. I >> have tried with Openbabel 2.3.2 and 2.4.1. I am compiling with: >> >> g++ -O3 -Wall -std=c++11 -Wno-uninitialized >> -I/home/nicolas/Programs/Openbabel_2.3.2/include/openbabel-2.0 -lm -fopenmp >> -c File.cpp -o File.o >> g++ File.o -o File.exe -rdynamic >> /home/nicolas/Programs/Openbabel_2.3.2/lib/libopenbabel.so >> -Wl,-rpath,/home/nicolas/Programs/Openbabel_2.3.2/lib -fopenmp >> >> When using the following, it works and produces 20 files (Ligand_0_x.xyz >> with x from 0 to 19): >> export OMP_NUM_THREADS=1 >> ./File.exe >> >> When I set export OMP_NUM_THREADS=4, it fails with: >> ============================== >> *** Open Babel Warning in Translate >> Cannot perform atom type translation: table cannot find requested types. >> Erreur de segmentation (core dumped) >> >> >> Can someone please help me fixing it. I am now wondering if it is possible >> to mix OpenMP and Openbabel. >> >> Thank you >> >> Nicolas >> >> >> >> *********************************************** >> #include <openbabel/mol.h> >> #include <openbabel/obconversion.h> >> #include <openbabel/forcefield.h> >> #include <openbabel/atom.h> >> #include <omp.h> >> >> using namespace std; >> >> int main(int nbarg, char * argv[]) >> { >> #pragma omp parallel for >> for (int x=0 ; x < 20 ; x++) { >> //Convert thread index and x in string >> ostringstream threadFlow; >> threadFlow << omp_get_thread_num(); >> string thread = threadFlow.str(); >> ostringstream xFlow; >> xFlow << x; >> string counter = xFlow.str(); >> >> //Read the input file >> OpenBabel::OBMol obMol; >> OpenBabel::OBConversion obConversion; >> OpenBabel::OBFormat *format = >> obConversion.FormatFromExt("Molecule.pdb"); >> obConversion.SetInFormat(format); >> obConversion.ReadFile(&obMol, "Molecule.pdb"); >> >> //Convert the object in xyz >> string outputFileName = "Ligand_" + thread + "_" + counter + ".xyz"; >> obConversion.SetOutFormat("xyz"); >> obMol.SetTitle(outputFileName); >> obConversion.WriteFile(&obMol, outputFileName); >> } >> return 0; >> } >> >> >> >> > > > ------------------------------------------------------------------------------ > Developer Access Program for Intel Xeon Phi Processors > Access to Intel Xeon Phi processor-based developer platforms. > With one year of Intel Parallel Studio XE. > Training and support from Colfax. > Order your platform today. http://sdm.link/xeonphi > _______________________________________________ > OpenBabel-discuss mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/openbabel-discuss > ------------------------------------------------------------------------------ Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE. Training and support from Colfax. Order your platform today. http://sdm.link/xeonphi _______________________________________________ OpenBabel-discuss mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/openbabel-discuss |
Administrator
|
(ccing to list but avoiding scientific details in case they are super secret)
Quote: "I don't need OpenMP on the OpenBabel side. My project [REDACTED SUPER SECRET DETAILS] so the code is basically a big loop. The code uses OpenBabel and for now it runs on a single core. If I want to parallelize it on 4 cores I am using: ./Run.exe File.input & ./Run.exe File.input & ./Run.exe File.input & ./Run.exe File.input I would prefer using OpenMP to launch only one instance of the code. Regarding the warning, since the code works when I set "export OMP_NUM_THREADS=1" I don't think it is the cause of the problem. Actually, I have a feeling that you are running into a fundamental limitation of OB. It's not threadsafe. I can't say for certain that this is the cause, but OB has some global variables which will be shared between threads in a way that is not good, and it's not trivial for us to fix this (though we would certainly like to). I don't know of a way around this at the moment, apart from calling it 4 times separately. :-/ - Noel On 8 November 2016 at 09:42, Noel O'Boyle <[hidden email]> wrote: > Sorry - forgot to reply. > > Do you need OpenMP on the Open Babel side (i.e. if not, turn off it > off)? Your original email didn't make it clear whether it was just the > client code that needed OpenMP, or you are compiling OB with OpenMP > support also. > > The warning may indicate that your BABEL_DATADIR is not set correctly, > though I'm not sure. > > Regards, > - Noel > > On 8 November 2016 at 07:46, Nicolas Cheron > <[hidden email]> wrote: >> Dear all, >> >> Did anyone ever manage to use both openMP and openBabel in the same code? >> >> Thank you. >> >> Nicolas >> >> >> 2016-10-29 9:11 GMT+02:00 Nicolas Cheron <[hidden email]>: >>> >>> Dear all, >>> >>> I would like to use OpenMP with a code that uses the Openbabel library, >>> and I am facing problems. I have copied an example of a simple code below. I >>> have tried with Openbabel 2.3.2 and 2.4.1. I am compiling with: >>> >>> g++ -O3 -Wall -std=c++11 -Wno-uninitialized >>> -I/home/nicolas/Programs/Openbabel_2.3.2/include/openbabel-2.0 -lm -fopenmp >>> -c File.cpp -o File.o >>> g++ File.o -o File.exe -rdynamic >>> /home/nicolas/Programs/Openbabel_2.3.2/lib/libopenbabel.so >>> -Wl,-rpath,/home/nicolas/Programs/Openbabel_2.3.2/lib -fopenmp >>> >>> When using the following, it works and produces 20 files (Ligand_0_x.xyz >>> with x from 0 to 19): >>> export OMP_NUM_THREADS=1 >>> ./File.exe >>> >>> When I set export OMP_NUM_THREADS=4, it fails with: >>> ============================== >>> *** Open Babel Warning in Translate >>> Cannot perform atom type translation: table cannot find requested types. >>> Erreur de segmentation (core dumped) >>> >>> >>> Can someone please help me fixing it. I am now wondering if it is possible >>> to mix OpenMP and Openbabel. >>> >>> Thank you >>> >>> Nicolas >>> >>> >>> >>> *********************************************** >>> #include <openbabel/mol.h> >>> #include <openbabel/obconversion.h> >>> #include <openbabel/forcefield.h> >>> #include <openbabel/atom.h> >>> #include <omp.h> >>> >>> using namespace std; >>> >>> int main(int nbarg, char * argv[]) >>> { >>> #pragma omp parallel for >>> for (int x=0 ; x < 20 ; x++) { >>> //Convert thread index and x in string >>> ostringstream threadFlow; >>> threadFlow << omp_get_thread_num(); >>> string thread = threadFlow.str(); >>> ostringstream xFlow; >>> xFlow << x; >>> string counter = xFlow.str(); >>> >>> //Read the input file >>> OpenBabel::OBMol obMol; >>> OpenBabel::OBConversion obConversion; >>> OpenBabel::OBFormat *format = >>> obConversion.FormatFromExt("Molecule.pdb"); >>> obConversion.SetInFormat(format); >>> obConversion.ReadFile(&obMol, "Molecule.pdb"); >>> >>> //Convert the object in xyz >>> string outputFileName = "Ligand_" + thread + "_" + counter + ".xyz"; >>> obConversion.SetOutFormat("xyz"); >>> obMol.SetTitle(outputFileName); >>> obConversion.WriteFile(&obMol, outputFileName); >>> } >>> return 0; >>> } >>> >>> >>> >>> >> >> >> ------------------------------------------------------------------------------ >> Developer Access Program for Intel Xeon Phi Processors >> Access to Intel Xeon Phi processor-based developer platforms. >> With one year of Intel Parallel Studio XE. >> Training and support from Colfax. >> Order your platform today. http://sdm.link/xeonphi >> _______________________________________________ >> OpenBabel-discuss mailing list >> [hidden email] >> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss >> ------------------------------------------------------------------------------ Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE. Training and support from Colfax. Order your platform today. http://sdm.link/xeonphi _______________________________________________ OpenBabel-discuss mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/openbabel-discuss |
There are no super secret (the work is published http://pubs.acs.org/doi/abs/10.1021/acs.jmedchem.5b00886), I only thought it would by default reply to the list. Thank you for your answer. I had the feeling that there was something wrong coming from OB and different threads, but I wanted to be sure. This clarifies everything. Do you know if I will face the same problem if I try with MPI? (I have no expertise with MPI so the answer may be obvious in one way or another). Nicolas 2016-11-08 11:16 GMT+01:00 Noel O'Boyle <[hidden email]>: (ccing to list but avoiding scientific details in case they are super secret) ------------------------------------------------------------------------------ Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE. Training and support from Colfax. Order your platform today. http://sdm.link/xeonphi _______________________________________________ OpenBabel-discuss mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/openbabel-discuss |
On 11/08/2016 11:14 AM, Nicolas Cheron wrote:
> Thank you for your answer. I had the feeling that there was something wrong > coming from OB and different threads, but I wanted to be sure. This > clarifies everything. > > Do you know if I will face the same problem if I try with MPI? (I have no > expertise with MPI so the answer may be obvious in one way or another). Do you need the threads to talk to each other? If you can run completely separate processes, as in >> ... on 4 cores I am using: >> ./Run.exe File.input & >> ./Run.exe File.input & >> ./Run.exe File.input & >> ./Run.exe File.input then you could go the HTC route with e.g. condor: https://research.cs.wisc.edu/htcondor/ If you need the threads to talk to each other during the run, you're looking at HPC, and if you need performance you're probably better off with shared memory (OpenMP) rather than strict message passing (MPI). -- Dimitri Maziuk Programmer/sysadmin BioMagResBank, UW-Madison -- http://www.bmrb.wisc.edu ------------------------------------------------------------------------------ Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE. Training and support from Colfax. Order your platform today. http://sdm.link/xeonphi _______________________________________________ OpenBabel-discuss mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/openbabel-discuss |
Free forum by Nabble | Edit this page |