Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Merge commit '240a14784da2fa35f54fc30b2e73d10e32dc8ea9' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewcorrigan committed Oct 16, 2020
2 parents 1f8c508 + 240a147 commit e6e46bd
Show file tree
Hide file tree
Showing 11 changed files with 146 additions and 38 deletions.
28 changes: 20 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
# Support adding Thrust to a parent project via add_subdirectory.
# See examples/cmake/add_subdir/CMakeLists.txt for details.
if (NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_LIST_DIR}")
include(cmake/ThrustAddSubdir.cmake)
return()
endif()

# 3.15 is the minimum.
# 3.17 for nvc++/Feta
# 3.18 for C++17 + CUDA
Expand All @@ -18,12 +11,31 @@ endif()

project(Thrust NONE)

# Determine whether Thrust is the top-level project or included into
# another project via add_subdirectory()
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_LIST_DIR}")
set(THRUST_TOPLEVEL_PROJECT ON)
else()
set(THRUST_TOPLEVEL_PROJECT OFF)
endif()

option(THRUST_ENABLE_INSTALL_RULES "Enable installation of Thrust" ${THRUST_TOPLEVEL_PROJECT})
if (THRUST_ENABLE_INSTALL_RULES)
include(cmake/ThrustInstallRules.cmake)
endif()

# Support adding Thrust to a parent project via add_subdirectory.
# See examples/cmake/add_subdir/CMakeLists.txt for details.
if (NOT THRUST_TOPLEVEL_PROJECT)
include(cmake/ThrustAddSubdir.cmake)
return()
endif()

include(cmake/AppendOptionIfAvailable.cmake)

include(cmake/ThrustBuildCompilerTargets.cmake)
include(cmake/ThrustBuildTargetList.cmake)
include(cmake/ThrustMultiConfig.cmake)
include(cmake/ThrustInstallRules.cmake)
include(cmake/ThrustUtilities.cmake)

option(THRUST_ENABLE_HEADER_TESTING "Test that all public headers compile." "ON")
Expand Down
74 changes: 74 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ The CMake options are divided into these categories:
- `THRUST_ENABLE_EXAMPLE_FILECHECK={ON, OFF}`
- Enable validation of example outputs using the LLVM FileCheck utility.
Default is `OFF`.
- `THRUST_ENABLE_INSTALL_RULES={ON, OFF}`
- If true, installation rules will be generated for thrust. Default is `ON`.

## Single Config CMake Options

Expand Down Expand Up @@ -391,6 +393,10 @@ The CMake options are divided into these categories:
simultaneously.
- CUB configurations will be generated for each C++ dialect targeted by
the current Thrust build.
- `THRUST_INSTALL_CUB_HEADERS={ON, OFF}`
- If enabled, the CUB project's headers will be installed through Thrust's
installation rules. Default is `ON`.
- This option depends on `THRUST_ENABLE_INSTALL_RULES`.
- `THRUST_ENABLE_COMPUTE_XX={ON, OFF}`
- Controls the targeted CUDA architecture(s)
- Multiple options may be selected when using NVCC as the CUDA compiler.
Expand Down Expand Up @@ -489,3 +495,71 @@ The following branch names are used in the Thrust project:
On the rare occasion that we cannot do work in the open, for example when developing a change specific to an
unreleased product, these branches may exist on `gitlab` instead of `github`. By default, everything should be
in the open on `github` unless there is a strong motivation for it to not be open.

# Release Process

This section is a work in progress.

## Update Compiler Explorer

