PC Review


Reply
Thread Tools Rate Thread

Dispatching tasks to multiple cores from a batch file

 
 
adish
Guest
Posts: n/a
 
      30th Apr 2008
Hi,

I need to execute many (say 20) time consuming tasks (each takes
about 1 hour to run).
At the moment I dispatch them serially one by one.
According to the TaskManager the process runs on 1 CPU at 50%
utilization.
The whole batch finishes running after about 20 hours.

I'm using a hyper-threaded XP machine and the env var.
NUMBER_OF_PROCESSORS=2.
I'd like to dispatch the tasks in parallel to each CPU so that my
processing time will be approx. 10hour.

How can I do this in a batch file script.

I know about the start command, but that does not give precise control
over the number of running processes, and can cause hanging or 3
processes to run in parallel. There is no option to wait.

Is there some way to loop on NUMBER_OF_PROCESSORS and
"waitMultipleThreads" until one of the tasks is done?

Please advise.
Thanks,
Adi

 
Reply With Quote
 
 
 
 
Ridge Runner
Guest
Posts: n/a
 
      30th Apr 2008
Why bother?

"adish" <(E-Mail Removed)> wrote in message
news:00657a5e-b97e-4b39-876b-(E-Mail Removed)...
> Hi,
>
> I need to execute many (say 20) time consuming tasks (each takes
> about 1 hour to run).
> At the moment I dispatch them serially one by one.
> According to the TaskManager the process runs on 1 CPU at 50%
> utilization.
> The whole batch finishes running after about 20 hours.
>
> I'm using a hyper-threaded XP machine and the env var.
> NUMBER_OF_PROCESSORS=2.
> I'd like to dispatch the tasks in parallel to each CPU so that my
> processing time will be approx. 10hour.
>
> How can I do this in a batch file script.
>
> I know about the start command, but that does not give precise control
> over the number of running processes, and can cause hanging or 3
> processes to run in parallel. There is no option to wait.
>
> Is there some way to loop on NUMBER_OF_PROCESSORS and
> "waitMultipleThreads" until one of the tasks is done?
>
> Please advise.
> Thanks,
> Adi
>
>



 
Reply With Quote
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      30th Apr 2008

"adish" <(E-Mail Removed)> wrote in message
news:00657a5e-b97e-4b39-876b-(E-Mail Removed)...
> Hi,
>
> I need to execute many (say 20) time consuming tasks (each takes
> about 1 hour to run).
> At the moment I dispatch them serially one by one.
> According to the TaskManager the process runs on 1 CPU at 50%
> utilization.
> The whole batch finishes running after about 20 hours.
>
> I'm using a hyper-threaded XP machine and the env var.
> NUMBER_OF_PROCESSORS=2.
> I'd like to dispatch the tasks in parallel to each CPU so that my
> processing time will be approx. 10hour.
>
> How can I do this in a batch file script.
>
> I know about the start command, but that does not give precise control
> over the number of running processes, and can cause hanging or 3
> processes to run in parallel. There is no option to wait.
>
> Is there some way to loop on NUMBER_OF_PROCESSORS and
> "waitMultipleThreads" until one of the tasks is done?
>
> Please advise.
> Thanks,
> Adi
>


Try this:
@echo off
set Count=0
set AppName=MyApp.exe

:NextTask
set /a Count=%Count%+1
if %Count% GTR 20 goto :eof
start /b "My Application" "c:\Program Files\My Folder\%AppName%"

:Wait
ping localhost -n 60 > nul
tasklist | find /i "%AppName%" && goto Wait
goto NextTask


 
Reply With Quote
 
Bob I
Guest
Posts: n/a
 
      30th Apr 2008
You do realize that "Hyperthreading" in testing under best conditions
only increased throughput about 20%. Now on the other hand, if you had a
dual-core CPU, you may get maybe a 70% increase. But you aren't going to
see 10 hours, so don't get your hopes up.

adish wrote:

