-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create unified tests #1341
Create unified tests #1341
Conversation
499e10d
to
0ac2392
Compare
ec53f64
to
32b548b
Compare
7f412bf
to
c295ae8
Compare
I think you can remove a lot of boilerplate. The macro
could create a struct entry containing both the function pointer and the string, i.e.
So you wouldn't need the separate array with
|
Parallel testing for a single module is quite useful to keep. What are the options?
|
Thanks for your feedback! Yes, this sounds as the best possible alternative, will do this instead. |
Just so it is out there, I think we can agree that parallell testing within each module when performing all tests throughout FLINT doesn't really matter, and would probably not be beneficial at all. However, for one module only, I am thinking that a call like make check MOD=fmpz [THREAD=1/NTHREADS=8] could invoke threading via
which would spawn threads of whom each works on a subset of tests. Wouldn't be hard to implement. Sounds good? Edit: I will first check if it is possible to obtain the number of threads in Make, and so one wouldn't need to pass another parameter into Make, but simply use |
We'd have to be careful about running multiple tests in the same process because this changes runtime behaviour: we will enter some tests with cached data (fmpzs, primes, arb constants, thread pool, etc.) whereas tests previously always started with a clean slate. Actually this can be a good thing to test too, but I don't know if it should be the default. There is a particular problem with using multithreading to run tests in parallel: tests intended specifically to check multithreaded algorithms may end up only running serially because the thread pool is occupied by the competing test programs! (Again, it is also potentially interesting to deliberately test such conditions, but it should maybe not be the default.) |
Okay, I would like to not parallelize the tests in this PR. Is that okay with you, @fredrik-johansson? That we can do later, should be easy. |
c3e4cb8
to
62ee62d
Compare
It looks fine, but I would like to see parallel tests working from the start. |
c62f76d
to
3b35877
Compare
I think I have an idea of how to check a single module with multiple jobs. Let
The running recipes should look something like ifdef MOD
define mod_recipe
$(BUILD_DIR)/$(MOD)/test/main_RUN_$(1): $(BUILD_DIR)/$(MOD)/test/main | $(BUILD_DIR)/$(MOD)/test
@$< $(MOD_TESTS_$(1))
endef
$(foreach job_number, $(JOB_NUMBER_LIST), $(eval $(call mod_recipe,$(job_number))))
endif |
@fredrik-johansson Is there a reason why many files contain an empty line at the end of the file? |
fff800a
to
e5a69ed
Compare
For running the tests in parallel, I would outsource it to the GNU Parallel |
e5a69ed
to
2f13edc
Compare
I'd prefer if the makefile contains as much code as possible written in native Make, but if I cannot make it work I will consider this. Thanks! |
In hindsight, I think you are right, native make sounds much more reasonable. |
ff2f83d
to
1ac5f1c
Compare
But I really want the runtime to be lower before merging. It could signal that something went wrong. For example, in the MSVC runner, |
OK, parallel I consider that acceptable as long as |
Looks like a lot of work was made on |
Okay, on Linux with Make 4.4.1, I have performed some tests, and it seems like the tests on this branch indeed is faster when not running in parallel. However, for parallel runs, it is not always the case. The solution seems to be that one runs One could alter the flags inside the Makefile, but that requires Make 4.4 I believe. Will post some benchmarks soon. |
Here are some benchmarks indicating that this branch is faster when running
|
And remove TESTCFLAGS for AVX runner
I get the same behavior:
Curious; any clue why it's like that? |
Nice that you had the same result! I remember seeing something about it on SE, but I don't know the reason behind it. |
Finally. I think it is ready to be merged! |
It looks good. Before merging, I just want to see that test coverage hasn't changed. Could you update the explanations https://flintlib.org/doc/building.html also? Document the |
The coverage changes reported by codecov are worth a look. For example, there seem to be functions in |
I pushed a commit for this. |
Yeah, I really want to fix these things, but looking into it, it seems like there is no change. For example, |
Like, there may be a lot of bugs and so on in this PR, but I doubt that this PR will actually decrease the coverage. |
The local coverage report seems to be broken. Doing
I get coverage reports for all the test |
Does my commit work? |
That excludes the tests, but all |
OK, that may just have been something wonky on my end. It works after I changed some search paths. |
OK, will merge this now. Nothing looks obviously wrong, and the CI speedup alone is worth it. Thanks a lot! |
Note: New description
Change of code
Currently, all tests in FLINT is basically written in the same way, namely
To streamline this, we can do this instead:
with a main function
End result
The end result will be more streamlined tests along with a reduced compile time for the tests as only
module/test/main.c
has to be compiled, in contrast to compilingmodule/test/t-*.c
separately. I suspect this will reduce the compile time by at least 50%, but I think one could expect a larger reduction in compile time for the tests.Also, we should see a great reduction in the number of lines.
Functionality
In order to only run a subset of test functions, one can do this via
./build/fmpz/test/main fmpz_add fmpz_addmul
, and in this example it will only run the test forfmpz_add
andfmpz_addmul
.I do not intend to implement multithreaded testing for a single module in this PR, but it would be nice to have this. However, as of now it is not the main priority.
Bug fixes-ish
As I am going through all files (semi-automatically, just using Vim macros to change everything), I noticed that some functions print the wrong function it tests. All of these are being fixed.
Moreover, some test functions for IO creates a forks in the test functions. As the child processes are never closed, this would lead to multiple processes running the same tests after these IO-tests. Hence, I ensured that these child processes are closed, and that the parent waits until the child process has exited.