Skip to content

Commit 7f846f4

Browse files
authored
updated makefiles and README (#1630)
Signed-off-by: ShwethaSelma <shwethasshetty27@gmail.com>
1 parent cc85129 commit 7f846f4

File tree

11 files changed

+76
-31
lines changed

11 files changed

+76
-31
lines changed

DirectProgramming/C++SYCL/StructuredGrids/guided_HSOpticalflow_SYCLMigration/02_sycl_dpct_migrated/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ include_directories(${CMAKE_SOURCE_DIR}/02_sycl_dpct_migrated/Common/)
55
add_executable (02_sycl_dpct_migrated src/main.cpp src/flowGold.cpp src/flowSYCL.cpp)
66
target_link_libraries(02_sycl_dpct_migrated sycl)
77

8-
add_custom_target (run_sdm_cpu cd ${CMAKE_SOURCE_DIR}/02_sycl_dpct_migrated/ && ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/02_sycl_dpct_migrated)
9-
add_custom_target (run_sdm_gpu SYCL_DEVICE_FILTER=gpu cd ${CMAKE_SOURCE_DIR}/02_sycl_dpct_migrated/ && ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/02_sycl_dpct_migrated)
8+
add_custom_target (run_sdm cd ${CMAKE_SOURCE_DIR}/02_sycl_dpct_migrated/ && ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/02_sycl_dpct_migrated)

DirectProgramming/C++SYCL/StructuredGrids/guided_HSOpticalflow_SYCLMigration/02_sycl_dpct_migrated/src/flowSYCL.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@
4444
#include "upscaleKernel.hpp"
4545
#include "warpingKernel.hpp"
4646

47+
// custom device selector to pick device that supports sycl::image
48+
int sycl_image_support(const sycl::device& d ) {
49+
if(d.get_info<info::device::image_support>() == false){
50+
std::cout << d.get_info<info::device::name>() << " ==> Image Support = NO\n";
51+
} else {
52+
std::cout << d.get_info<info::device::name>() << " ==> Image Support = YES\n";
53+
}
54+
return d.get_info<info::device::image_support>();
55+
}
56+
4757
///////////////////////////////////////////////////////////////////////////////
4858
/// \brief method logic
4959
///
@@ -73,11 +83,11 @@ void ComputeFlowSYCL(const float *I0, const float *I1, int width, int height,
7383
}
7484
}
7585
};
76-
77-
dpct::device_ext &dev_ct1 = dpct::get_current_device();
78-
sycl::queue &q_ct1 = dev_ct1.default_queue();
79-
80-
printf("Computing optical flow on GPU...\n");
86+
87+
sycl::device preferred_device { sycl_image_support };
88+
sycl::queue q_ct1(preferred_device, exception_handler, property::queue::in_order());
89+
90+
printf("Computing optical flow on Device...\n");
8191
std::cout << "\nRunning on "
8292
<< q_ct1.get_device().get_info<sycl::info::device::name>() << "\n";
8393

DirectProgramming/C++SYCL/StructuredGrids/guided_HSOpticalflow_SYCLMigration/02_sycl_dpct_migrated/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ int main(int argc, char **argv) {
241241
auto SYCL_duration =
242242
std::chrono::duration_cast<float_ms>(stopSYCLTime - startSYCLTime)
243243
.count();
244-
printf("Processing time on GPU: %f (ms)\n", SYCL_duration);
244+
printf("Processing time on Device: %f (ms)\n", SYCL_duration);
245245

246246
// compare results (L1 norm)
247247
bool status =

DirectProgramming/C++SYCL/StructuredGrids/guided_HSOpticalflow_SYCLMigration/03_sycl_migrated/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ include_directories(${CMAKE_SOURCE_DIR}/03_sycl_migrated/Common/)
55
add_executable (03_sycl_migrated src/main.cpp src/flowGold.cpp src/flowSYCL.cpp)
66
target_link_libraries(03_sycl_migrated sycl)
77

8-
add_custom_target (run_cpu cd ${CMAKE_SOURCE_DIR}/03_sycl_migrated/ && ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/03_sycl_migrated)
9-
add_custom_target (run_gpu SYCL_DEVICE_FILTER=gpu cd ${CMAKE_SOURCE_DIR}/03_sycl_migrated/ && ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/03_sycl_migrated)
8+
add_custom_target (run cd ${CMAKE_SOURCE_DIR}/03_sycl_migrated/ && ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/03_sycl_migrated)

DirectProgramming/C++SYCL/StructuredGrids/guided_HSOpticalflow_SYCLMigration/03_sycl_migrated/src/flowSYCL.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@
4343
#include "upscaleKernel.hpp"
4444
#include "warpingKernel.hpp"
4545

46+
// custom device selector to pick device that supports sycl::image
47+
int sycl_image_support(const sycl::device& d ) {
48+
if(d.get_info<info::device::image_support>() == false){
49+
std::cout << d.get_info<info::device::name>() << " ==> Image Support = NO\n";
50+
} else {
51+
std::cout << d.get_info<info::device::name>() << " ==> Image Support = YES\n";
52+
}
53+
return d.get_info<info::device::image_support>();
54+
}
55+
4656
///////////////////////////////////////////////////////////////////////////////
4757
/// \brief method logic
4858
///
@@ -72,9 +82,11 @@ void ComputeFlowSYCL(const float *I0, const float *I1, int width, int height,
7282
}
7383
}
7484
};
75-
76-
queue q{default_selector_v, exception_handler, property::queue::in_order()};
77-
printf("Computing optical flow on GPU...\n");
85+
86+
sycl::device preferred_device { sycl_image_support };
87+
sycl::queue q(preferred_device, exception_handler, property::queue::in_order());
88+
89+
printf("Computing optical flow on Device...\n");
7890
std::cout << "\nRunning on "
7991
<< q.get_device().get_info<sycl::info::device::name>() << "\n";
8092

