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
 
"Bob Silverman"
Nov 2003
North of Boston

2·3,779 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

23·3·23 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

22·5·7·59 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
Dartmouth NS

2×52×132 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 online now   Reply With Quote
Old 2011-02-25, 14:53   #5
ATH
Einyen
 
ATH's Avatar
 
Dec 2003
Denmark

2·3·52·23 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
 
"Bob Silverman"
Nov 2003
North of Boston

2·3,779 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
 
"Bob Silverman"
Nov 2003
North of Boston

2×3,779 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
 
"Bob Silverman"
Nov 2003
North of Boston

2×3,779 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
Near Grandkid

53×19 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

2DFB16 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
 
"Bob Silverman"
Nov 2003
North of Boston

2·3,779 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 14:43.


Thu Jun 8 14:43:57 UTC 2023 up 294 days, 12:12, 0 users, load averages: 0.82, 0.97, 1.13

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, 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.

โ‰  ยฑ โˆ“ รท ร— ยท โˆ’ โˆš โ€ฐ โŠ— โŠ• โŠ– โŠ˜ โŠ™ โ‰ค โ‰ฅ โ‰ฆ โ‰ง โ‰จ โ‰ฉ โ‰บ โ‰ป โ‰ผ โ‰ฝ โŠ โА โŠ‘ โŠ’ ยฒ ยณ ยฐ
โˆ  โˆŸ ยฐ โ‰… ~ โ€– โŸ‚ โซ›
โ‰ก โ‰œ โ‰ˆ โˆ โˆž โ‰ช โ‰ซ โŒŠโŒ‹ โŒˆโŒ‰ โˆ˜ โˆ โˆ โˆ‘ โˆง โˆจ โˆฉ โˆช โจ€ โŠ• โŠ— ๐–• ๐–– ๐–— โŠฒ โŠณ
โˆ… โˆ– โˆ โ†ฆ โ†ฃ โˆฉ โˆช โІ โŠ‚ โŠ„ โŠŠ โЇ โŠƒ โŠ… โŠ‹ โŠ– โˆˆ โˆ‰ โˆ‹ โˆŒ โ„• โ„ค โ„š โ„ โ„‚ โ„ต โ„ถ โ„ท โ„ธ ๐“Ÿ
ยฌ โˆจ โˆง โŠ• โ†’ โ† โ‡’ โ‡ โ‡” โˆ€ โˆƒ โˆ„ โˆด โˆต โŠค โŠฅ โŠข โŠจ โซค โŠฃ โ€ฆ โ‹ฏ โ‹ฎ โ‹ฐ โ‹ฑ
โˆซ โˆฌ โˆญ โˆฎ โˆฏ โˆฐ โˆ‡ โˆ† ฮด โˆ‚ โ„ฑ โ„’ โ„“
๐›ข๐›ผ ๐›ฃ๐›ฝ ๐›ค๐›พ ๐›ฅ๐›ฟ ๐›ฆ๐œ€๐œ– ๐›ง๐œ ๐›จ๐œ‚ ๐›ฉ๐œƒ๐œ— ๐›ช๐œ„ ๐›ซ๐œ… ๐›ฌ๐œ† ๐›ญ๐œ‡ ๐›ฎ๐œˆ ๐›ฏ๐œ‰ ๐›ฐ๐œŠ ๐›ฑ๐œ‹ ๐›ฒ๐œŒ ๐›ด๐œŽ๐œ ๐›ต๐œ ๐›ถ๐œ ๐›ท๐œ™๐œ‘ ๐›ธ๐œ’ ๐›น๐œ“ ๐›บ๐œ”