-
Notifications
You must be signed in to change notification settings - Fork 14
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
Templatise Fill_cpu()
and Fill_gpu()
and increase block size
#507
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev-master #507 +/- ##
==============================================
+ Coverage 16.60% 18.00% +1.39%
==============================================
Files 221 221
Lines 48490 52808 +4318
Branches 20272 19698 -574
==============================================
+ Hits 8053 9508 +1455
- Misses 36143 38778 +2635
- Partials 4294 4522 +228 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
Merged
kaihsin
approved these changes
Nov 19, 2024
yingjerkao
approved these changes
Nov 19, 2024
This is the preparation for refactoring the `Storage` classes.
The maximum x- or y-dimension of a block is 1024 with compute capability above 2.x. The compute capability requirements of cuTENSOR and cuQuantum are much higher than 2.x. Furthermore, it's not easy to find a device that only supports the compute capability below or eqaul 1.3.
Dynamic scheduling is 1000 times slower than the static scheduling in this case. Below is the result and the code for benchmarking. ``` Total time for FillCpu: 0.0185553 seconds Total time for FillCpuDynamic: 21.2537 seconds ``` ```cpp /** compile command: g++ -std=c++17 -fopenmp -O3 -o fill.o fill.cpp && ./fill.o */ using namespace std; template <typename DType> void FillCpu(void *first, const DType &value, size_t count) { DType *typed_first = reinterpret_cast<DType *>(first); for (int i = 0; i < count; ++i) { typed_first[i] = value; } } template <typename DType> void FillCpuDynamic(void *first, const DType &value, size_t count) { DType *typed_first = reinterpret_cast<DType *>(first); for (int i = 0; i < count; ++i) { typed_first[i] = value; } } int main() { int count = 100000; int num_iterations = 10000; int *ptr = reinterpret_cast<int *>(malloc(sizeof(int) * count)); int value = 10; { auto start = chrono::high_resolution_clock::now(); for (int iter = 0; iter < num_iterations; ++iter) { FillCpu(reinterpret_cast<void *>(ptr), value, count); } auto end = chrono::high_resolution_clock::now(); const std::chrono::duration<double> total_time = end - start; cout << "Total time for FillCpu: " << total_time.count() << " seconds" << endl; } { auto start = chrono::high_resolution_clock::now(); for (int iter = 0; iter < num_iterations; ++iter) { FillCpuDynamic(reinterpret_cast<void *>(ptr), value, count); } auto end = chrono::high_resolution_clock::now(); const std::chrono::duration<double> total_time = end - start; cout << "Total time for FillCpuDynamic: " << total_time.count() << " seconds" << endl; } } ```
IvanaGyro
force-pushed
the
templatise_fill
branch
from
November 19, 2024 06:20
77936f6
to
eed01c2
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a task listed in #500.