mersenneforum.org  

Go Back   mersenneforum.org > Extra Stuff > Programming

Reply
 
Thread Tools
Old 2011-02-25, 13:58   #1
R.D. Silverman
 
R.D. Silverman's Avatar
 
Nov 2003

22·5·373 Posts
Default Processor Affinity

I am setting up to run ECM in a distributed environment.

I am creating a parent process that gets the hostname, creates
checkpoint and output file names from the hostname, then makes
a call to system() with an appropriately constructed command string
to invoke GMP-ECM.

I would also like to have separate output files for each core when
running on a multi-core system. Otherwise, if I name e.g.
my output files as "hostname.chk" I will get collisions.

Does anyone know of a Windows
system call that will return the processor ID during run-time?
I could then incorporate the processor ID in the output file names.

I tried Google, of course, but can't seem to find/use the right
keywords.
R.D. Silverman is offline   Reply With Quote
Old 2011-02-25, 14:20   #2
WraithX
 
WraithX's Avatar
 
Mar 2006

11×43 Posts
Default

Why not use your "parent process" to pick a unique id and then append that to the chk file?

You could use uid's like {1,2,3,4} and give the checkfile name to gmp-ecm like -chkpnt hostname-1.chk, -chkpnt hostname-2.chk, etc.
WraithX is offline   Reply With Quote
Old 2011-02-25, 14:27   #3
Prime95
P90 years forever!
 
Prime95's Avatar
 
Aug 2002
Yeehaw, FL

3·5·499 Posts
Default

GetAffinityMask tells you which processors your program is allowed to run on. It does not tell you which processor you are currently assigned to. Thus it always returns -1, unless you or someone else has called SetAffinityMask.

GetSystemInfo will return the number of logical processors on the machine.
Prime95 is offline   Reply With Quote
Old 2011-02-25, 14:33   #4
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

Quote:
Originally Posted by R.D. Silverman View Post
I am setting up to run ECM in a distributed environment.

I am creating a parent process that gets the hostname, creates
checkpoint and output file names from the hostname, then makes
a call to system() with an appropriately constructed command string
to invoke GMP-ECM.

I would also like to have separate output files for each core when
running on a multi-core system. Otherwise, if I name e.g.
my output files as "hostname.chk" I will get collisions.

Does anyone know of a Windows
system call that will return the processor ID during run-time?
I could then incorporate the processor ID in the output file names.

I tried Google, of course, but can't seem to find/use the right
keywords.
I know I'm probably on your ignore list and of no major help but I have a copy of advanced MSDOS which may have something and if not I also use :
http://www.computerhope.com/msdos.htm for windows system commands but I'm not sure how in date these are. wonder if PARI can generate a list of valid commands it allows system calls.
science_man_88 is offline   Reply With Quote
Old 2011-02-25, 14:53   #5
ATH
Einyen
 
ATH's Avatar
 
Dec 2003
Denmark

C3516 Posts
Default

You can have one copy of gmp-ecm for each core. Use imagecfg.exe to setup each gmp-ecm to run on a specific core:
http://www.robpol86.com/index.php/ImageCFG

imagecfg.exe -a 0x1 ecm.exe
imagecfg.exe -a 0x2 ecm.exe
imagecfg.exe -a 0x4 ecm.exe
imagecfg.exe -a 0x8 ecm.exe

this setting remains with the ecm.exe until changed with imagecfg or until ecm.exe overwritten by a recompile.
ATH is offline   Reply With Quote
Old 2011-02-25, 18:22   #6
R.D. Silverman
 
R.D. Silverman's Avatar
 
Nov 2003

22·5·373 Posts
Default

Quote:
Originally Posted by WraithX View Post
Why not use your "parent process" to pick a unique id and then append that to the chk file?

Reasonable. If you can tell me how a process can pick a unique ID.
One has (say) two processes running. Suppose I generate a PRN based on
(say) microseconds after midnight and use it as an ID. There is no
guarantee that it will be unique. Highly probable, yes. But no guarantee.

Alternately, I could set up an external file:

ID1 flag
ID2 flag
ID3 flag

Where flag = 0 for "ID available". It then gets set to 1 when used.
However, there is no guarantee that two processes won't both read
the same line at the same time.

