Skip to content

Commit

Permalink
Restore MSVC build
Browse files Browse the repository at this point in the history
 * Also add cross-platform deprecation ignore
 * And fix a few warnings
  • Loading branch information
PeterTh committed Dec 15, 2023
1 parent cd229ad commit 1d99af9
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 66 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/simsycl_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false

matrix:
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest, windows-latest, macos-latest]
build_type: [Release, Debug]
c_compiler: [gcc, clang, cl]
include:
Expand All @@ -26,13 +26,20 @@ jobs:
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
- os: macos-latest
c_compiler: clang
cpp_compiler: clang++
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl
- os: macos-latest
c_compiler: cl
- os: macos-latest
c_compiler: gcc

steps:
- uses: actions/checkout@v3
Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ function(set_simsycl_target_options target)
set_target_properties(${target} PROPERTIES CXX_STANDARD 20)
set_target_properties(${target} PROPERTIES CXX_STANDARD_REQUIRED ON)
target_compile_options(${target} PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/W4>
# 4180 is a false positive in MSVC in group_operation_impl -- "fixing" it actually breaks the code
$<$<CXX_COMPILER_ID:MSVC>:/W4 /wd4180>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic $<$<CONFIG:Debug>:-fsanitize=address>>
)
target_link_options(${target} PRIVATE
Expand Down
13 changes: 13 additions & 0 deletions include/simsycl/detail/preprocessor.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

// it is frequently necessary to use deprecated functionality to implment deprecated functionality
// this macro is used to suppress warnings in these cases, in a cross-platform way

#if defined(_MSC_VER)
#define SIMSYCL_START_IGNORING_DEPRECATIONS __pragma(warning(push)) __pragma(warning(disable : 4996))
#define SIMSYCL_STOP_IGNORING_DEPRECATIONS __pragma(warning(pop))
#else
#define SIMSYCL_START_IGNORING_DEPRECATIONS \
_Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
#define SIMSYCL_STOP_IGNORING_DEPRECATIONS _Pragma("GCC diagnostic pop")
#endif
13 changes: 3 additions & 10 deletions include/simsycl/sycl/accessor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
#include <iterator>
#include <limits>


#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" // access::placeholder, access_mode::atomic

// access::placeholder, access_mode::atomic
SIMSYCL_START_IGNORING_DEPRECATIONS

namespace simsycl::detail {

Expand Down Expand Up @@ -930,9 +928,6 @@ class host_accessor<DataT, 0, AccessMode> : public simsycl::detail::property_int

bool empty() const noexcept { return false; }

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" // access_mode::atomic

operator reference() const
requires(AccessMode != access_mode::atomic)
{
Expand All @@ -956,8 +951,6 @@ class host_accessor<DataT, 0, AccessMode> : public simsycl::detail::property_int
return *this;
}

#pragma GCC diagnostic pop

std::add_pointer_t<value_type> get_pointer() const noexcept {
SIMSYCL_CHECK(m_buffer != nullptr);
return m_buffer;
Expand Down Expand Up @@ -985,6 +978,6 @@ class host_accessor<DataT, 0, AccessMode> : public simsycl::detail::property_int
DataT *m_buffer = nullptr;
};

#pragma GCC diagnostic pop
SIMSYCL_STOP_IGNORING_DEPRECATIONS

} // namespace simsycl::sycl
5 changes: 2 additions & 3 deletions include/simsycl/sycl/buffer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ class buffer final
return accessor<T, Dimensions, Mode, Targ>(*this, command_group_handler, access_range, access_offset);
}

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
SIMSYCL_START_IGNORING_DEPRECATIONS

template<access_mode Mode>
[[deprecated]] accessor<T, Dimensions, Mode, target::host_buffer> get_access() {
Expand All @@ -220,7 +219,7 @@ class buffer final
accessor<T, Dimensions, Mode, target::host_buffer>(*this, access_range, access_offset);
}

#pragma GCC diagnostic pop
SIMSYCL_STOP_IGNORING_DEPRECATIONS

