Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions clang/examples/DPCT/Thrust/thrust$$count.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <thrust/device_malloc.h>
#include <thrust/device_vector.h>
#include <thrust/execution_policy.h>
#include <thrust/functional.h>
#include <thrust/host_vector.h>
#include <thrust/logical.h>
#include <thrust/partition.h>
#include <thrust/set_operations.h>
#include <thrust/sort.h>
#include <thrust/unique.h>

void count_test() {
// clang-format off
// Start
std::vector<int> v;
/*1*/ thrust::count(thrust::seq, v.begin(), v.end(), 23);
/*2*/ thrust::count(v.begin(), v.end(), 23);
// End
// clang-format on
}
18 changes: 18 additions & 0 deletions clang/examples/DPCT/Thrust/thrust$$get_temporary_buffer.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <thrust/device_delete.h>
#include <thrust/device_malloc.h>
#include <thrust/device_new.h>
#include <thrust/device_vector.h>
#include <thrust/execution_policy.h>
#include <thrust/memory.h>

void get_temporary_buffer_test() {

// clang-format off
// Start
const int N = 100;
typedef thrust::pair<thrust::pointer<int, thrust::device_system_tag>, std::ptrdiff_t> ptr_and_size_t;
thrust::device_system_tag device_sys;
ptr_and_size_t ptr_and_size = thrust::get_temporary_buffer<int>(device_sys, N);
// End
// clang-format on
}
19 changes: 19 additions & 0 deletions clang/examples/DPCT/Thrust/thrust$$sort.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <thrust/device_vector.h>
#include <thrust/execution_policy.h>
#include <thrust/functional.h>
#include <thrust/host_vector.h>
#include <thrust/partition.h>
#include <thrust/set_operations.h>
#include <thrust/sort.h>
#include <thrust/unique.h>

void sort_test() {
// clang-format off
// Start
thrust::host_vector<int> h_vec(10);
thrust::device_vector<int> d_vec(10);
/*1*/ thrust::sort(h_vec.begin(), h_vec.end());
/*2*/ thrust::sort(thrust::device, d_vec.begin(), d_vec.end());
// End
// clang-format on
}
36 changes: 36 additions & 0 deletions clang/test/dpct/query_api_mapping/Thrust/thrust_api_test_p3.cu
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,39 @@
// thrust_make_zip_iterator-NEXT: typedef dpct::device_vector<float>::iterator float_iterator;
// thrust_make_zip_iterator-NEXT: typedef std::tuple<int_iterator, float_iterator> iterator_tuple;
// thrust_make_zip_iterator-NEXT: dpct::zip_iterator<iterator_tuple> ret = oneapi::dpl::make_zip_iterator(std::make_tuple(int_in.begin(), float_in.begin()));

// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=thrust::count --extra-arg="-std=c++14"| FileCheck %s -check-prefix=thrust_count
// thrust_count: CUDA API:
// thrust_count-NEXT: std::vector<int> v;
// thrust_count-NEXT: /*1*/ thrust::count(thrust::seq, v.begin(), v.end(), 23);
// thrust_count-NEXT: /*2*/ thrust::count(v.begin(), v.end(), 23);
// thrust_count-NEXT: Is migrated to:
// thrust_count-NEXT: std::vector<int> v;
// thrust_count-NEXT: /*1*/ std::count(oneapi::dpl::execution::seq, v.begin(), v.end(), 23);
// thrust_count-NEXT: /*2*/ std::count(oneapi::dpl::execution::seq, v.begin(), v.end(), 23);

// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=thrust::sort --extra-arg="-std=c++14"| FileCheck %s -check-prefix=thrust_sort
// thrust_sort: CUDA API:
// thrust_sort-NEXT: thrust::host_vector<int> h_vec(10);
// thrust_sort-NEXT: thrust::device_vector<int> d_vec(10);
// thrust_sort-NEXT: /*1*/ thrust::sort(h_vec.begin(), h_vec.end());
// thrust_sort-NEXT: /*2*/ thrust::sort(thrust::device, d_vec.begin(), d_vec.end());
// thrust_sort-NEXT: Is migrated to:
// thrust_sort-NEXT: std::vector<int> h_vec(10);
// thrust_sort-NEXT: dpct::device_vector<int> d_vec(10);
// thrust_sort-NEXT: /*1*/ oneapi::dpl::sort(oneapi::dpl::execution::seq, h_vec.begin(), h_vec.end());
// thrust_sort-NEXT: /*2*/ oneapi::dpl::sort(oneapi::dpl::execution::make_device_policy(q_ct1), d_vec.begin(), d_vec.end());

// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=thrust::get_temporary_buffer --extra-arg="-std=c++14"| FileCheck %s -check-prefix=thrust_get_temporary_buffer
// thrust_get_temporary_buffer: CUDA API:
// thrust_get_temporary_buffer-NEXT: const int N = 100;
// thrust_get_temporary_buffer-NEXT: typedef thrust::pair<thrust::pointer<int, thrust::device_system_tag>, std::ptrdiff_t> ptr_and_size_t;
// thrust_get_temporary_buffer-NEXT: thrust::device_system_tag device_sys;
// thrust_get_temporary_buffer-NEXT: ptr_and_size_t ptr_and_size = thrust::get_temporary_buffer<int>(device_sys, N);
// thrust_get_temporary_buffer-NEXT: Is migrated to:
// thrust_get_temporary_buffer-NEXT: const int N = 100;
// thrust_get_temporary_buffer-NEXT: typedef std::pair<dpct::tagged_pointer<int, dpct::device_sys_tag>, std::ptrdiff_t> ptr_and_size_t;
// thrust_get_temporary_buffer-NEXT: dpct::device_sys_tag device_sys;
// thrust_get_temporary_buffer-NEXT: ptr_and_size_t ptr_and_size = dpct::get_temporary_allocation<int>(device_sys, N);


3 changes: 3 additions & 0 deletions clang/test/dpct/query_api_mapping/test_all.cu
Original file line number Diff line number Diff line change
Expand Up @@ -2424,6 +2424,7 @@
// CHECK-NEXT: thrust::copy_n
// CHECK-NEXT: thrust::cos
// CHECK-NEXT: thrust::cosh
// CHECK-NEXT: thrust::count
// CHECK-NEXT: thrust::count_if
// CHECK-NEXT: thrust::device_delete
// CHECK-NEXT: thrust::device_free
Expand All @@ -2450,6 +2451,7 @@
// CHECK-NEXT: thrust::generate
// CHECK-NEXT: thrust::generate_n
// CHECK-NEXT: thrust::get
// CHECK-NEXT: thrust::get_temporary_buffer
// CHECK-NEXT: thrust::inclusive_scan
// CHECK-NEXT: thrust::inclusive_scan_by_key
// CHECK-NEXT: thrust::inner_product
Expand Down Expand Up @@ -2513,6 +2515,7 @@
// CHECK-NEXT: thrust::set_union_by_key
// CHECK-NEXT: thrust::sin
// CHECK-NEXT: thrust::sinh
// CHECK-NEXT: thrust::sort
// CHECK-NEXT: thrust::sort_by_key
// CHECK-NEXT: thrust::sqrt
// CHECK-NEXT: thrust::stable_partition
Expand Down
Loading