Skip to content

Commit bd0e8c9

Browse files
Merge pull request #21 from Artoria2e5/msys2
Thanks for this PR !
2 parents 93c6062 + 7945474 commit bd0e8c9

File tree

5 files changed

+80
-20
lines changed

5 files changed

+80
-20
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,13 @@ logs/
2727
stage1_result_*.txt
2828
worktodo*.txt
2929
*.save
30+
<<<<<<< HEAD
3031
*.ckpt
32+
||||||| parent of 7a412ca (gitignore)
33+
=======
34+
/vcpkg
35+
/prmers.exe
36+
/*.zip
37+
/package
38+
/.vscode
39+
>>>>>>> 7a412ca (gitignore)

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ target_include_directories(prmers PRIVATE
2626

2727
target_compile_options(prmers PRIVATE
2828
$<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
29-
-Wall -Wextra -Wsign-conversion -ffinite-math-only -O2 -O3>
29+
-Wall -Wextra -Wsign-conversion -ffinite-math-only -O3>
3030
)
3131

3232
target_compile_definitions(prmers PRIVATE
@@ -45,6 +45,10 @@ target_link_libraries(prmers PRIVATE
4545
PkgConfig::GMPXX
4646
)
4747

48+
if (WIN32)
49+
target_link_libraries(prmers PRIVATE ws2_32)
50+
endif()
51+
4852
if (USE_CURL)
4953
target_link_libraries(prmers PRIVATE CURL::libcurl)
5054
endif()

Makefile

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,55 @@
11
PREFIX ?= /usr/local
22
TARGET := prmers
3-
KERNEL_PATH ?= $(PREFIX)/share/$(TARGET)/
43

54
SRC_DIR := src
65
INC_DIR := include
76

87
SRCS := $(shell find $(SRC_DIR) -type f -name '*.cpp')
98
OBJS := $(patsubst $(SRC_DIR)/%.cpp,$(SRC_DIR)/%.o,$(SRCS))
109

11-
CFLAGS := -Wall -Wextra -Wsign-conversion -ffinite-math-only
12-
FLAGS_CPU := -O3
13-
FLAGS_GPU := -O2 -DGPU
10+
UNAME_S := $(shell uname -s)
11+
VERSION := $(shell git describe --tags --always)
12+
PACKAGE := prmers-$(VERSION)
13+
14+
WARN := -Wall -Wextra -Wsign-conversion
15+
CPPFLAGS := -I$(INC_DIR) -I$(INC_DIR)/marin -DGPU
16+
MARCH := native
17+
OPT := -O3 -ffinite-math-only -march=$(MARCH)
1418

1519
CXX := g++
16-
CXXFLAGS := -std=c++20 -O3 -Wall -I$(INC_DIR) -march=native -flto -I$(INC_DIR)/marin $(CFLAGS) $(FLAGS_GPU) $(FLAGS_CPU)
17-
LDFLAGS := -flto
20+
CXXFLAGS := -std=c++20 $(WARN) $(OPT) -flto=auto
21+
LDFLAGS := -flto=auto
1822

19-
UNAME_S := $(shell uname -s)
23+
24+
# Mac
2025
ifeq ($(UNAME_S),Darwin)
21-
CXXFLAGS += -I/System/Library/Frameworks/OpenCL.framework/Headers
26+
CPPFLAGS += -I/System/Library/Frameworks/OpenCL.framework/Headers
2227
LDFLAGS += -framework OpenCL
2328
else
2429
LDFLAGS += -lOpenCL
2530
endif
2631

32+
# Windows
33+
ifeq ($(shell case $(UNAME_S) in (*_NT*) echo 1;; esac),1)
34+
LDFLAGS += -lWs2_32
35+
KERNEL_PATH ?= ./kernels/
36+
else
37+
KERNEL_PATH ?= $(PREFIX)/share/$(TARGET)/
38+
endif
39+
2740
LDFLAGS += -lgmpxx -lgmp
2841

2942
USE_CURL ?= 1
3043
ifeq ($(USE_CURL),1)
31-
CXXFLAGS += -DHAS_CURL=1
44+
CPPFLAGS += -DHAS_CURL=1
3245
LDFLAGS += -lcurl
3346
else
34-
CXXFLAGS += -DNO_CURL=1
47+
CPPFLAGS += -DNO_CURL=1
3548
endif
3649

37-
CPPFLAGS := -DKERNEL_PATH=\"$(KERNEL_PATH)\"
50+
CPPFLAGS += -DKERNEL_PATH=\"$(KERNEL_PATH)\"
3851

39-
.PHONY: all clean install uninstall
52+
.PHONY: all clean install uninstall package
4053

4154
all: $(TARGET)
4255

@@ -48,13 +61,28 @@ $(SRC_DIR)/%.o: $(SRC_DIR)/%.cpp
4861
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@
4962

5063
install: $(TARGET)
64+
@if [ "$(KERNEL_PATH)" = "./kernels/" ]; then \
65+
echo "Installation not supported with portable kernel path."; \
66+
exit 1; \
67+
fi
5168
@echo "Installation de $(TARGET) dans $(PREFIX)/bin"
5269
install -d $(DESTDIR)$(PREFIX)/bin
5370
install -m 755 $(TARGET) $(DESTDIR)$(PREFIX)/bin/
5471
@echo "Installation des kernels dans $(KERNEL_PATH)"
5572
install -d $(DESTDIR)$(KERNEL_PATH)
5673
install -m 644 kernels/*.cl $(DESTDIR)$(KERNEL_PATH)
5774

75+
package: $(TARGET)
76+
@if [ "$(KERNEL_PATH)" != "./kernels/" ]; then \
77+
echo "Packaging only supported with portable kernel path."; \
78+
exit 1; \
79+
fi
80+
mkdir -p package/$(PACKAGE)
81+
cp $(TARGET) package/$(PACKAGE)
82+
cp -r kernels package/$(PACKAGE)
83+
ldd $(TARGET) | grep "=> /.[^/]" | awk '{print $$3}' | xargs -- cp -t package/$(PACKAGE)
84+
bsdtar -czvf $(PACKAGE).zip -C package $(PACKAGE)
85+
5886
uninstall:
5987
@echo "Désinstallation de $(TARGET)"
6088
rm -f $(DESTDIR)$(PREFIX)/bin/$(TARGET)

README.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,29 +136,49 @@ Requirements
136136

137137
Quick Start
138138
-----------
139-
Build from source
139+
4. Build from source
140140
* Linux/macOS (example):
141141
```sh
142-
make
142+
make -j$(nproc)
143143
```
144144
* Windows (recommended): CMake + vcpkg + Visual Studio
145145
```cmd
146146
cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release
147147
cmake --build build --config Release
148148
```
149-
150-
Run a PRP test
149+
* Windows: MSYS2 UCRT64
150+
* Install MSYS2
151+
* Click open "MSYS2 UCRT64"
152+
* Install dependencies:
153+
```sh
154+
pacman -Syu
155+
pacman -S --noconfirm make mingw-w64-ucrt-x86_64-{gcc,opencl-headers,gmp,curl,opencl-icd}
156+
```
157+
* Build:
158+
```sh
159+
make -j$(nproc)
160+
```
161+
(Hint: add `MARCH=xxx` after `make` to select the CPU architecture to optimize for. The default is `MARCH=native`, which is good for
162+
your current CPU but may not work when you want to build for others.)
163+
* Package:
164+
```sh
165+
make package
166+
```
167+
(This takes care of copying the required DLLs next to the executable.)
168+
169+
170+
5. Run a PRP test
151171
```sh
152172
./prmers 136279841
153173
```
154174
(Default: PRP mode, Marin backend on)
155175

156-
4. Disable Marin (use legacy internal backend)
176+
6. Disable Marin (use legacy internal backend)
157177
```sh
158178
./prmers 136279841 -marin
159179
```
160180

161-
6. P-1 stage-1 + stage-2
181+
7. P-1 stage-1 + stage-2
162182
```sh
163183
./prmers 367 -pm1 -b1 11981 -b2 38971
164184
```

src/ui/WebGuiServer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#define NOMINMAX
1212
#include <winsock2.h>
1313
#include <ws2tcpip.h>
14-
#pragma comment(lib,"Ws2_32.lib")
1514
#else
1615
#include <sys/types.h>
1716
#include <sys/socket.h>

0 commit comments

Comments
 (0)