Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Changelog-mfakto.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ other changes:
- requested by James Heinrich: results are no longer saved to deprecated
results.txt by default (thanks to NStorm)
- please use results.json.txt for submissions
- set LegacyResultsTxt=1 in mfaktc.ini to restore old behavior and re-enable
- set LegacyResultsTxt=1 in mfakto.ini to restore old behavior and re-enable
logging to results.txt
- merged in James Heinrich's changes to mfaktc.ini and re-organized mfakto.ini
to be more user-friendly
Expand Down
3 changes: 2 additions & 1 deletion src/mfaktc.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ along with mfaktc (mfakto). If not, see <http://www.gnu.org/licenses/>.
#include "compatibility.h"
#include "sieve.h"
#include "read_config.h"
#include "params.h"
#include "parse.h"
#include "timer.h"
#include "checkpoint.h"
Expand Down Expand Up @@ -1132,7 +1133,7 @@ int main(int argc, char **argv)
mystuff.gpu_sieve_size = GPU_SIEVE_SIZE_DEFAULT * 1024 * 1024;
/* Default to 16 Kib processed by each block in a Barrett kernel. */
mystuff.gpu_sieve_processing_size = GPU_SIEVE_PROCESS_SIZE_DEFAULT * 1024;
strcpy(mystuff.inifile, "mfakto.ini");
strcpy(mystuff.inifile, CFG_FILE);
mystuff.force_rebuild = 0;


Expand Down
7 changes: 4 additions & 3 deletions src/myfnmatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,11 @@ static int match_bracket(const char *p, int k, int kfold)
wchar_t wc2;
int l = mbtowc(&wc2, p+1, 4);
if (l < 0) return 0;
if (wc <= wc2)
if ((unsigned)k-wc <= wc2-wc ||
(unsigned)kfold-wc <= wc2-wc)
if (wc <= wc2) {
unsigned int wc_temp = wc2 - wc;
if ((unsigned)k - wc <= wc_temp || (unsigned)kfold - wc <= wc_temp)
return !inv;
}
p += l-1;
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions src/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ void print_help(char *string)
printf(" -v <n> verbosity level: terse = 0, default = 1, more = 2,\n");
printf(" maximum = 3\n");
printf(" -tf <exp> <min> <max> trial factor M<exp> from <min> to <max> bits, ignores\n");
printf(" worktodo file\n");
printf(" -i | --inifile <file> load a specific INI file (default: mfakto.ini)\n");
printf(" %s file\n", WORKTODO_FILE);
printf(" -i | --inifile <file> load a specific INI file (default: %s)\n", CFG_FILE);
printf(" -st self-test using the optimal kernel for each test case\n");
printf(" -st2 self-test using all possible kernels\n");
printf("\n");
Expand Down
29 changes: 17 additions & 12 deletions src/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ from 2^66 to 2^67. The OpenCL version, mfakto, requires MORE_CLASSES be defined.
#define MORE_CLASSES



/*
THREADS_PER_BLOCK is not needed for OpenCL - it dynamically uses the device's maximum
All GPU-sieve kernels also have 256 threads per block.
Expand All @@ -139,7 +138,6 @@ All GPU-sieve kernels also have 256 threads per block.
//#define THREADS_PER_BLOCK 256



/*
SIEVE_PRIMES defines how far we sieve the factor candidates.
The first <SIEVE_PRIMES> odd primes are sieved.
Expand Down Expand Up @@ -213,7 +211,7 @@ Larger values may lead to less wasted cycles by reducing the number of times all
are not TFing a candidate. However, more shared memory is used which may reduce occupancy.
Smaller values should lead to a more responsive system (each kernel takes less time to execute).

The actual configuration is done in mfaktc.ini.
The actual configuration is done in mfakto.ini.
The following lines define the min, default and max value.
*/

Expand All @@ -229,15 +227,22 @@ The following lines define the min, default and max value.
#define GPU_SIEVE_PROCESS_SIZE_DEFAULT 16 /* Default is processing 16K bits */
#define GPU_SIEVE_PROCESS_SIZE_MAX 32 /* Upper limit is 64K, since we store k values as "short". Shared memory requirements limit usable values */