Quote:
You could use uid's like {1,2,3,4} and give the checkfile name to gmp-ecm like -chkpnt hostname-1.chk, -chkpnt hostname-2.chk, etc.
This is what I intend. Perhaps I might use getpid(). If this were Unix, I would. Is it available under Windows? I don't know nearly as much about
Windows system level coding as I do Unix.
R.D. Silverman is offline   Reply With Quote
Old 2011-02-25, 18:24   #7
R.D. Silverman
 
R.D. Silverman's Avatar
 
Nov 2003

22·5·373 Posts
Default

Quote:
Originally Posted by ATH View Post
You can have one copy of gmp-ecm for each core. Use imagecfg.exe to setup each gmp-ecm to run on a specific core:
http://www.robpol86.com/index.php/ImageCFG

imagecfg.exe -a 0x1 ecm.exe
imagecfg.exe -a 0x2 ecm.exe
imagecfg.exe -a 0x4 ecm.exe
imagecfg.exe -a 0x8 ecm.exe

this setting remains with the ecm.exe until changed with imagecfg or until ecm.exe overwritten by a recompile.
Very Nice! But I am not allowed to download/install code from the net
onto any office machines.
R.D. Silverman is offline   Reply With Quote
Old 2011-02-25, 18:35   #8
R.D. Silverman
 
R.D. Silverman's Avatar
 
Nov 2003

746010 Posts
Default

Quote:
Originally Posted by R.D. Silverman View Post
Reasonable. If you can tell me how a process can pick a unique ID.
One has (say) two processes running. Suppose I generate a PRN based on
(say) microseconds after midnight and use it as an ID. There is no
guarantee that it will be unique. Highly probable, yes. But no guarantee.

Alternately, I could set up an external file:

ID1 flag
ID2 flag
ID3 flag

Where flag = 0 for "ID available". It then gets set to 1 when used.
However, there is no guarantee that two processes won't both read
the same line at the same time.



This is what I intend. Perhaps I might use getpid(). If this were Unix, I would. Is it available under Windows? I don't know nearly as much about
Windows system level coding as I do Unix.
_getpid() does seem to be available under VS C++
R.D. Silverman is offline   Reply With Quote
Old 2011-02-25, 19:17   #9
wblipp
 
wblipp's Avatar
 
"William"
May 2003
New Haven

93916 Posts
Default

Quote:
Originally Posted by R.D. Silverman View Post
I am setting up to run ECM in a distributed environment.

I am creating a parent process that gets the hostname, creates
checkpoint and output file names from the hostname, then makes
a call to system() with an appropriately constructed command string
to invoke GMP-ECM.
Have you considered running an ECMNET server, with one client per core?
wblipp is offline   Reply With Quote
Old 2011-02-25, 22:00   #10
xilman
Bamboozled!
 
xilman's Avatar
 
"𒉺𒌌𒇷𒆷𒀭"
May 2003
Down not across

2·72·109 Posts
Default

Quote:
Originally Posted by wblipp View Post
Have you considered running an ECMNET server, with one client per core?
That's exactly what I do here.

Paul
xilman is offline   Reply With Quote
Old 2011-02-25, 22:53   #11
R.D. Silverman
 
R.D. Silverman's Avatar
 
Nov 2003

22·5·373 Posts
Default

Quote:
Originally Posted by xilman View Post
That's exactly what I do here.

Paul
I would have to designate a machine to be the server.

I have no way to assure that said machine will be up
at any given time. I am using public machines which are
subject to being disconnected (so others can plug in
their laptop), turned off at the whim of the last one to log in,
etc. etc. Sometimes people disconnect a machine to plug in
their laptop only to fail to restore the connection later.

The only machanism that I have for starting distributed processes
is the Windows task scheduler (equivalent to Unix cron jobs).

Availability of machines is very unreliable.

I can't use my laptop as the server since I often take it home.
R.D. Silverman is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Set affinity does not work g33py Software 3 2016-07-27 05:26
Core affinity question philmoore Information & Answers 2 2013-06-16 05:44
(windows) How to launch mfaktO/C with processor affinity swl551 Software 1 2012-09-24 23:29
Helper Thread Affinity TObject Software 3 2012-07-20 19:21
Affinity on Linux bmg9611 Software 5 2002-11-04 21:26

All times are UTC. The time now is 04:40.

Sun May 9 04:40:55 UTC 2021 up 30 days, 23:21, 0 users, load averages: 1.60, 1.30, 1.49

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.