Skip to content

Commit 249813e

Browse files
committed
Increase thread limit
1 parent ded05c1 commit 249813e

3 files changed

Lines changed: 20 additions & 25 deletions

File tree

devlog.md

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
1-
ARBITRARY PRECISION IS UPON US!
1+
The complex function plotter is done!
22

3-
Keeping things short, I tried, and failed, to implement my own GPU, GLSL arbitrary precision math library. Why? Because nobody else has! And for good reason.
4-
- First, I built the math library in a functional way `(add(x,y) -> z)`. This causes the GPU to run out of registers, because returning arrays means allocating temporary memory
5-
- Then, I rewrote the entire library to use 16 global registers, and by mutating a third input `(add(x,y,z) -> void)`. This worked at first, but for minimally nested functions (like `cos(sin(z))`), the GPU tries, and fails, to unroll the loops. So the shader doesn't compile
6-
- To fix that, I once again optimized the library and added flags for the GPU not to unroll. _then_ we run into a problem where the _assembly_ becomes too large. To my knowledge there is no practical solution for this.
3+
A little bit of personal lore here: I made another complex function plotter four years ago, when I was still in highschool. It was clunky, but worked fine enough. Still, I felt it missed some things, which led me to work on this project.
4+
Now, I have accomplished all things I have set out to do. Bugfixes aside, I believe I can put this project to rest now.
75

8-
At this point, I realized that true arbitrary precision is impossible in the GPU. Thankfully, GLSL translates pretty neatly to C++, so I could just, at build step, transform my complex functions into C++, and do all my arbitrary precision in the CPU!
6+
First, I worked on making the high precision plots reactive. They take a while to render, so having them shut down the main thread while the user waits on a blank screen isn't very fun. Now, each thread updates the canvas for every pixel they render. This allows the user to see the progress being made!
7+
Also, some reconfigurations were needed in the web version, since the browser needs special permissions to run Web Workers (the equivalent to threads for browsers)
98

10-
It is very slow, but it's meant for very high detail images. So, completely fine! Attached, some plots!
9+
Then, some quality of life changes: I added an amortization factor so the graph takes longer to converge to white (and black), and fixed a parsing mistake one of my beta testers caught.
1110

12-
**Commits**
13-
[2895bc0](https://url.jam06452.uk/2cwiyv): UHPM renders, but not properly
14-
[6d39bca](https://url.jam06452.uk/px4ufa): UHPM works, but not for big expressions
15-
[5d96733](https://url.jam06452.uk/154kn6z): High precision zooming
16-
[43e4423](https://url.jam06452.uk/s0xmt3): GPU to CPU transpiling
17-
[f262c96](https://url.jam06452.uk/137or8f): CPU rendering!
11+
Finally, documentation and benchmarking! I could always tell this tool was _fast_, but never _how fast_. I took upon myself to benchmark my own tool, and some other project's (since they are opensource, I can manually modify the code to do so). The result were great: this project outperforms everything else by a factor of 50.
12+
13+
And that's it for now folks!
1814

19-
**Issues**
20-
[#Issue #40](.): Arbitrary precision in the CPU
21-
[Issue #41](.): GLSL to C++ Transpiler
22-
-[#48](.): Synchronizing GLSL and C++ functions
23-
-[#49](.): Running shaders in the CPU
24-
[Issue #50](.): Reoptimize UHPM
25-
-[#51](.): Rewrite math library to use inout
26-
-[#52](.): Expanding nested expressions in transpiler #52
27-
-[#53](.): Using registers in transpiler #53
15+
Attached, our high precision plotting in real time!
16+
17+
**Commits**
18+
[9dd1515](https://url.jam06452.uk/3yqc6h): Async image generation
19+
[4266aaa](https://url.jam06452.uk/c71kuv): Add threading for web version
20+
[ded05c1](https://url.jam06452.uk/gvwf7p): Update documentation and perform benchmarking
21+
[2e32e99](https://url.jam06452.uk/zgmyyg): Fixed issue where expressions with negations would be evaluated incorrectly
22+
[2e10128](https://url.jam06452.uk/1rzb8g3): Fixed issue where moving the screen would cause the high precision plot to shift as well.

src/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ add_custom_command(
4646
)
4747

4848

49-
add_executable(complex-plotter ${SOURCE_FILES} ${HEADER_SRC} "main.cpp" ${TRANSPILED_MAPPER_CPP})
49+
add_executable(complex-plotter WIN32 ${SOURCE_FILES} ${HEADER_SRC} "main.cpp" ${TRANSPILED_MAPPER_CPP})
5050

5151
if(NOT EMSCRIPTEN)
5252
find_package(OpenGL REQUIRED)
@@ -106,7 +106,7 @@ if(EMSCRIPTEN)
106106
-sEXPORTED_RUNTIME_METHODS=[ccall]
107107
-pthread
108108
-sUSE_PTHREADS=1
109-
-sPTHREAD_POOL_SIZE=8
109+
-sPTHREAD_POOL_SIZE=16
110110
)
111111
target_compile_options(complex-plotter PRIVATE "-s" "USE_GLFW=3" "-fexceptions")
112112
set_target_properties(complex-plotter PROPERTIES SUFFIX ".js")

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ void main_loop_step(AppContext* ctx) {
211211
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
212212
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
213213
}
214-
int user_thread_limit = 16;
214+
int user_thread_limit = 32;
215215

216216

217217

0 commit comments

Comments
 (0)