User Tools

Site Tools


eman2:parallel_threaded

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
eman2:parallel_threaded [2025/07/03 01:02] steveludtkeeman2:parallel_threaded [2025/07/03 01:27] (current) steveludtke
Line 11: Line 11:
 === Quickstart === === Quickstart ===
 Programs with parallelism support will take the --parallel command line option as follows: Programs with parallelism support will take the --parallel command line option as follows:
 +<code>
 --parallel=thread:<n> --parallel=thread:<n>
 +</code>
 where <n> should be replaced by the number of cores you wish to use. That's it. Quite simple. where <n> should be replaced by the number of cores you wish to use. That's it. Quite simple.
  
Line 21: Line 21:
 This will put (sometimes large) temporary files in /tmp. On some systems now /tmp is a ramdisk, which can cause real problems. You can use an alternate folder for these temporary files, but make sure they are on the local computer, not a remote filesystem shared among machines for the same account: This will put (sometimes large) temporary files in /tmp. On some systems now /tmp is a ramdisk, which can cause real problems. You can use an alternate folder for these temporary files, but make sure they are on the local computer, not a remote filesystem shared among machines for the same account:
  
 +<code>
 --parallel=thread:<n>:<tmp_path> --parallel=thread:<n>:<tmp_path>
 +</code>
  
 for example: for example:
  
 +<code>
 --parallel=thread:32:/home/stevel/tmp --parallel=thread:32:/home/stevel/tmp
 +</code>
  
 The --threads option should not have this problem. The --threads option should not have this problem.
Line 33: Line 37:
 As above, in essence all you need to do is say, for example: As above, in essence all you need to do is say, for example:
  
 +<code>
 --parallel=thread:4 --parallel=thread:4
 +</code>
  
-to make use of 4 cores on your computer. However, if you are running, for example, on your desktop computer or workstation, you might wish to consider using 1 less core than you actually have to help make your machine more responsive for normal interactive use while the job is running. This is completely up to you.+to make use of 4 cores on your computer. 
  
-As mentioned on the previous page you should also specify:+If the specific program supports it, you should also specify:
  
 +<code>
 --threads=4 --threads=4
 +</code>
  
-for any programs that support it. This option is for cases where --parallel (which also supports MPI and other types of parallelism) cannot be used+This option is for cases where --parallel (which also supports MPI and other types of parallelism) cannot be used.
- +
-Specifying a number of threads larger than the number of cores your computer has will quite probably cause the job to run more slowly, and in some cases may cause it to run disastrously slowly+
  
-//What about hyperthreading// - Some computers support the concept of hyperthreading. This is when a CPU pretends to have more cores than it actually has, and tries to run 2 jobs using the same core. Sometimes this can result in improved efficiency, as there may be pieces of the core which can work semi-independently. So, for example, if one job is trying to do floating point math and another job is trying to do integer math, it may be that they can both do their computations at the same time on the same core. This sort of coincidence is rare in most programs. With current generation Intel chips, you can get some benefit out of hyperthreading, but only a little. If your computer has 16 physical cores, and thus 32 "threads", it may be useful to specify as many as 20 or even 24 threads. This will not make the job run 50% fasterbut may make it run 5 or 10% faster. Using 32 threads is not generally useful, and will likely be counterproductive.+Specifying a number of threads significantly larger than the number of cores your computer has will quite probably cause the job to run more slowlyand in some cases may cause it to run disastrously slowly
  
-//How do I know how many cores my machine has ?// - This depends on what OS you are usingOn Macsimply use the 'About this Mac' item on the apple menu. It may say something like "x 2.66 6 core Xeons" or somesuch (meaning, in this case12 cores)Under linuxyou can 'cat /proc/cpuinfo', and it will give information on each core. Processors are numbered starting with 0so if you see 'Processor : 3' as the last entryyou have 4 cores on your machine+  * //What about hyperthreading// - Some computers support the concept of hyperthreadingThis is when CPU pretends to have more cores than it actually hasand tries to run jobs using the same core. Sometimes this can result in improved efficiencyas there may be pieces of the core which can work semi-independentlySofor exampleif one job is trying to do floating point math and another job is trying to do integer math, it may be that they can both do their computations at the same time on the same core. This sort of coincidence is rare in most programs. With current generation Intel chips, you can get some benefit out of hyperthreading, but only a little. If your computer has 16 physical cores, and thus 32 "threads", it may be useful to specify as many as 20 or even 24 threads. This will not make the job run 50% fasterbut may make it run 5 or 10% faster. Using 32 threads is not generally useful, and will likely be counterproductive.
  