template<typename... Ts>
auto get_access(Ts... args) {
Expand Down
8 changes: 5 additions & 3 deletions include/simsycl/sycl/forward.hh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "allocator.hh"
#include "enums.hh"

#include "../detail/preprocessor.hh"

#include <functional>
#include <type_traits>

Expand All @@ -16,15 +18,15 @@ struct system_config;

namespace simsycl::sycl {

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" // access::placeholder
// access::placeholder
SIMSYCL_START_IGNORING_DEPRECATIONS

template<typename DataT, int Dimensions = 1,
access_mode AccessMode = (std::is_const_v<DataT> ? access_mode::read : access_mode::read_write),
target AccessTarget = target::device, access::placeholder IsPlaceholder = access::placeholder::false_t>
class accessor;

#pragma GCC diagnostic pop
SIMSYCL_STOP_IGNORING_DEPRECATIONS

template<typename T, access::address_space AddressSpace = access::address_space::global_space>
class atomic;
Expand Down
8 changes: 3 additions & 5 deletions include/simsycl/sycl/handler.hh
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ void parallel_for(sycl::nd_range<Dimensions> execution_range, const std::vector<

namespace simsycl::sycl {

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" // placeholder
// placeholder
SIMSYCL_START_IGNORING_DEPRECATIONS

class handler {
public:
Expand Down Expand Up @@ -331,7 +331,7 @@ class handler {
template<typename T, int Dim, access_mode Mode, target Tgt, access::placeholder IsPlaceholder>
void fill(accessor<T, Dim, Mode, Tgt, IsPlaceholder> dest, const T &src);

#pragma GCC diagnostic pop
SIMSYCL_STOP_IGNORING_DEPRECATIONS

void use_kernel_bundle(const kernel_bundle<bundle_state::executable> &exec_bundle);

Expand All @@ -350,8 +350,6 @@ class handler {
handler() = default;
};

#pragma GCC diagnostic pop

} // namespace simsycl::sycl

namespace simsycl::detail {
Expand Down
6 changes: 3 additions & 3 deletions include/simsycl/sycl/multi_ptr.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ struct remove_decoration {
template<typename T>
using remove_decoration_t = typename remove_decoration<T>::type;

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" // target::local, ...
// target::local, ...
SIMSYCL_START_IGNORING_DEPRECATIONS

template<typename ElementType, access::address_space Space, access::decorated DecorateAddress>
class multi_ptr {
Expand Down Expand Up @@ -340,6 +340,6 @@ using decorated_local_ptr = multi_ptr<ElementType, access::address_space::local_
template<typename ElementType>
using decorated_private_ptr = multi_ptr<ElementType, access::address_space::private_space, access::decorated::yes>;

#pragma GCC diagnostic pop
SIMSYCL_STOP_IGNORING_DEPRECATIONS

} // namespace simsycl::sycl
5 changes: 2 additions & 3 deletions include/simsycl/sycl/nd_item.hh
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ class nd_item {
return nd_range<Dimensions>(get_global_range(), get_local_range(), m_global_item.get_offset());
}

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
SIMSYCL_START_IGNORING_DEPRECATIONS

[[deprecated("offsets are deprecated in SYCL 2020")]] id<Dimensions> get_offset() const {
return m_global_item.get_offset();
Expand Down Expand Up @@ -129,7 +128,7 @@ class nd_item {
[[deprecated]] device_event async_work_group_copy(
global_ptr<DataT> dest, local_ptr<DataT> src, size_t num_elements, size_t dest_stride) const;

#pragma GCC diagnostic pop
SIMSYCL_STOP_IGNORING_DEPRECATIONS

template<typename DestDataT, typename SrcDataT>
requires(std::is_same_v<DestDataT, std::remove_const_t<SrcDataT>>)
Expand Down
10 changes: 5 additions & 5 deletions include/simsycl/sycl/queue.hh
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ class queue final : public detail::reference_type<queue, detail::queue_state>,

// Explicit copy functions

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" // access::placeholder
// access::placeholder
SIMSYCL_START_IGNORING_DEPRECATIONS

template<typename SrcT, int SrcDims, access_mode SrcMode, target SrcTgt, access::placeholder IsPlaceholder,
typename DestT>
Expand Down Expand Up @@ -312,7 +312,7 @@ class queue final : public detail::reference_type<queue, detail::queue_state>,
template<typename T, int Dims, access_mode Mode, target Tgt, access::placeholder IsPlaceholder>
event fill(accessor<T, Dims, Mode, Tgt, IsPlaceholder> dest, const T &src);

#pragma GCC diagnostic pop
SIMSYCL_STOP_IGNORING_DEPRECATIONS

private:
struct internal_t {
Expand All @@ -321,8 +321,8 @@ class queue final : public detail::reference_type<queue, detail::queue_state>,
explicit queue(internal_t /* tag */, const detail::device_selector &selector, const async_handler &async_handler,
const property_list &prop_list);

explicit queue(internal_t /* tag */, const device &sycl_device,
const async_handler &async_handler, const property_list &prop_list);
explicit queue(internal_t /* tag */, const device &sycl_device, const async_handler &async_handler,
const property_list &prop_list);

explicit queue(internal_t /* tag */, const context &sycl_context, const device &sycl_device,
const async_handler &async_handler, const property_list &prop_list);
Expand Down
37 changes: 13 additions & 24 deletions src/simsycl/device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "simsycl/sycl/range.hh"
#include "simsycl/system.hh"

#include <iterator>

namespace simsycl::detail {

Expand Down Expand Up @@ -163,13 +164,12 @@ uint64_t device::get_info<info::device::max_mem_alloc_size>() const {
return state().config.max_mem_alloc_size;
}

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
SIMSYCL_START_IGNORING_DEPRECATIONS
template<>
bool device::get_info<info::device::image_support>() const {
return state().config.image_support;
}
#pragma GCC diagnostic pop
SIMSYCL_STOP_IGNORING_DEPRECATIONS

template<>
uint32_t device::get_info<info::device::max_read_image_args>() const {
Expand Down Expand Up @@ -260,21 +260,19 @@ uint64_t device::get_info<info::device::global_mem_size>() const {
return state().config.global_mem_size;
}

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
SIMSYCL_START_IGNORING_DEPRECATIONS

template<>
uint64_t device::get_info<info::device::max_constant_buffer_size>() const {
return state().config.max_constant_buffer_size;
}
#pragma GCC diagnostic pop

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
template<>
uint32_t device::get_info<info::device::max_constant_args>() const {
return state().config.max_constant_args;
}
#pragma GCC diagnostic pop

SIMSYCL_STOP_IGNORING_DEPRECATIONS

template<>
info::local_mem_type device::get_info<info::device::local_mem_type>() const {
Expand Down Expand Up @@ -331,42 +329,34 @@ bool device::get_info<info::device::is_available>() const {
return state().config.is_available;
}

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
SIMSYCL_START_IGNORING_DEPRECATIONS

template<>
bool device::get_info<info::device::is_compiler_available>() const {
return state().config.is_compiler_available;
}
#pragma GCC diagnostic pop

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
template<>
bool device::get_info<info::device::is_linker_available>() const {
return state().config.is_linker_available;
}
#pragma GCC diagnostic pop

template<>
std::vector<info::execution_capability> device::get_info<info::device::execution_capabilities>() const {
return state().config.execution_capabilities;
}

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
template<>
bool device::get_info<info::device::queue_profiling>() const {
return state().config.queue_profiling;
}
#pragma GCC diagnostic pop

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
template<>
std::vector<std::string> device::get_info<info::device::built_in_kernels>() const {
return state().config.built_in_kernels;
}
#pragma GCC diagnostic pop

SIMSYCL_STOP_IGNORING_DEPRECATIONS

template<>
std::vector<sycl::kernel_id> device::get_info<info::device::built_in_kernel_ids>() const {
Expand Down Expand Up @@ -413,13 +403,12 @@ std::vector<sycl::aspect> device::get_info<info::device::aspects>() const {
return state().config.aspects;
}

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
SIMSYCL_START_IGNORING_DEPRECATIONS
template<>
std::vector<std::string> device::get_info<info::device::extensions>() const {
return state().config.extensions;
}
#pragma GCC diagnostic pop
SIMSYCL_STOP_IGNORING_DEPRECATIONS

template<>
size_t device::get_info<info::device::printf_buffer_size>() const {
Expand Down
7 changes: 3 additions & 4 deletions src/simsycl/platform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "simsycl/system.hh"

#include <algorithm>

#include <iterator>

namespace simsycl::detail {

Expand Down Expand Up @@ -47,13 +47,12 @@ std::string platform::get_info<info::platform::name>() const {
return state().config.name;
}

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
SIMSYCL_START_IGNORING_DEPRECATIONS
template<>
std::vector<std::string> platform::get_info<info::platform::extensions>() const {
return state().config.extensions;
}
#pragma GCC diagnostic pop
SIMSYCL_STOP_IGNORING_DEPRECATIONS

bool platform::has(aspect asp) const {
return std::all_of(
Expand Down
4 changes: 2 additions & 2 deletions test/group_op_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ TEST_CASE("Group broadcasts behave as expected", "[group_op][broadcast]") {
sycl::queue().submit([&actual](sycl::handler &cgh) {
cgh.parallel_for(sycl::nd_range<1>{8, 4}, [&actual](sycl::nd_item<1> it) {
actual[it.get_global_linear_id()]
= sycl::group_broadcast(it.get_group(), 40 + it.get_global_linear_id(), 2);
= sycl::group_broadcast(it.get_group(), 40 + (int)it.get_global_linear_id(), 2);

check_group_op_sequence(it.get_group(), {detail::group_operation_id::broadcast});
});
Expand All @@ -111,7 +111,7 @@ TEST_CASE("Group broadcasts behave as expected", "[group_op][broadcast]") {
sycl::queue().submit([&actual](sycl::handler &cgh) {
cgh.parallel_for(sycl::nd_range<1>{8, 8}, [&actual](sycl::nd_item<1> it) {
actual[it.get_global_linear_id()]
= sycl::group_broadcast(it.get_sub_group(), 40 + it.get_global_linear_id(), 2);
= sycl::group_broadcast(it.get_sub_group(), 40 + (int)it.get_global_linear_id(), 2);

check_group_op_sequence(it.get_sub_group(), {detail::group_operation_id::broadcast});
});
Expand Down
Loading

0 comments on commit 1d99af9

Please sign in to comment.