GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Subtle speed optimization by beru · Pull Request #419 · tiny-dnn/tiny-dnn Conversation
|
|
Achieved additional 10% ish speed gain by tuning up iterative call of activation function. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
What code are you running? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@bhack I compiled and ran |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
And with what engine? Internal? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@bhack I modified around layer and optimization function a little bit, so this PR isn't related to any backend engines. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| diff.begin(), [&](float_t x) { // NOLINT | ||
| return x * rcp_batch_size; }); | ||
| o->update(diff, target); | ||
| bool parallelize = (target.size() >= 512); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@beru what's the reason for this? Could you add a short comment to the source?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I just added below comment in recent commit.
// parallelize only when target size is big enough to mitigate thread spawning overhead
bool parallelize = (target.size() >= 512);
o->update(diff, target, parallelize);
I added bool parallelize parameter to optimizer::update method and its descendants.
The newly added parameter is used for 1st parameter of for_i function (that has triple argument prototype). for_i function can selectively create multi-threads but doing so is not favourable when size of data is small.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| #define TINY_DNN_GET_DEVICE_AND_PLATFORM \ | ||
| size_t cl_platform = 0, cl_device = 0; \ | ||
| int cl_platform = 0, cl_device = 0; \ |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Why an int here?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I've just reverted the change in here. I'll send another PR for this in future.
The reason why I changed the type : 2nd and 3rd parameters of Device::Device in tiny_dnn/core/framework/device.fwd.h is int, maybe I should have used size_t -> int casts.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@beru Are you sure that something like https://github.com/Maratyszcza/pthreadpool/ that we already used trough upstream cannot ammortised many of this costs? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I still haven't extensively checked the performance difference on many platforms, I only tested it on Win10 64bit, YMMV. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
But what code path are you testing? This one tiny-dnn/tiny_dnn/util/parallel_for.h Line 108 in 5693b92
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@bhack The thread pool you linked looks horrible. Are we going C-style library now? Have a look at this in comparison - proper modern C++: https://github.com/progschj/ThreadPool |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
No I don't want to use that. I mean that our upstream NNPACK is using that internally and I talked about ThreadPool cause I don't know if we are handling in this optimizzation only the c++11 thread backend of our parallel_for |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
@bhack Yes, that one. Here's the simplified call stack. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
@bhack I'm not so sure about that. I can only guess without having and measuring actual implementations. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@beru can I merge this PR? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@edgarriba It's up to you. I think b0db424 is much effective. So, just merging it would be enough for a while. Do you agree with the idea? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@beru sure |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.