rcedgar / muscle

Multiple sequence and structure alignment with top benchmark scores scalable to thousands of sequences. Generates replicate alignments, enabling assessment of downstream analyses such as trees and predicted structures.
https://drive5.com/muscle
GNU General Public License v3.0
186 stars 21 forks source link

If is possible to release Muscle V5 version which has no dependence of omp.h? #65

Closed orangeSi closed 10 months ago

orangeSi commented 10 months ago

Hi Robert, The openmp(omp.h) is a dependence of Muscle V5, so if is possible give a version which removed the dependence of omp.h ? I want to compile Muscle V5 to webassembly by https://github.com/emscripten-core/emscripten for use Muscle V5 in Web Browser, but emscripten still not support openmp(omp.h) and maybe continue for a long time.

Thanks~

rcedgar commented 10 months ago

I can suggest two options. (a) The dependency on OMP is very easy to remove if you have any C/C++ skills, I can explain how to do this. (b) MUSCLE v3 is single-threaded and has no dependency on OMP, you could use that instead: https://drive5.com/muscle/downloads_v3.htm

orangeSi commented 10 months ago

ok,thanks~ (a) I only learn C and C++ lang a few years ago~ by google, I just known should do these ( and If there are something more need to do ? ):

  1. remove all lines which contain#pragma omp + header file #include <omp.h>: This is easy to do for me
  2. remove some function of OMP, example omp_get_thread_num: this will take some time to do for me, Could you explain some guideline? example how to remove some function of OMP ?

(b) I had compile MUSCLE v3.8.1551 to wasm successfully, and will pulibsh it at https://github.com/biowasm/biowasm by github PR after some days, and I still want to try lastest V5 just.

rcedgar commented 10 months ago

Removing the lines with #pragma omp is ok, but should not be necessary because a compiler which does not support OMP should ignore them.

The basic idea is to make a fake OMP library that is running just one thread.

Replace #include <omp.h> with #include of your own header file which defines a macro or stub funtion for all the omp_* functions used in the source code. You can make a list of these functions by making an empty header file and looking at the error messages.

Most of the omp_* functions can be replaced by do-nothing macros in your new header file, e.g. all functions related to locking:

#define omp_init_lock(x)  /* do nothing */
#define omp_set_lock(x)   /* do nothing */
#define omp_lock_lock(x)  /* do nothing */

omp_get_num_threads() should return 1, e.g. as a macro:

#define get_num_threads(x) 1

omp_get_thread_num() should return 0 (one thread with zero-based indexing), e.g. as a macro:

#define get_thread_num(x) 0

orangeSi commented 10 months ago

thanks a lot~ I will try this way to write a fake omp.h!

orangeSi commented 10 months ago

I make a fake omp.h as below, and compile with -fno-openmp + add a fake GetPhysMemBytes, then it works! now I am submiting a PR to public the wasm file of Muscle V5 by https://github.com/biowasm/biowasm/pull/81.

#define omp_init_lock(x)  /* do nothing */
#define omp_set_lock(x)   /* do nothing */
#define omp_unset_lock(x) /* do nothing */
#define omp_lock_lock(x)  /* do nothing */
typedef void *omp_lock_t;

#define omp_get_num_threads(x)  1
#define omp_get_thread_num(x)  0

#define omp_get_max_threads(x) 1

thanks ~

orangeSi commented 10 months ago

@rcedgar If compile to unknown target(example above webassembly), need add a fake GetPhysMemBytes.
So I make a PR at https://github.com/rcedgar/muscle/pull/68, If that PR is not appropriate, I will close that PR, please let me known, thanks a lot ~

orangeSi commented 10 months ago

@rcedgar I compiled Muscle V5 to webassembly to use it in web browser, and release the wasm at https://biowasm.com/cdn/v3/muscle/5.1.0, thanks the guideline about fake omp.h !

orangeSi commented 5 months ago

muscle v3.8.1551 is also compiled to wasm to use in web browser at https://biowasm.com/cdn/v3/muscle/3.8.1551