Multicore calculation with WUFI 2D 4 - speed up WUFI 2D
Posted: Mon Jun 27, 2022 9:04 pm -1100
Some users found that on newer CPUs with many cores WUFI 2D is slower than on their older CPUs with up to four cores.
The problem is the following:
To use multiple cores, the differential equations to be solved has to be split. For that information from the other parts of the equation system has to be passed between the used cores, which needs time. This is called synchronization overhead. The more cores are used the more overhead is produced.
By default WUFI 2D is using all but one of the cpu cores (including hyperthreading) - for calculation, he one remaining is thought to be used for the GUI. Depending on the construction most time a number of about 4 to 6 cores is optimal, then the calculation speed decreases with increasing cores. Unfortunately the number of used cores cannot be set yet in WUFI 2D directly.
I wrote some batch files to handle this issue. One is a speed test to find out, how many cores are best for a project, one to calculate in batch mode with the given number of cores and one to set the number of cores to be used in a WUFI 2D session.
General information for working with command line mode in WUFI 2D (this is used by the batch files):
Set up your project in the GUI. After finished change to "Calculation". Doing that, the input file (input.dat) for the calculation kernel is created. This contains all information which are needed for the calculation. After that start the calculation to see, if everything is running. If the calculation starts you can stop it. Save your project. Now all files are written in the project folder.
wufi2d_core_test_all_cores.bat
To test the best numbers of cores to use, copy this file in your project folder. Set the hours to be calculated to about 100 (At the beginning there is often a redistribution of the initial moisture which needs more time to calculate than later time steps. So I would recommend to set this to about 100-200hours). You can do that in the GUI or by editing the input.dat file (first number in the 4th line). Start the batch. It is calculation the project starting with one core and increasing it by one up to the existing number of cores unless the needed time two times is slower than the last calculation. Then it displays the number of cores to use best. Use that number of cores for your calculation. Please remember to change back the calculation time in GUI or input.dat before calculating.
The output (for a calculation of 168 hours if i remember right) looks like this:
wufi2d_batch_calc_number_cores.bat <#cores>
Copy that file in your project file to do a command line (batch) calculation of your case. You can call the batch with the wished number of cores, but if you do not give a number you will get asked before the calculation. Please note: once started the calculation is running without any output as the output is redirected in the iter.txt file. Do not close the window until it shows "Calculation finished". You may see the status of the running calculation by opening iter.txt and scroll to the end.
wufi2d_batch_calc_number_cores_ren.bat <#cores> (added 05. April 2023)
Same as above but additionally asks for renaming the result files according to the name of the project file.
startWUFI2D_using_number_cores.bat <#cores>
Call that to start the GUI with the wanted number of cores. You can either call the batch with the number of cores to use, or if no number is given, you will be asked.
Only recommended for CPUs with up to 4 cores:
startWUFI2D_using_all_cores.bat
This starts WUFI 2D with existing cores plus one so all available cores are used for the calculation.
This is thought to be used for CPUs with 4 cores, where only 3 are used for calculation. This batch allows to use all 4 cores by initiating with 5 cores.
I did some tests with the Bed-Plate sample case from WUFI 2D. I calculated over three years (26280h) and got the following times:
Intel i5-7500T CPU - 4 cores - 3 used - Time 23,5 hours (my desktop)
Intel i9-11900K CPU - 8 cores - 15 threads used - Time 9,5 h
Intel i9-11900K CPU - 8 cores - 4 cores used - Time 1,6 h
I ordered this i9 for WUFI 2D calculations and really love it.
We have to include some automatism into WUFI 2D handling the cores, but that will need some more time. In the meanwhile this batch files are quite helpful.
There are still some things to solve. For example I have problems to set cores or threads (for hyperthreading). Further the affiliation to the single cores should be solved. This would allow to calculation multiple projects parallel in batch mode without slowing down each other.
If you have fun with batch coding feel free to enhance the files and share them with me / us.
Here you can download the batch-files:
https://owncloud.fraunhofer.de/index.ph ... PLtEXzctyv
Last change of files: 05. April 2023
Greetings
Christian
The problem is the following:
To use multiple cores, the differential equations to be solved has to be split. For that information from the other parts of the equation system has to be passed between the used cores, which needs time. This is called synchronization overhead. The more cores are used the more overhead is produced.
By default WUFI 2D is using all but one of the cpu cores (including hyperthreading) - for calculation, he one remaining is thought to be used for the GUI. Depending on the construction most time a number of about 4 to 6 cores is optimal, then the calculation speed decreases with increasing cores. Unfortunately the number of used cores cannot be set yet in WUFI 2D directly.
I wrote some batch files to handle this issue. One is a speed test to find out, how many cores are best for a project, one to calculate in batch mode with the given number of cores and one to set the number of cores to be used in a WUFI 2D session.
General information for working with command line mode in WUFI 2D (this is used by the batch files):
Set up your project in the GUI. After finished change to "Calculation". Doing that, the input file (input.dat) for the calculation kernel is created. This contains all information which are needed for the calculation. After that start the calculation to see, if everything is running. If the calculation starts you can stop it. Save your project. Now all files are written in the project folder.
wufi2d_core_test_all_cores.bat
To test the best numbers of cores to use, copy this file in your project folder. Set the hours to be calculated to about 100 (At the beginning there is often a redistribution of the initial moisture which needs more time to calculate than later time steps. So I would recommend to set this to about 100-200hours). You can do that in the GUI or by editing the input.dat file (first number in the 4th line). Start the batch. It is calculation the project starting with one core and increasing it by one up to the existing number of cores unless the needed time two times is slower than the last calculation. Then it displays the number of cores to use best. Use that number of cores for your calculation. Please remember to change back the calculation time in GUI or input.dat before calculating.
The output (for a calculation of 168 hours if i remember right) looks like this:
wufi2d_batch_calc_number_cores.bat <#cores>
Copy that file in your project file to do a command line (batch) calculation of your case. You can call the batch with the wished number of cores, but if you do not give a number you will get asked before the calculation. Please note: once started the calculation is running without any output as the output is redirected in the iter.txt file. Do not close the window until it shows "Calculation finished". You may see the status of the running calculation by opening iter.txt and scroll to the end.
wufi2d_batch_calc_number_cores_ren.bat <#cores> (added 05. April 2023)
Same as above but additionally asks for renaming the result files according to the name of the project file.
startWUFI2D_using_number_cores.bat <#cores>
Call that to start the GUI with the wanted number of cores. You can either call the batch with the number of cores to use, or if no number is given, you will be asked.
Only recommended for CPUs with up to 4 cores:
startWUFI2D_using_all_cores.bat
This starts WUFI 2D with existing cores plus one so all available cores are used for the calculation.
This is thought to be used for CPUs with 4 cores, where only 3 are used for calculation. This batch allows to use all 4 cores by initiating with 5 cores.
I did some tests with the Bed-Plate sample case from WUFI 2D. I calculated over three years (26280h) and got the following times:
Intel i5-7500T CPU - 4 cores - 3 used - Time 23,5 hours (my desktop)
Intel i9-11900K CPU - 8 cores - 15 threads used - Time 9,5 h
Intel i9-11900K CPU - 8 cores - 4 cores used - Time 1,6 h
I ordered this i9 for WUFI 2D calculations and really love it.
We have to include some automatism into WUFI 2D handling the cores, but that will need some more time. In the meanwhile this batch files are quite helpful.
There are still some things to solve. For example I have problems to set cores or threads (for hyperthreading). Further the affiliation to the single cores should be solved. This would allow to calculation multiple projects parallel in batch mode without slowing down each other.
If you have fun with batch coding feel free to enhance the files and share them with me / us.
Here you can download the batch-files:
https://owncloud.fraunhofer.de/index.ph ... PLtEXzctyv
Last change of files: 05. April 2023
Greetings
Christian