/* For worktodo.txt files */
#define MAX_LINE_LENGTH 100
/* settings related to worktodo.txt file */
#define WORKTODO_FILE "worktodo.txt"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest leaving a comment here, that WORKTODO_FILE string length shouldn't exceed 50 characters (as per my_types.h)

Same for the other string constants for file names below.

#define MAX_LINE_LENGTH 100

#define MAX_FACTORS_PER_JOB 20
#define MAX_DEZ_96_STRING_LENGTH 30 // max value of int96 (unsigned) has 29 digits + 1 byte for NUL

#define MAX_FACTORS_PER_JOB 20
#define MAX_DEZ_96_STRING_LENGTH 30 // max value of int96 (unsigned) has 29 digits + 1 byte for NUL
#define MAX_FACTOR_BUFFER_LENGTH MAX_FACTORS_PER_JOB * MAX_DEZ_96_STRING_LENGTH
#define MAX_BUFFER_LENGTH MAX_FACTOR_BUFFER_LENGTH + 100

#define MAX_FACTOR_BUFFER_LENGTH MAX_FACTORS_PER_JOB * MAX_DEZ_96_STRING_LENGTH
#define MAX_BUFFER_LENGTH MAX_FACTOR_BUFFER_LENGTH + 100
/* other files */
#define CFG_FILE "mfakto.ini"
#define RESULTS_FILE "results.txt"
#define RESULTS_JSON_FILE "results.json.txt"

#define GHZDAYS_MAGIC_TF_TOP 0.016968 // magic constant for TF to 65 bits and above
#define GHZDAYS_MAGIC_TF_MID 0.017832 // magic constant for 63 and 64 bits
#define GHZDAYS_MAGIC_TF_BOT 0.011160 // magic constant for 62 bits and below
/* for GHz-day calculations */
#define GHZDAYS_MAGIC_TF_TOP 0.016968 // magic constant for TF to 65 bits and above
#define GHZDAYS_MAGIC_TF_MID 0.017832 // magic constant for 63 and 64 bits
#define GHZDAYS_MAGIC_TF_BOT 0.011160 // magic constant for 62 bits and below
6 changes: 3 additions & 3 deletions src/read_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ int read_config(mystuff_t *mystuff)

if(my_read_string(mystuff->inifile, "WorkFile", mystuff->workfile, 50))
{
sprintf(mystuff->workfile, "worktodo.txt");
sprintf(mystuff->workfile, WORKTODO_FILE);
logprintf(mystuff, "Warning: Cannot read WorkFile from INI file, using default (%s)\n", mystuff->workfile);
}
if(mystuff->verbosity >= 1)logprintf(mystuff, " WorkFile %s\n", mystuff->workfile);
Expand All @@ -506,7 +506,7 @@ int read_config(mystuff_t *mystuff)

if(my_read_string(mystuff->inifile, "ResultsFile", mystuff->resultfile, 50))
{
sprintf(mystuff->resultfile, "results.txt");
sprintf(mystuff->resultfile, RESULTS_FILE);
logprintf(mystuff, "Warning: Cannot read ResultsFile from INI file, using default (%s)\n", mystuff->resultfile);
}
if(mystuff->verbosity >= 1)logprintf(mystuff, " ResultsFile %s\n", mystuff->resultfile);
Expand All @@ -515,7 +515,7 @@ int read_config(mystuff_t *mystuff)

if (my_read_string(mystuff->inifile, "JSONResultsFile", mystuff->jsonresultfile, 50))
{
sprintf(mystuff->jsonresultfile, "results.json.txt");
sprintf(mystuff->jsonresultfile, RESULTS_JSON_FILE);
logprintf(mystuff, "Warning: Cannot read JSONResultsFile from INI file, using default (%s)\n", mystuff->jsonresultfile);
}
if (mystuff->verbosity >= 1)logprintf(mystuff, " JSONResultsFile %s\n", mystuff->jsonresultfile);
Expand Down