mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   Information & Answers (https://www.mersenneforum.org/forumdisplay.php?f=38)
-   -   Bug in CPU "daytime" (https://www.mersenneforum.org/showthread.php?t=10967)

Jud McCranie 2008-11-13 00:04

Bug in CPU "daytime"
 
There seems to be a bug in the CPU "daytime" hours. I wanted daytime to go from 10:30 am to 1:30 am - the hours when I may be working. If the second time is after midnight the program swaps the start and end times.

cheesehead 2008-11-13 00:43

[quote=Jud McCranie;149055]There seems to be a bug in the CPU "daytime" hours. I wanted daytime to go from 10:30 am to 1:30 am - the hours when I may be working. If the second time is after midnight the program swaps the start and end times.[/quote]In source module commonc.c, there's:

[code] if (day_start_time > day_end_time) {
temp = day_memory; day_memory = night_memory; night_memory = temp;
temp = day_start_time; day_start_time = day_end_time; day_end_time = temp;
[/code]... which swaps the day/night memory and day start/end time values in your case.

So, you can either:

1. Leave your day start/end times as 10:30 am and 1:30 am, but switch your memory specifications so that the "daytime memory" is actually what you want as your night memory, and vice versa,

or

2. Leave your memory figures alone and swap your day start/end times.

In either case, prime95 will then use your desired daytime memory allocation from 10:30 am until 1:30 am the following day, and your desired nighttime memory allocation from 1:30 am until 10:30 am the same day.

Jud McCranie 2008-11-13 00:47

[quote=cheesehead;149058]I'm fairly sure you can workaround this by (1) specifying daytime to start at 1:30 am and end at 10:30 am, then (2) put your desired nighttime setting in the daytime field, and your desired daytime setting in the nighttime field.

(I'll look through the source code and come back with an update if necessary.)[/quote]

Yes, that makes sense.

Jud McCranie 2008-11-13 00:50

Of course, it would be better for Prime95 to point that out and ask if you want to swap the times. Quite a few people are up after midnight.

Prime95 2008-11-13 08:43

[QUOTE=Jud McCranie;149055]There seems to be a bug in the CPU "daytime" hours. I wanted daytime to go from 10:30 am to 1:30 am - the hours when I may be working. If the second time is after midnight the program swaps the start and end times.[/QUOTE]

I presume you wanted a 15 hour daytime period. If the code did not do that, then I need to fix it. I'll look at it when I get back from vacation.

Mini-Geek 2008-11-13 12:02

[quote=Prime95;149088]I presume you wanted a 15 hour daytime period. If the code did not do that, then I need to fix it. I'll look at it when I get back from vacation.[/quote]
[quote=cheesehead;149058]In source module commonc.c, there's:

[code] if (day_start_time > day_end_time) {
temp = day_memory; day_memory = night_memory; night_memory = temp;
temp = day_start_time; day_start_time = day_end_time; day_end_time = temp;
[/code][/quote]I'd guess it was coded like that assuming people would accidentally put the two values in the wrong spot and so it swaps them, but apparently that means you can't set the night time values to happen past midnight. Did it used to be like this? I don't think so...I recall having night set to 10 pm to 6 am and it seemed to respect the values correctly.

Prime95 2008-11-13 14:53

[QUOTE=Mini-Geek;149107]Did it used to be like this? I don't think so....[/QUOTE]

I'll have to check out the source control system when I return from vacation.

Jud McCranie 2008-11-13 15:58

[quote=Mini-Geek;149107]I'd guess it was coded like that assuming people would accidentally put the two values in the wrong spot and so it swaps them, but apparently that means you can't set the night time values to happen past midnight. Did it used to be like this? I don't think so...I recall having night set to 10 pm to 6 am and it seemed to respect the values correctly.[/quote]

I don't know if it used to be like that or not. Just after I upgraded to version 25 I went through the options and I noticed that the 10:30am (daytime start) and 1:30am (daytime end) were backwards. I thought "why did I put it in that way?" After I changed them I noticed that the program automatically reversed them.

cheesehead 2008-11-13 19:59

[quote=cheesehead;149058]In source module commonc.c[/quote]... version 25.7, I should have specified.

In version 24.13, module commonc.c does not have such code, but commonb.c has:

[code]/* Return memory available now */
/* Compute the time where we must halt processing to change the */
/* amount of available memory. */
unsigned int avail_mem (void)
{
time_t t;
struct tm *x;
unsigned int curtime;
/* Set flag indicating we are using a lot of memory */
HIGH_MEMORY_USAGE = TRUE;
/* If the same memory is available both day and night, then return */
/* that value and note that we won't have to stop in the future. */
if (DAY_MEMORY == NIGHT_MEMORY) {
STOP_TIME = 0;
return (DAY_MEMORY);
}
/* Determine whether it is daytime or nighttime. */
/* Return corresponding available memory. */
/* Set timer for when daytime or nighttime ends. */
time (&t);
x = localtime (&t);
curtime = x->tm_hour * 60 + x->tm_min;
if (DAY_START_TIME < DAY_END_TIME) {
if (curtime < DAY_START_TIME) {
STOP_TIME = t + (DAY_START_TIME - curtime) * 60;
return (NIGHT_MEMORY);
} else if (curtime < DAY_END_TIME) {
STOP_TIME = t + (DAY_END_TIME - curtime) * 60;
return (DAY_MEMORY);
} else {
STOP_TIME = t + (DAY_START_TIME + 1440 - curtime) * 60;
return (NIGHT_MEMORY);
}
} else {
if (curtime < DAY_END_TIME) {
STOP_TIME = t + (DAY_END_TIME - curtime) * 60;
return (DAY_MEMORY);
} else if (curtime < DAY_START_TIME) {
STOP_TIME = t + (DAY_START_TIME - curtime) * 60;
return (NIGHT_MEMORY);
} else {
STOP_TIME = t + (DAY_END_TIME + 1440 - curtime) * 60;
return (DAY_MEMORY);
}
}
}
[/code](Did that have the same practical effect? When I try to figure it out in my head without writing down, there's a spinning sensation ... I'll go for a walk. :-)

Mini-Geek 2008-11-13 21:16

day start = 11:00 am
day end = 10:00 am
current time = 10:30 am
[code]
if (11:00 < 10:00) {
//false
} else {
if (10:30 < 10) {
//false
} else if (10:30 < 11:00) {
//true
STOP_TIME = t + (11:00 - 10:30) * 60;
return (NIGHT_MEMORY);
}[/code]I don't think it's the same. Looks like if you have the day start after the day end and the current time is between the two (in this case, 11 am, 10 am, 10:30 am respectively. Using the example of the OP's times, we could say 10:30 am, 1:30 am, and 6 am respectively, which would be expected to be night), it returns the night memory like it's supposed to.

cheesehead 2008-11-13 22:19

A little walk can do wonders for clearing ones mind. :smile:

[quote=Mini-Geek;149175]day start = 11:00 am
day end = 10:00 am
current time = 10:30 am
[code]
if (11:00 < 10:00) {
//false
} else {
if (10:30 < 10) {
//false
} else if (10:30 < 11:00) {
//true
STOP_TIME = t + (11:00 - 10:30) * 60;
return (NIGHT_MEMORY);
}[/code]I don't think it's the same.[/quote]Doesn't your example show that at 10:30 am, the night setting is used by v24?

That's the same as v25 does. After exchanging day start and end times, it exchanges day and night memory allocations. Thus, at 10:30 am, v25 will consider it to be "day"time, and so will then use the memory allocation that the user originally specified for night, which had been exchanged into the "day" allocation slot.

[quote]Looks like if you have the day start after the day end and the current time is between the two (in this case, 11 am, 10 am, 10:30 am respectively.[/quote]Right -- so in v24 it will at that time (10:30 am) use the "night"time memory allocation. So would v25, but accomplished via different means.

[quote]Using the example of the OP's times, we could say 10:30 am, 1:30 am, and 6 am respectively, which would be expected to be night), it returns the night memory like it's supposed to.[/quote]Correct, in either v24 or v25.

- - -

To anyone still confused: Take a little walk; draw a couple of deep breaths; return.


All times are UTC. The time now is 21:56.

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