> Hi,
>
> I need to execute many (say 20) time consuming tasks (each takes
> about 1 hour to run).
> At the moment I dispatch them serially one by one.
> According to the TaskManager the process runs on 1 CPU at 50%
> utilization.
> The whole batch finishes running after about 20 hours.
>
> I'm using a hyper-threaded XP machine and the env var.
> NUMBER_OF_PROCESSORS=2.
> I'd like to dispatch the tasks in parallel to each CPU so that my
> processing time will be approx. 10hour.
>
> How can I do this in a batch file script.
>
> I know about the start command, but that does not give precise control
> over the number of running processes, and can cause hanging or 3
> processes to run in parallel. There is no option to wait.
>
> Is there some way to loop on NUMBER_OF_PROCESSORS and
> "waitMultipleThreads" until one of the tasks is done?
>
> Please advise.
> Thanks,
> Adi
>


 
Reply With Quote
 
adish
Guest
Posts: n/a
 
      30th Apr 2008
Well, a lot of the time is spent waiting for I/O (from the HDD), so
hopefully, I will see some speedup.
My 10 hour example, was just for brevity.
Also, I want this script to execute of multi-core machines too, where,
as you, I will see much more effect.
Thanks for the prompt reply,
Adi
 
Reply With Quote
 
adish
Guest
Posts: n/a
 
      30th Apr 2008
Hi,

Thanks for the prompt reply.
A few questions though:
1. tasklist returns "ERROR: The RPC server is unavailable." on my XP
machine. Is there some some service I need to start?
2. You are using ping as a "sleep" timer, right? Isn't there some
nicer way?
3. I don't see how the script takes into account the number of
processors. It seems that it will just spawn a process and when that's
finished it will call the next task. I could do that if I didn't use
start. Am I missing something?

Thanks,
Adi
 
Reply With Quote
 
Bob I
Guest
Posts: n/a
 
      30th Apr 2008
If the HD is the bottleneck, you won't see any improvement at all.

adish wrote:

> Well, a lot of the time is spent waiting for I/O (from the HDD), so
> hopefully, I will see some speedup.
> My 10 hour example, was just for brevity.
> Also, I want this script to execute of multi-core machines too, where,
> as you, I will see much more effect.
> Thanks for the prompt reply,
> Adi


 
Reply With Quote
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      30th Apr 2008
See below.

"adish" <(E-Mail Removed)> wrote in message
news:1623e0fb-ae94-4caa-9bde-(E-Mail Removed)...
> Hi,
>
> Thanks for the prompt reply.
> A few questions though:
> 1. tasklist returns "ERROR: The RPC server is unavailable." on my XP
> machine. Is there some some service I need to start?


*** I suggest you google for the string "The RPC server is unavailable"
*** to find out if this is of concern.

> 2. You are using ping as a "sleep" timer, right? Isn't there some
> nicer way?


*** Why is ping not nice? It's native and it consumes few CPU
*** resources and it works on all Windows platforms. If you
*** don't like it then you can use one of the many sleep utilities.
*** There is even one in WinXP!

> 3. I don't see how the script takes into account the number of
> processors. It seems that it will just spawn a process and when that's
> finished it will call the next task. I could do that if I didn't use
> start. Am I missing something?


*** It doesn't, and I don't know of any way to do it.

> Thanks,
> Adi



 
Reply With Quote
 
adish
Guest
Posts: n/a
 
      1st May 2008
Thanks.
I'll give it a shot.
Adi
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A script/batch to kill a batch file from scheduled tasks? Bogdan Windows XP Configuration 1 31st Jul 2009 06:05 AM
How do I specialize CPU cores for certain categories of tasks? Sam Windows Vista Performance 1 13th Aug 2008 08:48 PM
calling multiple batch files from within a batch file yawnmoth Windows XP General 3 26th May 2008 06:47 PM
Batch file will not run via Scheduled Tasks David C Microsoft Windows 2000 3 8th Dec 2003 11:18 PM
Batch File in Scheduled Tasks - michael Microsoft Windows 2000 CMD Promt 3 27th Aug 2003 01:22 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:03 PM.