Compare commits
2 Commits
3ef2e95c69
...
384257825b
Author | SHA1 | Date |
---|---|---|
Miguel M | 384257825b | |
Miguel M | 10451dcde9 |
14
make.py
14
make.py
|
@ -17,7 +17,8 @@ COMPILE_FLAGS = [
|
|||
"-pedantic-errors",
|
||||
"-fopenmp",
|
||||
]
|
||||
LINK_FLAGS = []
|
||||
LINK_FLAGS = ["-fopenmp"]
|
||||
LIBRARIES = ["-lm"]
|
||||
OBJ_DIR = os.path.join("obj", "release" if ("RELEASE" in os.environ) else "debug")
|
||||
SRC_DIR = "src"
|
||||
EXE_NAME = "main." + ("release" if ("RELEASE" in os.environ) else "debug") + ".exe"
|
||||
|
@ -28,11 +29,12 @@ if "RELEASE" in os.environ:
|
|||
COMPILE_FLAGS[COMPILE_FLAGS.index("-O0")] = "-O2"
|
||||
COMPILE_FLAGS[COMPILE_FLAGS.index("-g3")] = "-g"
|
||||
COMPILE_FLAGS.append("-DRELEASE")
|
||||
COMPILE_FLAGS.append("-g")
|
||||
LINK_FLAGS.append("-DRELEASE")
|
||||
else:
|
||||
COMPILE_FLAGS.append("-fsanitize=address,undefined")
|
||||
LINK_FLAGS.append("-fsanitize=address,undefined")
|
||||
|
||||
if "COMPILE_FLAGS" in os.environ:
|
||||
COMPILE_FLAGS.extend(os.environ["COMPILE_FLAGS"].split(";"))
|
||||
if "LINK_FLAGS" in os.environ:
|
||||
LINK_FLAGS.extend(os.environ["LINK_FLAGS"].split(";"))
|
||||
|
||||
|
||||
def as_object(source_path):
|
||||
|
@ -88,7 +90,7 @@ def link():
|
|||
obj_files = glob(
|
||||
os.path.join(OBJ_DIR, "**", "*.obj").replace("\\", "/"), recursive=True
|
||||
)
|
||||
sp.run([COMPILER, *LINK_FLAGS, "-o", EXE_NAME, *obj_files])
|
||||
sp.run([COMPILER, *LINK_FLAGS, "-o", EXE_NAME, *obj_files, *LIBRARIES])
|
||||
|
||||
|
||||
@recipe(info="Removes all compiled objects.")
|
||||
|
|
26
src/main.c
26
src/main.c
|
@ -1,4 +1,5 @@
|
|||
#include <alloca.h>
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -26,10 +27,13 @@ static void ReportProgress(uintmax_t current, uintmax_t total, clock_t now) {
|
|||
if (current >= _timing_last_count) {
|
||||
float inferred_rate = (float)(current - _timing_last_count) /
|
||||
((float)(now - _timing_last_time) / CLOCKS_PER_SEC);
|
||||
_timing_rate = _timing_rate * (1. - _timing_exp_backoff) +
|
||||
inferred_rate * _timing_exp_backoff;
|
||||
if (_timing_exp_backoff > 0.0001) {
|
||||
_timing_exp_backoff *= 0.99;
|
||||
if (inferred_rate < _timing_rate) {
|
||||
_timing_rate = inferred_rate;
|
||||
_timing_exp_backoff = 0.3;
|
||||
} else {
|
||||
_timing_rate = _timing_rate * (1. - _timing_exp_backoff) +
|
||||
inferred_rate * _timing_exp_backoff;
|
||||
_timing_exp_backoff = fmax(0.99 * _timing_exp_backoff, 0.001);
|
||||
}
|
||||
_timing_last_count = current;
|
||||
_timing_last_time = now;
|
||||
|
@ -256,8 +260,14 @@ int main(int argc, char *argv[]) {
|
|||
PermutationReset(b_out_perms + i);
|
||||
}
|
||||
|
||||
#pragma omp for schedule(guided)
|
||||
#pragma omp for schedule(dynamic)
|
||||
for (size_t lhs_i = 0; lhs_i < row_count - 1; lhs_i++) {
|
||||
{
|
||||
clock_t now = clock();
|
||||
uintmax_t tested_now = tested;
|
||||
ReportProgress(tested_now, total, now);
|
||||
}
|
||||
|
||||
if (seen[lhs_i]) {
|
||||
const uintmax_t remaining = (uintmax_t)row_count * perm_iterations;
|
||||
#pragma omp atomic update
|
||||
|
@ -351,12 +361,6 @@ int main(int argc, char *argv[]) {
|
|||
skip_permutations:;
|
||||
#pragma omp atomic update
|
||||
tested += perm_iterations;
|
||||
{
|
||||
clock_t now = clock();
|
||||
#pragma omp task default(none) shared(tested, total) firstprivate(now)
|
||||
ReportProgress(tested, total, now);
|
||||
}
|
||||
|
||||
} // For loop over rhs_i
|
||||
} // For loop over lhs_i
|
||||
|
||||
|
|
Loading…
Reference in New Issue