Wikipedia:Reference desk/Archives/Computing/2018 September 16

= September 16 =

Parallel computing on an Intel i5
I wrote a program to do some intensive calculations and use parallel processing on an Intel i5. I started it about 33 hours ago and I expect it to finish tonight. After I started it, for several hours (the rest of the day yesterday) it was using close to 100% of the CPU. Then this morning it was using only 81%. Then this afternoon it started using only 56%. Every other process combined is using less than 1% of the CPU. I'm losing a lot of CPU processing power - why? (And will it be the same on an i7?) Bubba73 You talkin' to me? 23:56, 16 September 2018 (UTC)
 * Of course it's impossible to know what is happening without further analysis using software tools. The first thing that's crossing my mind is that the cpu may be overheating. That's easy to check with one of the many cpu temp gadgets that are on the net. Jahoe (talk) 11:31, 17 September 2018 (UTC)
 * I have experienced cpu usage on a dual core dropping to 50%, and going up to 100% after a brief sleep mode. Cpu usage in parallel processing can depend on the program. Maybe some of the cpu cores have little to do because they wait for data from other cores, or the program doesn't use them at all at this stage. PrimeHunter (talk) 12:42, 17 September 2018 (UTC)


 * I thought of overheating, but I checked and it was in the 50-60C range, but that was after it dropped to 81%. The program finished, and I'll restart it and check the temperature after it has been running near 100% for a while.
 * As far as the software tools, I'm using the parallel stuff in Delphi XE 10.2, in particular the parallel for. I've used this before, but not for runs over 24 hours.  The way the program is designed, it should be using all four cores until near the end of 48 cases.  (I tested it on smaller cases.)  Bubba73 You talkin' to me? 16:52, 17 September 2018 (UTC)


 * As a test, I restarted it. It has been running at 99% for a while and the CPU temps have gotten up to an average of 59C and leveled off, with individual ones never getting above 63C, which is well within specifications (< 73C, I think).  Bubba73 You talkin' to me? 17:31, 17 September 2018 (UTC)


 * Several hours later and it is still running at 99% and averaging 59C. Bubba73 You talkin' to me? 20:20, 17 September 2018 (UTC)


 * It's really dangerous to speculate without more details - but the symptom described implies that your computational task can't keep the CPU busy. This almost always means that your work is "I/O bound."  If you aren't explicitly doing file I/O - which you would already know about - then the next most probable culprit is file-backed paging implemented by the operating-system's virtual memory system.  What does the memory usage look like?  Does it all fit in physical main memory, or is the memory footprint larger than the available RAM?
 * Nimur (talk) 17:44, 18 September 2018 (UTC)


 * There is essentially no I/O. It was running 48 outer loops and wrote one line after each was finished, and then one line at the end (all to the screen).  It did keep the CPU busy for several hours, then the CPU use started dropping.  (I started it about 10AM and it was still running full blast late at night, but the next morning it had dropped to 81%.  Later it dropped to 56%.)  There were no files in use.  I have something else running on that computer now, so I can't look at the memory usage, but it has 32GB and the program uses very little memory, although the EXE is about 12MB.  It should have been using only a tiny fraction of the RAM.  Bubba73 You talkin' to me? 18:08, 18 September 2018 (UTC)


 * The i5 I was running the program on is going to be busy for about 2 more days, but I did some tests on smaller cases on an i7. Memory use was 2.2MB. I was running 42 outer loops (each loop's running time is exponential in a n, which is different from the number of loops).  On the i7, it starts out running 7 threads.  when it finished 24 outer loops, it dropped to running 6 threads.  After about 27 outer loops, it dropped to 5 threads.  And after 35 outer loops, it seems to have dropped to running 4 threads.  So I think this is something that the Delphi Parallel Programming Library is doing - it must think that is is using too much CPU, so lowering the number of threads it is running.  Bubba73 You talkin' to me? 18:41, 18 September 2018 (UTC)


 * A book I have that covers Delphi says "The Thread Pool is 'self tuning' in that it automatically takes into account the number of cores your CPU has, as well as the current burden on those cores. It creates threads as needed, trying to maximize the capabilities of your machine. When the system is free it creates more threads... ". This is probably second-guessing what I am doing, but it is not working as the book describes.  The i5 is a bare-bones system - everything else is taking only a fraction of a percent of the CPU (that isn't true for the i7 I was using.)  It is cutting down the number of threads after about the half-way point.  I will try doing the first half and then the second half and see what happens. Bubba73 You talkin' to me? 18:58, 18 September 2018 (UTC)
 * Breaking it into two parts made it keep the CPU as busy as it should (at least for the 4.6 minutes it took to run). Bubba73 You talkin' to me? 19:18, 18 September 2018 (UTC)

Play two audio tracks (different languages) at the same time
To watch a movie I connect my laptop through HDMI to the TV. When watching alone it's not a problem to watch a movie in the track that I wish, obviously. However, if a group is watching, some would like to hear track A and others track B. Is there a way to play track A through TV and track B through head phones? If there are 2 laptops available, it would be trivial to play both at the same time. However, how could I perfectly synchronise the audio played by each one? The two laptops could be any combination of Windows, Linux and Mac. So far the best solution I could think of is to run two Linux laptops, and through the command line set them to start playing the same file at time t. After pauses, set them to play a file from a specific minute  on at a certain time. That would coordinate two copies playing different audio tracks. --Doroletho (talk) 23:57, 16 September 2018 (UTC)
 * This is not a common feature of free- or low-cost consumer video playback hardware and software. If you start with professional-grade commercial software, it's pretty easy to configure audio streams and route playback through different hardware outputs to different speakers - or to a software mixer and thence to a single speaker - or whatever you seek.
 * If your target is low- or zero- cost, you might start by developing expertise with your favorite Linux or Windows software. VLC is a popular configurable playback tool, and it has a standard procedure for multi-track audio and even has a quick tutorial for multi-instance playback if you choose to use that method.  You might also want to learn how to use your system's audio mixer.  On linux-like systems, JACK is a very popular audio tool suite; on Windows, the built-in system is controllable through the built-in volume control user-interface.
 * These procedures aren't easy, which is why there is still a market for commercial (non-free) video playback software.
 * Nimur (talk) 15:15, 17 September 2018 (UTC)
 * Confirm, VLC is able to run several tasks at same time, else use a second other player, or run VLC as program from console. -- Hans Haase (有问题吗) 07:19, 21 September 2018 (UTC)