-//Caveat -// Under linux there is a possibility that this number may be 2x larger than your actual number of coresIntel has technology called 'hyperthreadingwhich they use to market their chipsThis will make the machine appear to have 2x as many cores as it actually physically has, and can give a performance advantage under some specific situations (like word-processing, etc.), but is actually quite detrimental for something like large computational jobsAgainif you have only 4 physical coreswith hyperthreading making it look like you have 8 cores, you should only specify 4 threads to EMAN2or you will almost certainly make your job run slower, and perhaps even crash your machine under certain situations.+  * //How do I know how many cores my machine has ?// - This depends on what OS you are using 
 +    * On Mac, simply use the 'About this Macitem on the apple menu then press the "System Report" buttonOn the main Hardware page you'll see something like "Total Number of Cores: 10 (8 performance and 2 efficiency)"in which case 8 cores is a good number to use. 
 +    * Under linux, you can 'cat /proc/cpuinfo'and look for the "cpu cores" entry for any one of the processors. As long as your machine has only 1 physical CPUthis is the number of cores. If the last processor has a "physical id">0 then you have multiple CPUs and need to multiply the number of cores by the number of CPUs
  
 **Note about disk space:** - This parallelism option will put a bunch of scratch files in /tmp. These files can get quite large, so if your /tmp filesystem is small, you may wish to put the scratch files elsewhere. You can just specify --parallel=thread:<n>:</path/to/scratch> to do this, but be warned: The scratch directory MUST be on a local hard drive, NOT a shared filesystem from another computer !!!  Violating this could lead to database corruption ! **Note about disk space:** - This parallelism option will put a bunch of scratch files in /tmp. These files can get quite large, so if your /tmp filesystem is small, you may wish to put the scratch files elsewhere. You can just specify --parallel=thread:<n>:</path/to/scratch> to do this, but be warned: The scratch directory MUST be on a local hard drive, NOT a shared filesystem from another computer !!!  Violating this could lead to database corruption !
  
-**IMPORTANT WARNING ABOUT MEMORY** - For most tasks, if you specify thread:4, that job will use 4x as much memory (RAM, NOT disk space) as if you use only a single thread. If you have, for example, only gigs of RAM, and your job was using 1 gig when you ran it on a single processor, if you then specify thread:4, you will probably exhaust your system memory, and likely cause either excessive swapping (making your machine seem to run like molasses), or possibly even crash the entire machine. This is particularly important if you have a machine with, say, 12 cores. This effect can be mitigated to some extent through use of the '--lowmem' option provided for commands like 'e2refine.py', but it will not eliminate the problem. This issue is extremely problem dependent, though.  If you are refining something like the demo groel data set with a box size <200, and only ~5,000 particles, memory isn't likely to even approach being exhausted. However, if you're processing a virus with a box size of 800x800 to very high resolution, you will almost certainly have issues unless you have a LOT of RAM+**IMPORTANT WARNING ABOUT MEMORY** - For most tasks, if you specify thread:8, that job will use 8x as much memory (RAM, NOT disk space) as if you use only a single thread. If you have, for example, only 16 gigs of RAM, and your job was using 4 gigs when you ran it on a single processor, if you then specify thread:8, you will probably exhaust your system memory, and likely cause either excessive swapping (making your machine seem to run like molasses), or possibly even crash the entire machine. This is particularly important if you have a machine with, say, 64 cores. 
  
-Note that not all programs will run in parallel. If a program does not accept the --parallel option, then it is not parallelized.+Note that not all programs will run in parallel, and some will intrinsically use the GPU rather than threads on the CPU. If a program does not accept the --parallel option or the --threads option, then it isn'parallelized.
  
eman2/parallel_threaded.1751504570.txt.gz · Last modified: by steveludtke