EddyRivasLab / infernal

RNA secondary structure/sequence profiles for homology search and alignment
Other
101 stars 24 forks source link

cmscan,cmsearch cpu & mpi option definitions #4

Closed kalvari closed 8 years ago

kalvari commented 8 years ago

@nawrockie

Hi Eric ,

I was going though cmsearch and cmscan code and noticed that you have the constants CPUOPTS and MPIOPTS that define --cpu and --mpi options reversed (cmscan lines: 110-113 and cmsearch lines: 84-87).

For convenience I'm copying lines 110-113 from cmscan below:

#if defined (HMMER_THREADS) && defined (HAVE_MPI)
#define CPUOPTS     "--mpi"
#define MPIOPTS     "--cpu"
#else

They are both only used once under #ifdef HMMER_THREADS and #ifdef HAVE_MPI, lines 170 and 174 respectively.

I was wondering if these would be troublesome when compiling the code with the --enable-mpi option, or whether there's a reason why they are set this way.

Kind regards, Ioanna

nawrockie commented 8 years ago

Hi Ioanna,

Sorry for the delay... I can see why you're confused, but the code is correct despite being confusing.

CPUOPTS is used only once in each cmsearch.c and cmscan.c: in the definition of the --cpu option. Specifically it is used to define the set of other options that --cpu is incompatible with. If --cpu is used on the command line along with any option in the CPUOPTS variable, then the program will die and report an error that those two options are incompatible. As you noticed, CPUOPTS is set to --mpi, so --cpu and --mpi are incompatible options. They are incompatible because cmsearch and cmscan can either be run in multithreaded mode (which is true by default, but set specifically to threads with --cpu ) or in MPI mode (which occurs when --mpi is used). It can't be run in both modes, which is why we don't allow users to specify both --cpu and --mpi on the command line.

The inverse is true for --mpi. It is incompatible with MPIOPTS, which is set to --cpu.

CPUOPTS and MPIOPTS are only set to --mpi and --cpu, respectively, if both HMMER_THREADS and HAVE_MPI are defined, otherwise they are set to NULL. The reason for this is that it only makes sense to make --cpu and --mpi incompatible if they are both potential options. HMMER_THREADS will be defined if multi-threading is possible.

The HMMER_THREADS variable is defined if the system you have compiled Infernal on can use threads (most can) and you haven't configured infernal with the --disable-threads flag. The HAVE_MPI variable is only defined if you've configured infernal with the --enable-mpi flag.

Hope this helps. Let me know if this makes sense, or if you have any questions.

kalvari commented 8 years ago

Hi Eric,

No worries at all. Thank you for getting back to me.

I was trying to install infernal 1.1.2 on RHEL7 with the --mpi option. I didn't realised it was checking for option incompatibility, until I ran into the error message. Thank you for pointing that out and the thorough explanation.

At the begging it wasn't clear to me whether --mpi was a sub-option for --cpu, or if those two were independent from one another. A few test runs did the trick. It all makes sense now and everything's running smoothly.

Great work by the way. The code reads effortlessly.

nawrockie commented 8 years ago

Great, I'm glad that it makes sense now, and thanks for your kind words. Don't hesitate to ask any other questions you might have.