Skip to content

Commit

Permalink
change dpcpp to sycl
Browse files Browse the repository at this point in the history
  • Loading branch information
yhmtsai committed Aug 22, 2023
1 parent 9eea078 commit 7d22222
Show file tree
Hide file tree
Showing 115 changed files with 856 additions and 837 deletions.
4 changes: 2 additions & 2 deletions benchmark/utils/dpcpp_linops.dp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ class OnemklBase : public gko::LinOp {
return this->mat_handle_.get();
}

std::shared_ptr<const gko::DpcppExecutor> get_device_exec() const
std::shared_ptr<const gko::SyclExecutor> get_device_exec() const
{
return std::dynamic_pointer_cast<const gko::DpcppExecutor>(
return std::dynamic_pointer_cast<const gko::SyclExecutor>(
this->get_executor());
}

Expand Down
28 changes: 14 additions & 14 deletions benchmark/utils/dpcpp_timer.dp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


/**
* DpcppTimer uses dpcpp executor and event to measure the timing.
* SyclTimer uses sycl executor and event to measure the timing.
*/
class DpcppTimer : public Timer {
class SyclTimer : public Timer {
public:
/**
* Create a DpcppTimer.
* Create a SyclTimer.
*
* @param exec Executor which should be a DpcppExecutor
* @param exec Executor which should be a SyclExecutor
*/
DpcppTimer(std::shared_ptr<const gko::Executor> exec)
: DpcppTimer(std::dynamic_pointer_cast<const gko::DpcppExecutor>(exec))
SyclTimer(std::shared_ptr<const gko::Executor> exec)
: SyclTimer(std::dynamic_pointer_cast<const gko::SyclExecutor>(exec))
{}

/**
* Create a DpcppTimer.
* Create a SyclTimer.
*
* @param exec DpcppExecutor associated to the timer
* @param exec SyclExecutor associated to the timer
*/
DpcppTimer(std::shared_ptr<const gko::DpcppExecutor> exec) : Timer()
SyclTimer(std::shared_ptr<const gko::SyclExecutor> exec) : Timer()
{
assert(exec != nullptr);
if (!exec->get_queue()
Expand All @@ -73,7 +73,7 @@ class DpcppTimer : public Timer {
void tic_impl() override
{
exec_->synchronize();
// Currently, gko::DpcppExecutor always use default stream.
// Currently, gko::SyclExecutor always use default stream.
start_ = exec_->get_queue()->submit([&](sycl::handler& cgh) {
cgh.parallel_for(1, [=](sycl::id<1> id) {});
});
Expand All @@ -96,14 +96,14 @@ class DpcppTimer : public Timer {
}

private:
std::shared_ptr<const gko::DpcppExecutor> exec_;
std::shared_ptr<const gko::SyclExecutor> exec_;
sycl::event start_;
int id_;
};


std::shared_ptr<Timer> get_dpcpp_timer(
std::shared_ptr<const gko::DpcppExecutor> exec)
std::shared_ptr<Timer> get_sycl_timer(
std::shared_ptr<const gko::SyclExecutor> exec)
{
return std::make_shared<DpcppTimer>(exec);
return std::make_shared<SyclTimer>(exec);
}
5 changes: 2 additions & 3 deletions benchmark/utils/formats.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,8 @@ std::shared_ptr<csr::strategy_type> create_gpu_strategy(
return std::make_shared<Strategy>(cuda->shared_from_this());
} else if (auto hip = dynamic_cast<const gko::HipExecutor*>(exec.get())) {
return std::make_shared<Strategy>(hip->shared_from_this());
} else if (auto dpcpp =
dynamic_cast<const gko::DpcppExecutor*>(exec.get())) {
return std::make_shared<Strategy>(dpcpp->shared_from_this());
} else if (auto sycl = dynamic_cast<const gko::SyclExecutor*>(exec.get())) {
return std::make_shared<Strategy>(sycl->shared_from_this());
} else {
return std::make_shared<csr::classical>();
}
Expand Down
24 changes: 12 additions & 12 deletions benchmark/utils/general.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,13 +389,13 @@ const std::map<std::string, std::function<std::shared_ptr<gko::Executor>(bool)>>
gko::OmpExecutor::create(),
create_hip_allocator());
}},
{"dpcpp", [](bool use_gpu_timer) {
auto property = dpcpp_queue_property::in_order;
{"sycl", [](bool use_gpu_timer) {
auto property = gko::sycl_queue_property::in_order;
if (use_gpu_timer) {
property = dpcpp_queue_property::in_order |
dpcpp_queue_property::enable_profiling;
property = gko::sycl_queue_property::in_order |
gko::sycl_queue_property::enable_profiling;
}
return gko::DpcppExecutor::create(
return gko::SyclExecutor::create(
FLAGS_device_id, gko::OmpExecutor::create(), "all", property);
}}};

Expand Down Expand Up @@ -425,20 +425,20 @@ const std::map<std::string,
gko::ReferenceExecutor::create(),
create_hip_allocator());
}},
{"dpcpp", [](MPI_Comm comm) {
if (gko::DpcppExecutor::get_num_devices("gpu")) {
{"sycl", [](MPI_Comm comm) {
if (gko::SyclExecutor::get_num_devices("gpu")) {
FLAGS_device_id =
gko::experimental::mpi::map_rank_to_device_id(
comm, gko::DpcppExecutor::get_num_devices("gpu"));
} else if (gko::DpcppExecutor::get_num_devices("cpu")) {
comm, gko::SyclExecutor::get_num_devices("gpu"));
} else if (gko::SyclExecutor::get_num_devices("cpu")) {
FLAGS_device_id =
gko::experimental::mpi::map_rank_to_device_id(
comm, gko::DpcppExecutor::get_num_devices("cpu"));
comm, gko::SyclExecutor::get_num_devices("cpu"));
} else {
GKO_NOT_IMPLEMENTED;
}
return gko::DpcppExecutor::create(
FLAGS_device_id, gko::ReferenceExecutor::create());
return gko::SyclExecutor::create(FLAGS_device_id,
gko::ReferenceExecutor::create());
}}};


Expand Down
12 changes: 6 additions & 6 deletions benchmark/utils/timer_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ std::shared_ptr<Timer> get_hip_timer(


#ifdef HAS_DPCPP_TIMER
std::shared_ptr<Timer> get_dpcpp_timer(
std::shared_ptr<const gko::DpcppExecutor> exec);
std::shared_ptr<Timer> get_sycl_timer(
std::shared_ptr<const gko::SyclExecutor> exec);
#endif // HAS_DPCPP_TIMER


Expand Down Expand Up @@ -278,13 +278,13 @@ inline std::shared_ptr<Timer> get_timer(
#endif // HAS_HIP_TIMER

#ifdef HAS_DPCPP_TIMER
if (auto dpcpp =
std::dynamic_pointer_cast<const gko::DpcppExecutor>(exec)) {
return get_dpcpp_timer(dpcpp);
if (auto sycl =
std::dynamic_pointer_cast<const gko::SyclExecutor>(exec)) {
return get_sycl_timer(sycl);
}
#endif // HAS_DPCPP_TIMER
}
// No cuda/hip/dpcpp executor available or no gpu_timer used
// No cuda/hip/sycl executor available or no gpu_timer used
return std::make_shared<CpuTimer>(exec);
}

Expand Down
2 changes: 1 addition & 1 deletion cmake/create_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ function(ginkgo_create_common_device_test test_name)
cmake_parse_arguments(PARSE_ARGV 1 common_device_test "" "${gko_test_single_args}" "${gko_test_multi_args}")
ginkgo_build_test_name(${test_name} test_target_name)
if(GINKGO_BUILD_SYCL)
ginkgo_create_common_test_internal(${test_name} DpcppExecutor dpcpp ${ARGN})
ginkgo_create_common_test_internal(${test_name} SyclExecutor dpcpp ${ARGN})
target_compile_features(${test_target_name}_dpcpp PRIVATE cxx_std_17)
target_compile_options(${test_target_name}_dpcpp PRIVATE ${GINKGO_DPCPP_FLAGS})
# We need to use a new file to avoid sycl setting in other backends because add_sycl_to_target will change the source property.
Expand Down
2 changes: 1 addition & 1 deletion common/unified/base/kernel_launch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ GKO_INLINE GKO_ATTRIBUTES constexpr unpack_member_type<T> unpack_member(T value)

#elif defined(GKO_COMPILING_DPCPP)

#define GKO_DEVICE_NAMESPACE dpcpp
#define GKO_DEVICE_NAMESPACE sycl
#define GKO_KERNEL


Expand Down
2 changes: 1 addition & 1 deletion common/unified/distributed/partition_helpers_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void check_consecutive_ranges(std::shared_ptr<const DefaultExecutor> exec,
{
array<uint32> result_uint32{exec, 1};
auto num_ranges = range_start_ends.get_num_elems() / 2;
// need additional guard because DPCPP doesn't return the initial value for
// need additional guard because SYCL doesn't return the initial value for
// empty inputs
if (num_ranges > 1) {
run_kernel_reduction(
Expand Down
2 changes: 1 addition & 1 deletion core/base/executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void Operation::run(std::shared_ptr<const HipExecutor> executor) const
GKO_NOT_IMPLEMENTED;


void Operation::run(std::shared_ptr<const DpcppExecutor> executor) const
void Operation::run(std::shared_ptr<const SyclExecutor> executor) const
GKO_NOT_IMPLEMENTED;


Expand Down
2 changes: 1 addition & 1 deletion core/base/noop_scoped_device_id_guard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace detail {
/**
* An implementation of generic_scoped_device_id_guard that does nothing.
*
* This is used for OmpExecutor and DpcppExecutor, since they don't require
* This is used for OmpExecutor and SyclExecutor, since they don't require
* setting a device id.
*/
class noop_scoped_device_id_guard : public generic_scoped_device_id_guard {};
Expand Down
10 changes: 5 additions & 5 deletions core/base/timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ time_point::~time_point()
case type::hip:
kernels::hip::destroy_event(data_.hip_event);
break;
case type::dpcpp:
kernels::dpcpp::destroy_event(data_.dpcpp_event);
case type::sycl:
kernels::sycl::destroy_event(data_.sycl_event);
break;
case type::cpu:
default:
Expand Down Expand Up @@ -137,9 +137,9 @@ std::unique_ptr<Timer> Timer::create_for_executor(
} else if (auto hip_exec =
std::dynamic_pointer_cast<const HipExecutor>(exec)) {
return std::make_unique<HipTimer>(hip_exec);
} else if (auto dpcpp_exec =
std::dynamic_pointer_cast<const DpcppExecutor>(exec)) {
return std::make_unique<DpcppTimer>(dpcpp_exec);
} else if (auto sycl_exec =
std::dynamic_pointer_cast<const SyclExecutor>(exec)) {
return std::make_unique<SyclTimer>(sycl_exec);
} else {
return std::make_unique<CpuTimer>();
}
Expand Down
4 changes: 2 additions & 2 deletions core/base/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ std::ostream& operator<<(std::ostream& os, const version_info& ver_info)
print_version(os, ver_info.cuda_version);
os << "\n the HIP module is ";
print_version(os, ver_info.hip_version);
os << "\n the DPCPP module is ";
print_version(os, ver_info.dpcpp_version);
os << "\n the SYCL module is ";
print_version(os, ver_info.sycl_version);
return os;
}

Expand Down
2 changes: 1 addition & 1 deletion core/device_hooks/cuda_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void CudaExecutor::raw_copy_to(const HipExecutor*, size_type num_bytes,
GKO_NOT_COMPILED(cuda);


void CudaExecutor::raw_copy_to(const DpcppExecutor*, size_type num_bytes,
void CudaExecutor::raw_copy_to(const SyclExecutor*, size_type num_bytes,
const void* src_ptr, void* dest_ptr) const
GKO_NOT_COMPILED(cuda);

Expand Down
Loading

0 comments on commit 7d22222

Please sign in to comment.