Skip to content
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

Remove dependency on cub #449

Merged

Conversation

VinInn
Copy link

@VinInn VinInn commented Apr 25, 2020

This PR build on #447 and remove dependencies from cub in the allocator as well.
BuildFiles have been cleaned.

In principle cub can be removed as required external.

test passed

@fwyzard
Copy link

fwyzard commented Apr 25, 2020

I don't understand... here is what GitHub shows me:
image

@VinInn
Copy link
Author

VinInn commented Apr 25, 2020

that was one additional commit due to conflicts (I was in pre5)
this is what I see
image

@fwyzard
Copy link

fwyzard commented May 15, 2020

@VinInn could you rebase this on top of the latest CMSSW_11_1_X (which now includes #447) ?

@VinInn
Copy link
Author

VinInn commented May 15, 2020

looks ok but includes explicitly #447. Any suggestion?

@VinInn VinInn changed the base branch from CMSSW_11_1_X_Patatrack to master May 15, 2020 17:21
@fwyzard
Copy link

fwyzard commented May 15, 2020

looks ok but includes explicitly #447. Any suggestion?

Do you mean the it appears in the diff ?
Let me see if re-targetting the PR helps with that.

@fwyzard fwyzard changed the base branch from master to CMSSW_11_1_X_Patatrack May 15, 2020 20:30
@fwyzard
Copy link

fwyzard commented May 15, 2020

Nope.

@fwyzard
Copy link

fwyzard commented May 15, 2020

According to a discussion on GitHub forums it's not a bug, it's a feature:

When you merge commits from a Pull Request into a branch, the commit SHA changes from what the original commit SHA's were.

This means when you compare the same two branches again, the diff will show those commits again because those specific commit SHA's don't exist on the branch you're merging into.

This is a result of the type of diff we use on GitHub. We use git's three dot diff, which is the difference between the latest commit on the HEAD branch and the last common ancestor commit with the base branch.

This matches what I see locally:

normal git diff with two dots ..

$ git diff CMSSW_11_1_X_Patatrack..pull/449 -- HeterogeneousCore/CUDAUtilities/interface/HistoContainer.h
[nothing]

git diff with three dots ...

$ git diff CMSSW_11_1_X_Patatrack...pull/449 -- HeterogeneousCore/CUDAUtilities/interface/HistoContainer.h
diff --git a/HeterogeneousCore/CUDAUtilities/interface/HistoContainer.h b/HeterogeneousCore/CUDAUtilities/interface/HistoContainer.h
index 7b31863a9f4c..bd80281f7533 100644
--- a/HeterogeneousCore/CUDAUtilities/interface/HistoContainer.h
+++ b/HeterogeneousCore/CUDAUtilities/interface/HistoContainer.h
@@ -9,10 +9,6 @@
 #include <cstdint>
 #include <type_traits>
 
-#ifdef __CUDACC__
-#include <cub/cub.cuh>
-#endif
-
 #include "HeterogeneousCore/CUDAUtilities/interface/AtomicPairCounter.h"
 #include "HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h"
 #include "HeterogeneousCore/CUDAUtilities/interface/cuda_assert.h"
@@ -61,32 +57,31 @@ namespace cms {
                                                           = cudaStreamDefault
 #endif
     ) {
-      uint32_t *off = (uint32_t *)((char *)(h) + offsetof(Histo, off));
+      uint32_t *poff = (uint32_t *)((char *)(h) + offsetof(Histo, off));
+      int32_t size = offsetof(Histo, bins) - offsetof(Histo, off);
+      assert(size >= int(sizeof(uint32_t) * Histo::totbins()));
 #ifdef __CUDACC__
-      cudaCheck(cudaMemsetAsync(off, 0, 4 * Histo::totbins(), stream));
+      cudaCheck(cudaMemsetAsync(poff, 0, size, stream));
 #else
-      ::memset(off, 0, 4 * Histo::totbins());
+      ::memset(poff, 0, size);
 #endif
     }
 
     template <typename Histo>
[...]

So, it looks like the only options for cleaning up the diff are to

  • rebase instead of merging
  • squashing all commits

The rebase cannot be done automatically, so I would not suggest doing it.

The squash is as simple as

git checkout RemoveDependencyFromCUB
git merge CMSSW_11_1_X_Patatrack -m 'Merge'
git reset CMSSW_11_1_X_Patatrack
git add -A .
git commit -m'Remove all dependencies on cub'
git push -f

(if anybody knows a simpler way, I'll be happy to hear it)

However, in out case this affects only the diff shown on GitHub: when we merge we squash all commits anyway, so the end results will be the same.

@fwyzard fwyzard requested a review from makortel May 15, 2020 20:55
@VinInn
Copy link
Author

VinInn commented May 16, 2020

Is it technically possible to run 'code format' directly on git?

@fwyzard
Copy link

fwyzard commented May 16, 2020

Not as far as I know.

@fwyzard
Copy link

fwyzard commented May 16, 2020

Looks good for merging, waiting just to give @makortel a chance to comment.

@@ -331,8 +331,7 @@ namespace notcub {
cudaError_t error = cudaSuccess;

if (device == INVALID_DEVICE_ORDINAL) {
if (CubDebug(error = cudaGetDevice(&entrypoint_device)))
return error;
cudaCheck(error = cudaGetDevice(&entrypoint_device));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If all errors are handled with cudaCheck() internally, I'd expect there is no need to return an "error code" anymore (that was already passed through cudaCheck() in the calling code). Something to be cleaned up in a subsequent PR though.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we don't expect errors, I would just cudaCheck all function calls (except for retrying the out-of-memory case).
Can be followed up later.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we don't expect errors, I would just cudaCheck all function calls (except for retrying the out-of-memory case).
Can be followed up later.

I agree.

}

// Allocate the block if necessary
if (!found) {
// Attempt to allocate
// TODO: eventually support allocation flags
if (CubDebug(error = cudaHostAlloc(&search_key.d_ptr, search_key.bytes, cudaHostAllocDefault)) ==
if ((error = cudaHostAlloc(&search_key.d_ptr, search_key.bytes, cudaHostAllocDefault)) ==

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a functional change, earlier it would print out the error code if CUB_STDERR was defined (which IIRC we do define). Doesn't really matter to me though.

Copy link

@makortel makortel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The caching allocators would benefit from further cleanup (well, rewrite from scratch really...), but better to be done later.

@fwyzard fwyzard changed the title Remove dependency from cub Remove dependency on cub May 18, 2020
@makortel
Copy link

@fwyzard Thanks for annotating all the changes, I think this PR is good to go now.

@fwyzard fwyzard merged commit 39a8c4b into cms-patatrack:CMSSW_11_1_X_Patatrack May 18, 2020
fwyzard added a commit that referenced this pull request Oct 8, 2020
Annotate all CMS-specific changes to CachingDeviceAllocator.

Co-authored-by: Andrea Bocci <andrea.bocci@cern.ch>
fwyzard added a commit that referenced this pull request Oct 19, 2020
Annotate all CMS-specific changes to CachingDeviceAllocator.

Co-authored-by: Andrea Bocci <andrea.bocci@cern.ch>
fwyzard added a commit that referenced this pull request Oct 20, 2020
Annotate all CMS-specific changes to CachingDeviceAllocator.

Co-authored-by: Andrea Bocci <andrea.bocci@cern.ch>
fwyzard added a commit that referenced this pull request Oct 23, 2020
Annotate all CMS-specific changes to CachingDeviceAllocator.

Co-authored-by: Andrea Bocci <andrea.bocci@cern.ch>
fwyzard added a commit that referenced this pull request Nov 6, 2020
Annotate all CMS-specific changes to CachingDeviceAllocator.

Co-authored-by: Andrea Bocci <andrea.bocci@cern.ch>
fwyzard added a commit that referenced this pull request Nov 16, 2020
Annotate all CMS-specific changes to CachingDeviceAllocator.

Co-authored-by: Andrea Bocci <andrea.bocci@cern.ch>
fwyzard added a commit that referenced this pull request Nov 27, 2020
Annotate all CMS-specific changes to CachingDeviceAllocator.

Co-authored-by: Andrea Bocci <andrea.bocci@cern.ch>
fwyzard added a commit that referenced this pull request Dec 25, 2020
Annotate all CMS-specific changes to CachingDeviceAllocator.

Co-authored-by: Andrea Bocci <andrea.bocci@cern.ch>
fwyzard added a commit that referenced this pull request Dec 29, 2020
Annotate all CMS-specific changes to CachingDeviceAllocator.

Co-authored-by: Andrea Bocci <andrea.bocci@cern.ch>
fwyzard added a commit that referenced this pull request Dec 29, 2020
Annotate all CMS-specific changes to CachingDeviceAllocator.

Co-authored-by: Andrea Bocci <andrea.bocci@cern.ch>
fwyzard added a commit that referenced this pull request Dec 29, 2020
Annotate all CMS-specific changes to CachingDeviceAllocator.

Co-authored-by: Andrea Bocci <andrea.bocci@cern.ch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants