mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   No Prime Left Behind (https://www.mersenneforum.org/forumdisplay.php?f=82)
-   -   LLRnet enhancements (https://www.mersenneforum.org/showthread.php?t=10066)

kar_bon 2008-03-09 19:51

LLRnet enhancements
 
i looked around the LLRnet sources (*.lua files) and wonder if there is a way to print the date/time in the lresults-file like on the LLRnet-server results.
and i found a way!
it's not the best way but it works fine!

insert the following lines (in red) in the "llrnet.lua" in the function Work() (little above the end of the function, around line 229):
[code]
(...)
else
ClearWorkfile()
end

[color=red] local file = openfile("lresults.txt", "a")
write(file, format("[%s] ", date("%c")))
closefile(file)[/color]

if not asynchronous then
SendAllResults((sendRetries or 0) + 1)
end

SendStructureToAllGUIs("tosend", tosend, 1)
(...)
[/code]

the output in the "lresults.txt" without these lines:

[code]
329*2^387216-1 is not prime. Res64: 471878A4A7F58281 Time : 160.390 sec.
Result 329/387216 succesfully sent to the server.
[/code]

and with these lines:

[code]
329*2^387216-1 is not prime. Res64: 471878A4A7F58281 Time : 160.390 sec.
[03/09/08 20:37:46] Result 329/387216 succesfully sent to the server.
[/code]

please make copies of "llrnet.lua" and "lresults.txt" before changes and stop the client.

the time in the result-file and on the client console differ by 2 seconds (result-file minus 2 seconds from console)!

if there're any issues please post them here!

karsten

kar_bon 2008-03-26 00:45

here is another enhancement for LLRnet:

insert the following red lines into 'llrnet.lua' (around line# 187, function 'Work()') and all found primes will be written in a seperate file called 'primes.txt':

[code]
(...)
-- check user interruption
if stopCheck() then
return -- return with no error
end
end
[color=red]
if result == 0 then
local file = openfile("primes.txt", "a")
write(file, format("%s %s\n", k, n))
closefile(file)
end
[/color]
SemaWait(semaphore)

-- add the result in tosend table and file
local tbl = { t = t, k = k, n = n,
(...)
[/code]

the primes in this file are formatted as one prime per line with 'k n' values.

karsten

IronBits 2008-03-26 01:09

I have used that and it works fine listing out just the primes.
I'd like it to report the user that found it and the date to.
Anyway to make it do all that?

mdettweiler 2008-03-26 03:07

[quote=IronBits;129753]I have used that and it works fine listing out just the primes.
I'd like it to report the user that found it and the date to.
Anyway to make it do all that?[/quote]
I think Karsten's modification is for the client, not the server, right?

IronBits 2008-03-26 03:28

This is what I use on the Server.
[code]
function OnPrime(t, k, n, job)
local fileprime = openfile("primes.txt", "a")
if fileprime then
write(fileprime, format("[%s]\n", job.resultdate))
write(fileprime, format(displayFormat.." is prime! Time : %d.0 sec.\n",
k, n,
Seconds() - job.seconds))
closefile(fileprime)
end
end
[/code]

mdettweiler 2008-03-26 03:34

[quote=IronBits;129764]This is what I use on the Server.
[code]
function OnPrime(t, k, n, job)
local fileprime = openfile("primes.txt", "a")
if fileprime then
write(fileprime, format("[%s]\n", job.resultdate))
write(fileprime, format(displayFormat.." is prime! Time : %d.0 sec.\n",
k, n,
Seconds() - job.seconds))
closefile(fileprime)
end
end
[/code][/quote]
Hmm. Though I don't know squat about the LUA programming language, it looks like the OnPrime function isn't even being fed the username--so it might be technically impossible to have it output the user for each prime without actually modifying the one of the .lua files (rather than just using the built in OnPrime function thing in the llr-serverconfig.txt file).

AES 2008-03-26 14:42

Isn't "job" the array from the joblist file?

You could just add:
[code]
write(fileprime, format("user=%s\n", job.user))
[/code]Function OnPrime:
[code]
function OnPrime(t, k, n, job)
local fileprime = openfile("primes.txt", "a")
if fileprime then
write(fileprime, format("user=%s\n", job.user))
write(fileprime, format("[%s]\n", job.resultdate))
write(fileprime, format(displayFormat.." is prime! Time : %d.0 sec.\n",
k, n,
Seconds() - job.seconds))
closefile(fileprime)
end
end
[/code]

mdettweiler 2008-03-26 15:00

[quote=AES;129804]Isn't "job" the array from the joblist file?

You could just add:
[code]
write(fileprime, format("user=%s\n", job.user))
[/code]Function OnPrime:
[code]
function OnPrime(t, k, n, job)
local fileprime = openfile("primes.txt", "a")
if fileprime then
write(fileprime, format("user=%s\n", job.user))
write(fileprime, format("[%s]\n", job.resultdate))
write(fileprime, format(displayFormat.." is prime! Time : %d.0 sec.\n",
k, n,
Seconds() - job.seconds))
closefile(fileprime)
end
end
[/code][/quote]
Ah, I see, I didn't notice that job was an array. Looked like a scalar to me. (since LUA, unlike most other programming languages, doesn't have an easy way to distinguish between scalars and arrays at a glance). :smile:

kar_bon 2008-03-26 23:00

to print all found primes in a seperate file (like Adams version) you can edit 'llrserver.lua' too.
the function 'WriteResultToFile' does such a thing (line 108):

[code]
function WriteResultToFile(job, filename)
-- write result into lresults file
local file = openfile(filename, "a")
if file then
write(file, format("user=%s\n", job.user))
write(file, format("[%s]\n", job.resultdate))
if job.result ~= "0" then
write(file, format(displayFormat.." is not prime. Res64: %s Time : %d.0 sec.\n",
job.k, job.n, job.result,
Seconds() - job.seconds))
else
write(file, format(displayFormat.." is prime! Time : %d.0 sec.\n",
job.k, job.n,
Seconds() - job.seconds))
[color=red]
local fileprime = openfile("primes.txt", "a")
if fileprime then
write(fileprime, format("%s %s %s\n", job.k, job.n, job.user))
closefile(fileprime)
end
[/color]

end
closefile(file)
end
end
[/code]

i couldn't check this if it works. try it.

karsten

IronBits 2008-03-27 01:58

Thanks, I'll give it a try. :smile:

kar_bon 2008-03-28 11:21

small edit ti post #2
 
in post #2 i gave the hint to create a seperate file for found primes (the client version).

for llrnet users like me with several folders of llrnet-ports/servers (i use a Quad so i got four folders for each of the two servers now) here is another hint:
my folders looks like this:
[code]
[LLRnet_A300_1]
[LLRnet_A300_2]
[LLRnet_A300_3]
[LLRnet_A300_4]
[LLRnet_I5000_1]
[LLRnet_I5000_2]
[LLRnet_I5000_3]
[LLRnet_I5000_4]
prim.bat
tests.bat
[/code]

where [...] are the folders (A-> AES server, I->IronBits server) and the two batches to show me number of done tests and found primes.

now, edit one line from post #2:
[code][color=red]
local file = openfile("..\\primes.txt", "a")
[/color][/code]

and the file 'primes.txt' will be generated not in the LLRnet-folder but in the folder above.
so every found prime from every server/port will be written there.
another point: if any prime is found the file exists. after checking you can delete this file and go on.

-> [PseudoCode on]
[code]
if exists(primes.txt)
ALARM("prime found!")
endif
[/code]

:grin:
karsten


All times are UTC. The time now is 06:37.

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