Menu
Logged-In As
ACCOUNTNot Logged In
Create test for thread creation on WindowsBRL-CAD
Status: ClosedTime to complete:
48 hrs
Mentors: Sean
This is a follow-on of a previous GCI task:
- http://www.google-melange.com/gci/task/view/google/gci2012/8030203
Your task is to test whether that thread creation actually works correctly. Write a small test program that calls bu_parallel() and calls a function N times.
You can submit this as a partial unit test for parallel.c by adding a new test file similar to several other existing files. You can write the test on any platform, but ideally you'll have access to a clean Windows build so that you can specifically test the new Windows thread creation.
Code:
- src/libbu/tests/CMakeLists.txt
- src/libbu/tests/test_parallel.c -- you write this, test bu_parallel()
Uploaded Work
File name/URL | File size | Date submitted | |
---|---|---|---|
parallel-test.patch | 1.9 KB | January 08 2013 17:28 UTC | |
parallel-test.patch | 2.1 KB | January 08 2013 17:44 UTC | |
parallel-test.patch | 2.1 KB | January 09 2013 03:49 UTC | |
parallel-sans-arg.patch | 1.9 KB | January 09 2013 03:49 UTC | |
parallel-test.patch | 3.5 KB | January 09 2013 11:04 UTC |
I would like to work on this task.
This task has been assigned to Skriptkid. You have 48 hours to complete this task, good luck!
The test files are run when "make test" is run right? And in Windows, if ALL_BUILD is used to build BRL-CAD, is "test" also run?
"that calls bu_parallel() and calls a function N times." Create a function in the test file and call it through bu_parallel?
The work on this task is ready to be reviewed.
One of the mentors has sent this task back for more work. Talk to the mentor(s) assigned to this task to satisfy the requirements needed to complete this task, submit your work again and mark the task as complete once you re-submit your work.
What's the needed work?
Noticed a few minor issues:
First three were issues, which are now corrected, but 4 and 5 are there intentionally. argv[1] is the number of times bu_parallel is run("N") and argv[2] is the no. of CPUs available(which is also the number of threads created by parallel, unless that many are not available.) Both of these are passed through CMakeLists.txt in addtest(... ... N no-of-CPUs.) If you're saying this is not needed, I'l upload two versions, one with arguments being passed and the other without. The no of CPUs have to be passed since bu_parallel takes (void *func)(int ncpu, genptr arg) Also, the no of argc is being tested. (if (argc 3)) If some changes still need to be made, I'll do it.
The work on this task is ready to be reviewed.
I wasn't saying that passing N and no-of-CPUs aren't needed. I was asking *why* are you running bu_parallel N times?
I was also asking why you only test no-of-CPUs=1? Why not also test 2, 10, 42...
You're not really testing bu_parallel() very well to only test creation of 1 parallel context.
One of the mentors has sent this task back for more work. Talk to the mentor(s) assigned to this task to satisfy the requirements needed to complete this task, submit your work again and mark the task as complete once you re-submit your work.
There's probably a misunderstanding on my part. The task description says "that calls bu_parallel and calls a function N times." What does this mean? What I've understood is that you need to pass a test function to bu_parallel and run it N times, which is why I've put bu_parallel in a loop that runs N times and calls bu_parallel each time, passing the test function to it.
The CPUs part, I had forgotten. I'll add some more tests. Any specific number required?
The work on this task is ready to be reviewed.
The latest patch has some more(25 more) tests. I haven't fixed the "N times" part yet, because I'm waiting for someone to answer that.
Congratulations, this task has been completed successfully.
I think there is some misunderstanding on your part of what bu_parallel() does. All of the additional tests you added are rather unnecessary (unhelpful even) and I think just reinforce the misunderstanding for what the two parameters you've defined actually do. Calling bu_parallel() just one time runs a function X times in parallel. So in actuality, you only needed to have your test program call bu_parallel once. It's okay to re-run it in a loop but from a testing perspective, you have to think about what it's testing and hoping to catch.
On that point, your test should have included some means to verify that bu_parallel() actually ran a function X times but I let it pass since you got enough scaffolding in place for us to make that edit. You run it and print a message, but don't actually have the program test anything (beyond it compiles and didn't crash). A human becomes the tester, needing to read the print statements and discern if anything is wrong. Still, easy to fix.
Thanks for your efforts. Again, it's a good stub to get us started (and why it's worth closing). You've put good work in spite of the misunderstanding. ;)