DirectProgramming/C++SYCL/StructuredGrids/guided_HSOpticalflow_SYCLMigration/03_sycl_migrated/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ int main(int argc, char **argv) {
241241
auto SYCL_duration =
242242
std::chrono::duration_cast<float_ms>(stopSYCLTime - startSYCLTime)
243243
.count();
244-
printf("Processing time on GPU: %f (ms)\n", SYCL_duration);
244+
printf("Processing time on Device: %f (ms)\n", SYCL_duration);
245245

246246
// compare results (L1 norm)
247247
bool status =

DirectProgramming/C++SYCL/StructuredGrids/guided_HSOpticalflow_SYCLMigration/04_sycl_migrated_optimized/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ include_directories(${CMAKE_SOURCE_DIR}/04_sycl_migrated_optimized/Common/)
55
add_executable (04_sycl_migrated_optimized src/main.cpp src/flowGold.cpp src/flowSYCL.cpp)
66
target_link_libraries(04_sycl_migrated_optimized sycl)
77

8-
add_custom_target (run_smo_cpu cd ${CMAKE_SOURCE_DIR}/04_sycl_migrated_optimized/ && ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/04_sycl_migrated_optimized)
9-
add_custom_target (run_smo_gpu SYCL_DEVICE_FILTER=gpu cd ${CMAKE_SOURCE_DIR}/04_sycl_migrated_optimized/ && ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/04_sycl_migrated_optimized)
8+
add_custom_target (run_smo cd ${CMAKE_SOURCE_DIR}/04_sycl_migrated_optimized/ && ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/04_sycl_migrated_optimized)

DirectProgramming/C++SYCL/StructuredGrids/guided_HSOpticalflow_SYCLMigration/04_sycl_migrated_optimized/src/flowSYCL.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@
4343
#include "upscaleKernel.hpp"
4444
#include "warpingKernel.hpp"
4545

46+
// custom device selector to pick device that supports sycl::image
47+
int sycl_image_support(const sycl::device& d ) {
48+
if(d.get_info<info::device::image_support>() == false){
49+
std::cout << d.get_info<info::device::name>() << " ==> Image Support = NO\n";
50+
} else {
51+
std::cout << d.get_info<info::device::name>() << " ==> Image Support = YES\n";
52+
}
53+
return d.get_info<info::device::image_support>();
54+
}
55+
4656
///////////////////////////////////////////////////////////////////////////////
4757
/// \brief method logic
4858
///
@@ -73,8 +83,10 @@ void ComputeFlowSYCL(const float *I0, const float *I1, int width, int height,
7383
}
7484
};
7585

76-
queue q{default_selector_v, exception_handler, property::queue::in_order()};
77-
printf("Computing optical flow on GPU...\n");
86+
sycl::device preferred_device { sycl_image_support };
87+
sycl::queue q(preferred_device, exception_handler, property::queue::in_order());
88+
89+
printf("Computing optical flow on Device...\n");
7890
std::cout << "\nRunning on "
7991
<< q.get_device().get_info<sycl::info::device::name>() << "\n";
8092

DirectProgramming/C++SYCL/StructuredGrids/guided_HSOpticalflow_SYCLMigration/04_sycl_migrated_optimized/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ int main(int argc, char **argv) {
241241
auto SYCL_duration =
242242
std::chrono::duration_cast<float_ms>(stopSYCLTime - startSYCLTime)
243243
.count();
244-
printf("Processing time on GPU: %f (ms)\n", SYCL_duration);
244+
printf("Processing time on Device: %f (ms)\n", SYCL_duration);
245245

246246
// compare results (L1 norm)
247247
bool status =

DirectProgramming/C++SYCL/StructuredGrids/guided_HSOpticalflow_SYCLMigration/README.md

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,22 +100,37 @@ If you receive an error message, troubleshoot the problem using the **Diagnostic
100100

101101
You can run the programs for CPU and GPU. The commands indicate the device target.
102102

103-
1. Run `02_sycl_dpct_migrated` for CPU and GPU.
103+
1. Run `02_sycl_dpct_migrated` for GPU.
104104
```
105-
make run_sdm_cpu
106-
make run_sdm_gpu
105+
make run_sdm
106+
```
107+
Run `02_sycl_dpct_migrated` for CPU.
108+
```
109+
export SYCL_DEVICE_FILTER=cpu
110+
make run_sdm
111+
unset SYCL_DEVICE_FILTER
107112
```
108113
109-
2. Run `03_sycl_migrated` for CPU and GPU.
114+
2. Run `03_sycl_migrated` for GPU.
115+
```
116+
make run
110117
```
111-
make run_cpu
112-
make run_gpu
118+
Run `03_sycl_migrated` for CPU.
119+
```
120+
export SYCL_DEVICE_FILTER=cpu
121+
make run
122+
unset SYCL_DEVICE_FILTER
113123
```
114124
115-
3. Run `04_sycl_migrated_optimized` for CPU and GPU.
125+
3. Run `04_sycl_migrated_optimized` for GPU.
126+
```
127+
make run_smo
128+
```
129+
Run `04_sycl_migrated_optimized` for CPU.
116130
```
117-
make run_smo_cpu
118-
make run_smo_gpu
131+
export SYCL_DEVICE_FILTER=cpu
132+
make run_smo
133+
unset SYCL_DEVICE_FILTER
119134
```
120135
121136
### Build and Run the `HSOpticalFlow` Sample in Intel® DevCloud

0 commit comments

Comments
 (0)