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

Commit

Permalink
Various 10.1 fixes, mostly relating to compiler compatibility.
Browse files Browse the repository at this point in the history
* Fix broken Thrust smart pointer interoperability with `nullptr`.
* Add `explicit operator bool` to Thrust smart pointers when using C++11 for
  `std::unique_ptr` interoperability.
* Disable -Wnoexcept-type for Clang 6.
* `thrust_nightly.pl`: remove erroneous counting of disabled tests as failures.
* Remove some incorrect `return std::move(...)`s that trigger warning failures.
* Various other bug fixes.

Bug 2379510
Bug 2379513
Bug 2463967
  • Loading branch information
brycelelbach committed Dec 18, 2018
1 parent 2f79d31 commit 395f62b
Show file tree
Hide file tree
Showing 38 changed files with 242 additions and 111 deletions.
2 changes: 1 addition & 1 deletion internal/build/common_warnings.mk
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ifeq ($(OS),$(filter $(OS),Linux Darwin))
# on older versions of Clang.
CUDACC_FLAGS += -Xcompiler "-Wno-unneeded-internal-declaration"

ifeq ($(shell if test $(CLANG_VERSION) -ge 70; then echo true; fi),true)
ifeq ($(shell if test $(CLANG_VERSION) -ge 60; then echo true; fi),true)
# Clang complains about name mangling changes due to `noexcept`
# becoming part of the type system; we don't care.
CUDACC_FLAGS += -Xcompiler "-Wno-noexcept-type"
Expand Down
1 change: 1 addition & 0 deletions internal/build/warningstester_create_uber_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def find_headers(base_dir, rel_dir, exclude = ['\B']):
print('#error no include files found\n')

print('#define THRUST_CPP11_REQUIRED_NO_ERROR')
print('#define THRUST_MODERN_GCC_REQUIRED_NO_ERROR')
for h in headers:
print('#include <' + h + '>')

