Skip to content

Commit 4fa62ad

Browse files
QuasirandomGenerator Sample (#1645)
* Updated sample.json and Makefile Signed-off-by: ManjulaChalla <manjula.challa98@gmail.com> * Update README.md * Update README.md * Update README.md * Updated print statements --------- Signed-off-by: ManjulaChalla <manjula.challa98@gmail.com>
1 parent 39f2389 commit 4fa62ad

File tree

5 files changed

+34
-16
lines changed

5 files changed

+34
-16
lines changed

DirectProgramming/C++SYCL/MapReduce/guided_quasirandomGenerator_SYCLMigration/01_dpct_output/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ include_directories(${CMAKE_SOURCE_DIR}/01_dpct_output/include/)
66
add_executable (01_dpct_output Samples/5_Domain_Specific/quasirandomGenerator/quasirandomGenerator.cpp.dp.cpp Samples/5_Domain_Specific/quasirandomGenerator/quasirandomGenerator_gold.cpp Samples/5_Domain_Specific/quasirandomGenerator/quasirandomGenerator_kernel.dp.cpp)
77
target_link_libraries(01_dpct_output sycl)
88

9-
add_custom_target (run_cpu cd ${CMAKE_SOURCE_DIR}/01_dpct_output/ && ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/01_dpct_output)
10-
add_custom_target (run_gpu SYCL_DEVICE_FILTER=gpu cd ${CMAKE_SOURCE_DIR}/01_dpct_output/ && ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/01_dpct_output)
9+
add_custom_target (run cd ${CMAKE_SOURCE_DIR}/01_dpct_output/ && ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/01_dpct_output)

DirectProgramming/C++SYCL/MapReduce/guided_quasirandomGenerator_SYCLMigration/01_dpct_output/Samples/5_Domain_Specific/quasirandomGenerator/quasirandomGenerator.cpp.dp.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ const int N = 1048576;
6363
int main(int argc, char **argv) {
6464
// Start logs
6565
printf("%s Starting...\n\n", argv[0]);
66-
66+
std::cout << "\nRunning on "
67+
<< dpct::get_default_queue().get_device().get_info<sycl::info::device::name>() << "\n";
6768
unsigned int tableCPU[QRNG_DIMENSIONS][QRNG_RESOLUTION];
6869

6970
float *h_OutputGPU, *d_Output;
@@ -80,7 +81,7 @@ int main(int argc, char **argv) {
8081

8182
sdkCreateTimer(&hTimer);
8283

83-
printf("Allocating GPU memory...\n");
84+
printf("Allocating Device memory...\n");
8485
/*
8586
DPCT1003:21: Migrated API does not return error code. (*, 0) is inserted. You
8687
may need to rewrite this code.
@@ -135,7 +136,7 @@ int main(int argc, char **argv) {
135136
(double)QRNG_DIMENSIONS * (double)N * 1.0E-9 / gpuTime, gpuTime,
136137
QRNG_DIMENSIONS * N, 1, 128 * QRNG_DIMENSIONS);
137138

138-
printf("\nReading GPU results...\n");
139+
printf("\nReading Device results...\n");
139140
/*
140141
DPCT1003:25: Migrated API does not return error code. (*, 0) is inserted. You
141142
may need to rewrite this code.
@@ -197,7 +198,7 @@ int main(int argc, char **argv) {
197198
(double)QRNG_DIMENSIONS * (double)N * 1E-9 / gpuTime, gpuTime,
198199
QRNG_DIMENSIONS * N, 1, 128);
199200

200-
printf("Reading GPU results...\n");
201+
printf("Reading Device results...\n");
201202
/*
202203
DPCT1003:29: Migrated API does not return error code. (*, 0) is inserted. You
203204
may need to rewrite this code.

DirectProgramming/C++SYCL/MapReduce/guided_quasirandomGenerator_SYCLMigration/02_sycl_migrated_optimized/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ include_directories(${CMAKE_SOURCE_DIR}/02_sycl_migrated_optimized/include/)
66
add_executable(02_sycl_migrated_optimized Samples/5_Domain_Specific/quasirandomGenerator/quasirandomGenerator.cpp.dp.cpp Samples/5_Domain_Specific/quasirandomGenerator/quasirandomGenerator_gold.cpp Samples/5_Domain_Specific/quasirandomGenerator/quasirandomGenerator_kernel.dp.cpp)
77
target_link_libraries(02_sycl_migrated_optimized sycl)
88

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

DirectProgramming/C++SYCL/MapReduce/guided_quasirandomGenerator_SYCLMigration/02_sycl_migrated_optimized/Samples/5_Domain_Specific/quasirandomGenerator/quasirandomGenerator.cpp.dp.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ int main(int argc, char **argv) {
6464
// Start logs
6565
sycl::queue q_ct1 = sycl::queue(sycl::default_selector_v);
6666
printf("%s Starting...\n\n", argv[0]);
67-
67+
std::cout << "\nRunning on " << q_ct1.get_device().get_info<info::device::name>()
68+
<< "\n";
6869
unsigned int tableCPU[QRNG_DIMENSIONS][QRNG_RESOLUTION];
6970

7071
float *h_OutputGPU, *d_Output;
@@ -121,7 +122,7 @@ int main(int argc, char **argv) {
121122
(double)QRNG_DIMENSIONS * (double)N * 1.0E-9 / gpuTime, gpuTime,
122123
QRNG_DIMENSIONS * N, 1, 128 * QRNG_DIMENSIONS);
123124

124-
printf("\nReading GPU results...\n");
125+
printf("\nReading Device results...\n");
125126

126127
q_ct1.memcpy(h_OutputGPU, d_Output, QRNG_DIMENSIONS * N * sizeof(float))
127128
.wait();
@@ -166,7 +167,7 @@ int main(int argc, char **argv) {
166167
(double)QRNG_DIMENSIONS * (double)N * 1E-9 / gpuTime, gpuTime,
167168
QRNG_DIMENSIONS * N, 1, 128);
168169

169-
printf("Reading GPU results...\n");
170+
printf("Reading Device results...\n");
170171

171172
q_ct1.memcpy(h_OutputGPU, d_Output, QRNG_DIMENSIONS * N * sizeof(float))
172173
.wait();

DirectProgramming/C++SYCL/MapReduce/guided_quasirandomGenerator_SYCLMigration/README.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,32 @@ To summarise, in-order queues guarantee the order of execution of commands, whil
104104
$ make
105105
```
106106

107-
By default, this command sequence will build the `02_sycl_migrated_optimized` version of the program.
107+
By default, this command sequence will build the `01_dpct_output`, `02_sycl_migrated_optimized` version of the program.
108108

109109
3. Run the program.
110110

111-
You can run the programs for CPU and GPU. The commands indicate the device target.
111+
Run `01_dpct_output` on GPU.
112+
```
113+
make run
114+
```
115+
Run `01_dpct_output` on CPU.
116+
```
117+
export ONEAPI_DEVICE_SELECTOR=cpu
118+
make run
119+
unset ONEAPI_DEVICE_SELECTOR
120+
```
121+
4. Run the program.
122+
123+
Run `02_sycl_migrated_optimized` on GPU.
124+
```
125+
make run_smo
126+
```
127+
Run `02_sycl_migrated_optimized` on CPU.
128+
```
129+
export ONEAPI_DEVICE_SELECTOR=cpu
130+
make run_smo
131+
unset ONEAPI_DEVICE_SELECTOR
112132
```
113-
$ make run_cpu
114-
$ make run_gpu
115-
```
116133

117134
#### Troubleshooting
118135

0 commit comments

Comments
 (0)