Thrust and CUB are bundled together on
[Compiler Explorer](https://www.godbolt.org/) (CE) as libraries for the CUDA
language. When releasing a new version of these projects, CE will need to be
updated.

There are two files in two repos that need to be updated:

### libraries.yaml

- Repo: https://github.com/compiler-explorer/infra
- Path: bin/yaml/libraries.yaml

This file tells CE how to pull in library files and defines which versions to
fetch. Look for the `thrustcub:` section:

```yaml
thrustcub:
type: github
method: clone_branch
repo: NVIDIA/thrust
check_file: dependencies/cub/cub/cub.cuh
targets:
- 1.9.9
- 1.9.10
- 1.9.10-1
- 1.10.0
```
Simply add the new version tag to list of `targets:`. This will check out the
specified tag to `/opt/compiler-explorer/libs/thrustcub/<tag>/`.

### cuda.amazon.properties

- Repo: https://github.com/compiler-explorer/compiler-explorer
- File: etc/config/cuda.amazon.properties

This file defines the library versions displayed in the CE UI and maps them
to a set of include directories. Look for the `libs.thrustcub` section:

```yaml
libs.thrustcub.name=Thrust+CUB
libs.thrustcub.description=CUDA collective and parallel algorithms
libs.thrustcub.versions=trunk:109090:109100:109101:110000
libs.thrustcub.url=http://www.github.com/NVIDIA/thrust
libs.thrustcub.versions.109090.version=1.9.9
libs.thrustcub.versions.109090.path=/opt/compiler-explorer/libs/thrustcub/1.9.9:/opt/compiler-explorer/libs/thrustcub/1.9.9/dependencies/cub
libs.thrustcub.versions.109100.version=1.9.10
libs.thrustcub.versions.109100.path=/opt/compiler-explorer/libs/thrustcub/1.9.10:/opt/compiler-explorer/libs/thrustcub/1.9.10/dependencies/cub
libs.thrustcub.versions.109101.version=1.9.10-1
libs.thrustcub.versions.109101.path=/opt/compiler-explorer/libs/thrustcub/1.9.10-1:/opt/compiler-explorer/libs/thrustcub/1.9.10-1/dependencies/cub
libs.thrustcub.versions.110000.version=1.10.0
libs.thrustcub.versions.110000.path=/opt/compiler-explorer/libs/thrustcub/1.10.0:/opt/compiler-explorer/libs/thrustcub/1.10.0/dependencies/cub
libs.thrustcub.versions.trunk.version=trunk
libs.thrustcub.versions.trunk.path=/opt/compiler-explorer/libs/thrustcub/trunk:/opt/compiler-explorer/libs/thrustcub/trunk/dependencies/cub
```

Add a new version identifier to the `libs.thrustcub.versions` key, using the
convention `X.Y.Z-W -> XXYYZZWW`. Then add a corresponding UI label (the
`version` key) and set of colon-separated include paths for Thrust and CUB
(`path`). The version used in the `path` entries must exactly match the tag
specified in `libraries.yaml`.
2 changes: 1 addition & 1 deletion dependencies/cub
Submodule cub updated 1 files
+16 −2 cub/util_allocator.cuh
25 changes: 10 additions & 15 deletions thrust/cmake/thrust-config-version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,19 @@ math(EXPR THRUST_VERSION_MAJOR "${THRUST_VERSION_FLAT} / 100000")
math(EXPR THRUST_VERSION_MINOR "(${THRUST_VERSION_FLAT} / 100) % 1000")
math(EXPR THRUST_VERSION_PATCH "${THRUST_VERSION_FLAT} % 100") # Thrust: "subminor" CMake: "patch"

# Build comparison versions:
set(THRUST_COMPAT "${THRUST_VERSION_MAJOR}.${THRUST_VERSION_MINOR}.${THRUST_VERSION_PATCH}")
set(THRUST_EXACT "${THRUST_COMPAT}.${THRUST_VERSION_TWEAK}")
set(FIND_COMPAT "${PACKAGE_FIND_VERSION_MAJOR}.${PACKAGE_FIND_VERSION_MINOR}.${PACKAGE_FIND_VERSION_PATCH}")
set(FIND_EXACT "${FIND_COMPAT}.${PACKAGE_FIND_VERSION_TWEAK}")
set(THRUST_VERSION "${THRUST_VERSION_MAJOR}.${THRUST_VERSION_MINOR}.${THRUST_VERSION_PATCH}.${THRUST_VERSION_TWEAK}")

# Set default results
set(PACKAGE_VERSION ${THRUST_EXACT})
set(PACKAGE_VERSION_UNSUITABLE FALSE)
set(PACKAGE_VERSION ${THRUST_VERSION})
set(PACKAGE_VERSION_COMPATIBLE FALSE)
set(PACKAGE_VERSION_EXACT FALSE)
set(PACKAGE_VERSION_UNSUITABLE FALSE)

# Test for compatibility (ignores tweak)
if (FIND_COMPAT VERSION_EQUAL THRUST_COMPAT)
set(PACKAGE_VERSION_COMPATIBLE TRUE)
endif()
if(PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION)
if(PACKAGE_FIND_VERSION_MAJOR STREQUAL THRUST_VERSION_MAJOR)
set(PACKAGE_VERSION_COMPATIBLE TRUE)
endif()

# Test for exact (does not ignore tweak)
if (FIND_EXACT VERSION_EQUAL THRUST_EXACT)
set(PACKAGE_VERSION_EXACT TRUE)
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()
6 changes: 6 additions & 0 deletions thrust/cmake/thrust-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -650,3 +650,9 @@ foreach(component ${${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS})
endforeach()

thrust_update_system_found_flags()

include(FindPackageHandleStandardArgs)
if (NOT Thrust_CONFIG)
set(Thrust_CONFIG "${CMAKE_CURRENT_LIST_FILE}")
endif()
find_package_handle_standard_args(Thrust CONFIG_MODE)
4 changes: 2 additions & 2 deletions thrust/detail/tuple.inl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ template <
class tuple;

// forward declaration of tuple_element
template<int i, typename T> struct tuple_element;
template<size_t N, class T> struct tuple_element;

// specializations for tuple_element
template<class T>
Expand All @@ -60,7 +60,7 @@ template<class T>
typedef typename T::head_type type;
}; // end tuple_element<0,T>

template<int N, class T>
template<size_t N, class T>
struct tuple_element<N, const T>
{
private:
Expand Down
14 changes: 11 additions & 3 deletions thrust/iterator/detail/zip_iterator.inl
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,19 @@ template<typename IteratorTuple>
} // end zip_iterator::distance_to()


template<typename IteratorTuple>
template<typename... Iterators>
__host__ __device__
zip_iterator<thrust::tuple<Iterators...>> make_zip_iterator(thrust::tuple<Iterators...> t)
{
return zip_iterator<thrust::tuple<Iterators...>>(t);
} // end make_zip_iterator()


template<typename... Iterators>
__host__ __device__
zip_iterator<IteratorTuple> make_zip_iterator(IteratorTuple t)
zip_iterator<thrust::tuple<Iterators...>> make_zip_iterator(Iterators... its)
{
return zip_iterator<IteratorTuple>(t);
return make_zip_iterator(thrust::make_tuple(its...));
} // end make_zip_iterator()


Expand Down
18 changes: 16 additions & 2 deletions thrust/iterator/zip_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,23 @@ template <typename IteratorTuple>
*
* \see zip_iterator
*/
template<typename IteratorTuple>
template<typename... Iterators>
inline __host__ __device__
zip_iterator<IteratorTuple> make_zip_iterator(IteratorTuple t);
zip_iterator<thrust::tuple<Iterators...>> make_zip_iterator(thrust::tuple<Iterators...> t);


/*! \p make_zip_iterator creates a \p zip_iterator from
* iterators.
*
* \param its The iterators to copy.
* \return A newly created \p zip_iterator which zips the iterators.
*
* \see zip_iterator
*/
template<typename... Iterators>
inline __host__ __device__
zip_iterator<thrust::tuple<Iterators...>> make_zip_iterator(Iterators... its);


/*! \} // end fancyiterators
*/
Expand Down
2 changes: 1 addition & 1 deletion thrust/pair.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ template <typename T1, typename T2>
* \tparam N This parameter selects the member of interest.
* \tparam T A \c pair type of interest.
*/
template<int N, typename T> struct tuple_element;
template<size_t N, class T> struct tuple_element;


/*! This convenience metafunction is included for compatibility with
Expand Down
9 changes: 4 additions & 5 deletions thrust/system/detail/generic/scalar/binary_search.inl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ RandomAccessIterator lower_bound_n(RandomAccessIterator first,
Size start = 0, i;
while(start < n)
{
i = (start + n) / 2;
i = start + (n - start) / 2; // Overflow-safe variant of (a+b)/2
if(wrapped_comp(first[i], val))
{
start = i + 1;
Expand All @@ -62,7 +62,7 @@ RandomAccessIterator lower_bound_n(RandomAccessIterator first,
n = i;
}
} // end while

return first + start;
}

Expand Down Expand Up @@ -94,7 +94,7 @@ RandomAccessIterator upper_bound_n(RandomAccessIterator first,
Size start = 0, i;
while(start < n)
{
i = (start + n) / 2;
i = start + (n - start) / 2; // Overflow-safe variant of (a+b)/2
if(wrapped_comp(val, first[i]))
{
n = i;
Expand All @@ -104,7 +104,7 @@ RandomAccessIterator upper_bound_n(RandomAccessIterator first,
start = i + 1;
}
} // end while

return first + start;
}

Expand Down Expand Up @@ -156,4 +156,3 @@ bool binary_search(RandomAccessIterator first, RandomAccessIterator last, const
} // end thrust

#include <thrust/system/detail/generic/scalar/binary_search.inl>

2 changes: 1 addition & 1 deletion thrust/tuple.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct null_type;
* \see pair
* \see tuple
*/
template<int N, class T>
template<size_t N, class T>
struct tuple_element
{
private:
Expand Down

0 comments on commit e6e46bd

Please sign in to comment.