Expand Down
1 change: 0 additions & 1 deletion internal/test/thrust_nightly.pl
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,6 @@ sub run_unit_tests {
printf("&&&& FAILED $test\n");
printf("#### WALLTIME $test %.2f [s]\n", $elapsed);
} elsif ($known_fail == 0 and $pass == 0) {
$errors = $errors + 1;
printf("#### DISABLED $test returned 0 and had no failures, known failures, errors or passes.\n");
printf("&&&& PASSED $test\n");
printf("#### WALLTIME $test %.2f [s]\n", $elapsed);
Expand Down
4 changes: 2 additions & 2 deletions testing/async_copy.cu
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <thrust/detail/config.h>

#if THRUST_CPP_DIALECT >= 2011
#if THRUST_CPP_DIALECT >= 2011 && !defined(THRUST_LEGACY_GCC)

#include <unittest/unittest.h>
#include <unittest/util_async.h>
Expand Down Expand Up @@ -338,5 +338,5 @@ DECLARE_GENERIC_SIZED_UNITTEST_WITH_TYPES_AND_NAME(
// TODO: H->D copy, then dependent D->H copy (round trip).
// Can't do this today because we can't do cross-system with explicit policies.

#endif // THRUST_CPP_DIALECT >= 2011
#endif

4 changes: 2 additions & 2 deletions testing/async_for_each.cu
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <thrust/detail/config.h>

#if THRUST_CPP_DIALECT >= 2011
#if THRUST_CPP_DIALECT >= 2011 && !defined(THRUST_LEGACY_GCC)

#include <unittest/unittest.h>

Expand Down Expand Up @@ -95,5 +95,5 @@ DECLARE_GENERIC_SIZED_UNITTEST_WITH_TYPES_AND_NAME(
, test_async_for_each_policy
);

#endif // THRUST_CPP_DIALECT >= 2011
#endif

4 changes: 2 additions & 2 deletions testing/async_reduce.cu
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <thrust/detail/config.h>

#if THRUST_CPP_DIALECT >= 2011
#if THRUST_CPP_DIALECT >= 2011 && !defined(THRUST_LEGACY_GCC)

#include <unittest/unittest.h>
#include <unittest/util_async.h>
Expand Down Expand Up @@ -1132,5 +1132,5 @@ DECLARE_GENERIC_SIZED_UNITTEST_WITH_TYPES(

// TODO: when_all from reductions.

#endif // THRUST_CPP_DIALECT >= 2011
#endif

4 changes: 2 additions & 2 deletions testing/async_reduce_into.cu
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <thrust/detail/config.h>

#if THRUST_CPP_DIALECT >= 2011
#if THRUST_CPP_DIALECT >= 2011 && !defined(THRUST_LEGACY_GCC)

#include <unittest/unittest.h>
#include <unittest/util_async.h>
Expand Down Expand Up @@ -621,5 +621,5 @@ DECLARE_GENERIC_SIZED_UNITTEST_WITH_TYPES_AND_NAME(
, test_async_reduce_into_policy_allocator_on_init_custom_plus
);

#endif // THRUST_CPP_DIALECT >= 2011
#endif

4 changes: 2 additions & 2 deletions testing/async_sort.cu
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <thrust/detail/config.h>

#if THRUST_CPP_DIALECT >= 2011
#if THRUST_CPP_DIALECT >= 2011 && !defined(THRUST_LEGACY_GCC)

#include <unittest/unittest.h>

Expand Down Expand Up @@ -323,5 +323,5 @@ DECLARE_GENERIC_SIZED_UNITTEST_WITH_TYPES_AND_NAME(

// TODO: Test future return type.

#endif // THRUST_CPP_DIALECT >= 2011
#endif

4 changes: 2 additions & 2 deletions testing/async_transform.cu
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <thrust/detail/config.h>

#if THRUST_CPP_DIALECT >= 2011
#if THRUST_CPP_DIALECT >= 2011 && !defined(THRUST_LEGACY_GCC)

#include <unittest/unittest.h>
#include <unittest/util_async.h>
Expand Down Expand Up @@ -529,5 +529,5 @@ DECLARE_GENERIC_SIZED_UNITTEST_WITH_TYPES_AND_NAME(

///////////////////////////////////////////////////////////////////////////////

#endif // THRUST_CPP_DIALECT >= 2011
#endif

28 changes: 28 additions & 0 deletions testing/device_ptr.cu
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,31 @@ void TestRawPointerCast(void)
}
DECLARE_VECTOR_UNITTEST(TestRawPointerCast);


#if THRUST_CPP_DIALECT >= 2011
template<typename T>
void TestDevicePointerNullptrCompatibility()
{
thrust::device_ptr<T> p0(nullptr);

ASSERT_EQUAL_QUIET(nullptr, p0);
ASSERT_EQUAL_QUIET(p0, nullptr);

p0 = nullptr;

ASSERT_EQUAL_QUIET(nullptr, p0);
ASSERT_EQUAL_QUIET(p0, nullptr);
}
DECLARE_GENERIC_UNITTEST(TestDevicePointerNullptrCompatibility);

template<typename T>
void TestDevicePointerBoolConversion()
{
thrust::device_ptr<T> p0(nullptr);
auto const b = bool(p0);

ASSERT_EQUAL_QUIET(false, b);
}
DECLARE_GENERIC_UNITTEST(TestDevicePointerBoolConversion);
#endif

4 changes: 2 additions & 2 deletions testing/event.cu
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <thrust/detail/config.h>

#if THRUST_CPP_DIALECT >= 2011
#if THRUST_CPP_DIALECT >= 2011 && !defined(THRUST_LEGACY_GCC)

#include <unittest/unittest.h>
#include <unittest/util_async.h>
Expand Down Expand Up @@ -178,5 +178,5 @@ DECLARE_UNITTEST(test_event_when_all);

///////////////////////////////////////////////////////////////////////////////

#endif // THRUST_CPP_DIALECT >= 2011
#endif

4 changes: 2 additions & 2 deletions testing/future.cu
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <thrust/detail/config.h>

#if THRUST_CPP_DIALECT >= 2011
#if THRUST_CPP_DIALECT >= 2011 && !defined(THRUST_LEGACY_GCC)

#include <unittest/unittest.h>
#include <unittest/util_async.h>
Expand Down Expand Up @@ -253,5 +253,5 @@ DECLARE_GENERIC_UNITTEST_WITH_TYPES(

///////////////////////////////////////////////////////////////////////////////

#endif // THRUST_CPP_DIALECT >= 2011
#endif

6 changes: 4 additions & 2 deletions thrust/async/copy.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@

#include <thrust/detail/config.h>
#include <thrust/detail/cpp11_required.h>
#include <thrust/detail/modern_gcc_required.h>

#if THRUST_CPP_DIALECT >= 2011
#if THRUST_CPP_DIALECT >= 2011 && !defined(THRUST_LEGACY_GCC)

#include <thrust/detail/static_assert.h>
#include <thrust/detail/select_system.h>
Expand Down Expand Up @@ -141,4 +142,5 @@ THRUST_INLINE_CONSTANT copy_detail::copy_fn copy{};

THRUST_END_NS

#endif // THRUST_CPP_DIALECT >= 2011
#endif

5 changes: 3 additions & 2 deletions thrust/async/for_each.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@

#include <thrust/detail/config.h>
#include <thrust/detail/cpp11_required.h>
#include <thrust/detail/modern_gcc_required.h>

#if THRUST_CPP_DIALECT >= 2011
#if THRUST_CPP_DIALECT >= 2011 && !defined(THRUST_LEGACY_GCC)

#include <thrust/detail/static_assert.h>
#include <thrust/detail/select_system.h>
Expand Down Expand Up @@ -114,5 +115,5 @@ THRUST_INLINE_CONSTANT for_each_detail::for_each_fn for_each{};

THRUST_END_NS

#endif // THRUST_CPP_DIALECT >= 2011
#endif

5 changes: 3 additions & 2 deletions thrust/async/reduce.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@

#include <thrust/detail/config.h>
#include <thrust/detail/cpp11_required.h>
#include <thrust/detail/modern_gcc_required.h>

#if THRUST_CPP_DIALECT >= 2011
#if THRUST_CPP_DIALECT >= 2011 && !defined(THRUST_LEGACY_GCC)

#include <thrust/detail/static_assert.h>
#include <thrust/detail/select_system.h>
Expand Down Expand Up @@ -389,5 +390,5 @@ THRUST_INLINE_CONSTANT reduce_into_detail::reduce_into_fn reduce_into{};

THRUST_END_NS

#endif // THRUST_CPP_DIALECT >= 2011
#endif

5 changes: 3 additions & 2 deletions thrust/async/sort.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@

#include <thrust/detail/config.h>
#include <thrust/detail/cpp11_required.h>
#include <thrust/detail/modern_gcc_required.h>

#if THRUST_CPP_DIALECT >= 2011
#if THRUST_CPP_DIALECT >= 2011 && !defined(THRUST_LEGACY_GCC)

#include <thrust/detail/static_assert.h>
#include <thrust/detail/select_system.h>
Expand Down Expand Up @@ -257,5 +258,5 @@ THRUST_INLINE_CONSTANT sort_detail::sort_fn sort{};

THRUST_END_NS

#endif // THRUST_CPP_DIALECT >= 2011
#endif

5 changes: 3 additions & 2 deletions thrust/async/transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@

#include <thrust/detail/config.h>
#include <thrust/detail/cpp11_required.h>
#include <thrust/detail/modern_gcc_required.h>

#if THRUST_CPP_DIALECT >= 2011
#if THRUST_CPP_DIALECT >= 2011 && !defined(THRUST_LEGACY_GCC)

#include <thrust/detail/static_assert.h>
#include <thrust/detail/select_system.h>
Expand Down Expand Up @@ -129,5 +130,5 @@ THRUST_INLINE_CONSTANT transform_detail::transform_fn transform{};

THRUST_END_NS

#endif // THRUST_CPP_DIALECT >= 2011
#endif

7 changes: 6 additions & 1 deletion thrust/detail/config/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
#elif defined(__GNUC__)
#define THRUST_HOST_COMPILER THRUST_HOST_COMPILER_GCC
#define THRUST_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#if (THRUST_GCC_VERSION >= 50000)
#define THRUST_MODERN_GCC
#else
#define THRUST_LEGACY_GCC
#endif
#else
#define THRUST_HOST_COMPILER THRUST_HOST_COMPILER_UNKNOWN
#endif // THRUST_HOST_COMPILER
Expand Down Expand Up @@ -72,7 +77,7 @@
#define THRUST_DEVICE_COMPILER_IS_OMP_CAPABLE THRUST_FALSE
#endif // _OPENMP

// Disable specific MSVC warnings.

#if (THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC) && !defined(__CUDA_ARCH__)
#define THRUST_DISABLE_MSVC_WARNING_BEGIN(x) \
__pragma(warning(push)) \
Expand Down
6 changes: 4 additions & 2 deletions thrust/detail/event_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@

#include <thrust/detail/config.h>
#include <thrust/detail/cpp11_required.h>
#include <thrust/detail/modern_gcc_required.h>

#if THRUST_CPP_DIALECT >= 2011
#if THRUST_CPP_DIALECT >= 2011 && !defined(THRUST_LEGACY_GCC)

#include <thrust/detail/type_traits.h>
#include <thrust/system/error_code.h>
Expand Down Expand Up @@ -157,4 +158,5 @@ inline bool operator<(event_error const& lhs, event_error const& rhs) noexcept

THRUST_END_NS

#endif // THRUST_CPP_DIALECT >= 2011
#endif

7 changes: 0 additions & 7 deletions thrust/detail/execute_with_dependencies.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,6 @@ extract_dependencies(System &&)
{
return std::tuple<>{};
}
template<typename System>
__host__
std::tuple<>
extract_dependencies(System &)
{
return std::tuple<>{};
}

} // end detail
} // end thrust
Expand Down
26 changes: 26 additions & 0 deletions thrust/detail/modern_gcc_required.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright 2018 NVIDIA Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <thrust/detail/config/cpp_dialect.h>

#ifndef THRUST_MODERN_GCC_REQUIRED_NO_ERROR
# if defined(THRUST_GCC_VERSION) && !defined(THRUST_MODERN_GCC)
# error GCC 5 or later is required for this Thrust feature; please upgrade your compiler.
# endif
#endif

7 changes: 7 additions & 0 deletions thrust/detail/pointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ template<typename Element, typename Tag, typename Reference, typename Derived>

__host__ __device__
Element *get() const;

#if THRUST_CPP_DIALECT >= 2011
// NOTE: This is needed so that Thrust smart pointers can be used in
// `std::unique_ptr`.
__host__ __device__
explicit operator bool() const;
#endif
}; // end pointer

// Output stream operator
Expand Down
13 changes: 13 additions & 0 deletions thrust/detail/pointer.inl
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ template<typename Element, typename Tag, typename Reference, typename Derived>
} // end pointer::operator=
#endif


template<typename Element, typename Tag, typename Reference, typename Derived>
template<typename OtherPointer>
__host__ __device__
Expand Down Expand Up @@ -127,6 +128,18 @@ template<typename Element, typename Tag, typename Reference, typename Derived>
return super_t::base();
} // end pointer::get


#if THRUST_CPP_DIALECT >= 2011
template<typename Element, typename Tag, typename Reference, typename Derived>
__host__ __device__
pointer<Element,Tag,Reference,Derived>
::operator bool() const
{
return bool(get());
} // end pointer::operator bool
#endif


template<typename Element, typename Tag, typename Reference, typename Derived,
typename charT, typename traits>
__host__
Expand Down
Loading

0 comments on commit 395f62b

Please sign in to comment.