Browse Source

borked array swapper test

Fortune for day3's current commit: Small curse − 小凶
master
Avril 6 months ago
parent
commit
018fa4b8c6
Signed by: flanchan
GPG Key ID: 284488987C31F630
  1. 2
      day2/Makefile
  2. 4
      day2/src/p1.c
  3. 15
      day3/Makefile
  4. 0
      day3/cmkinput.c
  5. 0
      day3/include/raw_input.hh
  6. 23
      day3/mkinput
  7. 20
      day3/mkinput-old

2
day2/Makefile

@ -14,7 +14,7 @@ INPUT_DEST=src/input.c
COMMON_FLAGS+= -W -Wall -fno-strict-aliasing $(addprefix -I,$(INCLUDE))
COMMON_FLAGS+=-msse -msse2 -msse3
COMMON_FLAGS+=-D_PART1 -D_PART2
COMMON_FLAGS+=-D_PART1 -D__PART2
OPT_FLAGS?= -march=native -fgraphite -fopenmp -floop-parallelize-all -ftree-parallelize-loops=4 \
-floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block \

4
day2/src/p1.c

@ -7,7 +7,7 @@
#include <result.h>
#define RIMAX_STR (64 - sizeof(size_t))
#define RIMAX_STR (sizeof(size_t))
struct proc {
union {
@ -16,7 +16,7 @@ struct proc {
off_t field;
};
struct {
//TODO: part2 shit
//TODO: part2 shit
} aimed;
};
};

15
day3/Makefile

@ -1,6 +1,6 @@
# aoc2021-day2
PROJECT=day2
PROJECT=day3
AUTHOR=Avril (Flanchan) <flanchan@cumallover.me>
SRC_C = $(wildcard src/*.c)
@ -9,12 +9,13 @@ SRC_CXX = $(wildcard src/*.cpp)
INCLUDE=include
INPUT_SOURCE?=input
INPUT_DEST=include/raw_input.hh
INPUT_DEST=src/input.c
COMMON_FLAGS+= -W -Wall -fno-strict-aliasing $(addprefix -I,$(INCLUDE))
COMMON_FLAGS+=-msse -msse2 -msse3
COMMON_FLAGS+=-D_PART1 -D__PART2
COMMON_FLAGS+=-D_PART1
# -D_PART2
OPT_FLAGS?= -march=native -fgraphite -fopenmp -floop-parallelize-all -ftree-parallelize-loops=4 \
-floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block \
@ -55,6 +56,9 @@ OBJ = $(OBJ_C) $(OBJ_CXX)
# Phonies
.PHONY: input
input: $(INPUT_DEST)
.PHONY: release
release: | dirs $(INPUT_DEST)
$(MAKE) $(PROJECT)-release
@ -68,7 +72,10 @@ debug: | dirs $(INPUT_DEST)
dirs:
@mkdir -p obj/c{,xx}/src
$(INPUT_DEST): $(INPUT_SOURCE)
cmkinput: cmkinput.c
$(CC) $^ $(CFLAGS) -fwhole-program -o $@
$(INPUT_DEST): $(INPUT_SOURCE) cmkinput
./mkinput $< > $@
obj/c/%.o: %.c

0
day3/mkinput.c → day3/cmkinput.c

0
day3/include/raw_input.hh

23
day3/mkinput

@ -0,0 +1,23 @@
#!/bin/bash
INPUT=${1:-input}
INPUT_PROC=.input-proc-$(uuidgen)
WIDTH=$(head -n 1 "$INPUT" | wc -c)
./cmkinput $INPUT > $INPUT_PROC || exit 1
echo "#include <input.h>"
echo ""
echo "const rawinput_t RAW_INPUT[] = {"
while IFS= read -r line; do
printf '0b'
echo "$line," | sed 's/.\{8\}/& 0b/g'
done < $INPUT_PROC
unset line
echo "};"
echo "const size_t INPUT_WIDTH = $WIDTH;"
echo "const size_t RAW_INPUT_SIZE = sizeof(RAW_INPUT) / sizeof(rawinput_t);"
rm -f $INPUT_PROC

20
day3/mkinput-old

@ -1,20 +0,0 @@
#!/bin/bash
echo "#pragma once"
echo ""
INPUT=${1:-input}
COLS=$(head -n 1 "$INPUT" | wc -c)
echo "namespace input {"
echo " constexpr const auto COLS = $COLS;"
echo " constexpr const char DATA[][COLS] = {"
while IFS= read -r line; do
echo " \"$line\","
done < $INPUT
unset line
echo " };"
echo " constexpr const auto ROWS = sizeof(DATA)/sizeof(DATA[0]);"
echo "}"
Loading…
Cancel
Save