Skip to content

Commit 6fb83e9

Browse files
authored
Merge pull request #2553 from AvijitBag07/Remigrated_sample_2025.0
Remigrated_SYCL_Sample_oneAPI_2025
2 parents f70ce55 + 91cdf79 commit 6fb83e9

File tree

1,868 files changed

+1121460
-117169
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,868 files changed

+1121460
-117169
lines changed

DirectProgramming/C++SYCL/SYCLMigration/guided_alignedTypes_SYCLMigration/01_dpct_output/Common/helper_cuda.h

Lines changed: 37 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@
5454
#ifdef __DPCT_HPP__
5555
static const char *_cudaGetErrorEnum(dpct::err0 error) {
5656
/*
57-
DPCT1009:0: SYCL uses exceptions to report errors and does not use the error
58-
codes. The call was replaced by a placeholder string. You need to rewrite this
59-
code.
57+
DPCT1009:0: SYCL reports errors using exceptions and does not use error codes.
58+
Please replace the "get_error_string_dummy(...)" with a real error-handling
59+
function.
6060
*/
61-
return "<Placeholder string>";
61+
return dpct::get_error_string_dummy(error);
6262
}
6363
#endif
6464

@@ -636,7 +636,7 @@ inline int ftoi(float value) {
636636
inline int _ConvertSMVer2Cores(int major, int minor) {
637637
// Defines for GPU Architecture types (using the SM version to determine
638638
// the # of cores per SM
639-
typedef struct dpct_type_175225 {
639+
typedef struct dpct_type_133627 {
640640
int SM; // 0xMm (hexidecimal notation), M = SM Major version,
641641
// and m = SM minor version
642642
int Cores;
@@ -685,7 +685,7 @@ inline int _ConvertSMVer2Cores(int major, int minor) {
685685
inline const char* _ConvertSMVer2ArchName(int major, int minor) {
686686
// Defines for GPU Architecture types (using the SM version to determine
687687
// the GPU Arch name)
688-
typedef struct dpct_type_319217 {
688+
typedef struct dpct_type_138373 {
689689
int SM; // 0xMm (hexidecimal notation), M = SM Major version,
690690
// and m = SM minor version
691691
const char* name;
@@ -736,8 +736,7 @@ inline const char* _ConvertSMVer2ArchName(int major, int minor) {
736736
// General GPU Device CUDA Initialization
737737
inline int gpuDeviceInit(int devID) {
738738
int device_count;
739-
checkCudaErrors(DPCT_CHECK_ERROR(
740-
device_count = dpct::dev_mgr::instance().device_count()));
739+
checkCudaErrors(DPCT_CHECK_ERROR(device_count = dpct::device_count()));
741740

742741
if (device_count == 0) {
743742
fprintf(stderr,
@@ -768,10 +767,10 @@ inline int gpuDeviceInit(int devID) {
768767
need to adjust this code.
769768
*/
770769
checkCudaErrors(DPCT_CHECK_ERROR(computeMode = 1));
771-
checkCudaErrors(DPCT_CHECK_ERROR(
772-
major = dpct::dev_mgr::instance().get_device(devID).get_major_version()));
773-
checkCudaErrors(DPCT_CHECK_ERROR(
774-
minor = dpct::dev_mgr::instance().get_device(devID).get_minor_version()));
770+
checkCudaErrors(
771+
DPCT_CHECK_ERROR(major = dpct::get_device(devID).get_major_version()));
772+
checkCudaErrors(
773+
DPCT_CHECK_ERROR(minor = dpct::get_device(devID).get_minor_version()));
775774
/*
776775
DPCT1035:6: All SYCL devices can be used by the host to submit tasks. You may
777776
need to adjust this code.
@@ -806,8 +805,7 @@ inline int gpuGetMaxGflopsDeviceId() try {
806805
int devices_prohibited = 0;
807806

808807
uint64_t max_compute_perf = 0;
809-
checkCudaErrors(DPCT_CHECK_ERROR(
810-
device_count = dpct::dev_mgr::instance().device_count()));
808+
checkCudaErrors(DPCT_CHECK_ERROR(device_count = dpct::device_count()));
811809

812810
if (device_count == 0) {
813811
fprintf(stderr,
@@ -826,12 +824,10 @@ inline int gpuGetMaxGflopsDeviceId() try {
826824
may need to adjust this code.
827825
*/
828826
checkCudaErrors(DPCT_CHECK_ERROR(computeMode = 1));
829-
checkCudaErrors(DPCT_CHECK_ERROR(major = dpct::dev_mgr::instance()
830-
.get_device(current_device)
831-
.get_major_version()));
832-
checkCudaErrors(DPCT_CHECK_ERROR(minor = dpct::dev_mgr::instance()
833-
.get_device(current_device)
834-
.get_minor_version()));
827+
checkCudaErrors(DPCT_CHECK_ERROR(
828+
major = dpct::get_device(current_device).get_major_version()));
829+
checkCudaErrors(DPCT_CHECK_ERROR(
830+
minor = dpct::get_device(current_device).get_minor_version()));
835831

836832
// If this GPU is not running on Compute Mode prohibited,
837833
// then we can add it to the list
@@ -847,14 +843,12 @@ inline int gpuGetMaxGflopsDeviceId() try {
847843
_ConvertSMVer2Cores(major, minor);
848844
}
849845
int multiProcessorCount = 0, clockRate = 0;
850-
checkCudaErrors(
851-
DPCT_CHECK_ERROR(multiProcessorCount = dpct::dev_mgr::instance()
852-
.get_device(current_device)
853-
.get_max_compute_units()));
854-
dpct::err0 result =
855-
DPCT_CHECK_ERROR(clockRate = dpct::dev_mgr::instance()
856-
.get_device(current_device)
857-
.get_max_clock_frequency());
846+
checkCudaErrors(DPCT_CHECK_ERROR(
847+
multiProcessorCount =
848+
dpct::get_device(current_device).get_max_compute_units()));
849+
dpct::err0 result = DPCT_CHECK_ERROR(
850+
clockRate =
851+
dpct::get_device(current_device).get_max_clock_frequency());
858852

859853
uint64_t compute_perf = (uint64_t)multiProcessorCount * sm_per_multiproc * clockRate;
860854

@@ -912,12 +906,10 @@ inline int findCudaDevice(int argc, const char **argv) {
912906
*/
913907
checkCudaErrors(DPCT_CHECK_ERROR(dpct::select_device(devID)));
914908
int major = 0, minor = 0;
915-
checkCudaErrors(DPCT_CHECK_ERROR(
916-
major =
917-
dpct::dev_mgr::instance().get_device(devID).get_major_version()));
918-
checkCudaErrors(DPCT_CHECK_ERROR(
919-
minor =
920-
dpct::dev_mgr::instance().get_device(devID).get_minor_version()));
909+
checkCudaErrors(
910+
DPCT_CHECK_ERROR(major = dpct::get_device(devID).get_major_version()));
911+
checkCudaErrors(
912+
DPCT_CHECK_ERROR(minor = dpct::get_device(devID).get_minor_version()));
921913
printf("GPU Device %d: \"%s\" with compute capability %d.%d\n\n",
922914
devID, _ConvertSMVer2ArchName(major, minor), major, minor);
923915

@@ -931,8 +923,7 @@ inline int findIntegratedGPU() {
931923
int device_count = 0;
932924
int devices_prohibited = 0;
933925

934-
checkCudaErrors(DPCT_CHECK_ERROR(
935-
device_count = dpct::dev_mgr::instance().device_count()));
926+
checkCudaErrors(DPCT_CHECK_ERROR(device_count = dpct::device_count()));
936927

937928
if (device_count == 0) {
938929
fprintf(stderr, "CUDA error: no devices supporting CUDA.\n");
@@ -947,10 +938,8 @@ inline int findIntegratedGPU() {
947938
may need to adjust this code.
948939
*/
949940
checkCudaErrors(DPCT_CHECK_ERROR(computeMode = 1));
950-
checkCudaErrors(
951-
DPCT_CHECK_ERROR(integrated = dpct::dev_mgr::instance()
952-
.get_device(current_device)
953-
.get_integrated()));
941+
checkCudaErrors(DPCT_CHECK_ERROR(
942+
integrated = dpct::get_device(current_device).get_integrated()));
954943
// If GPU is integrated and is not running on Compute Mode prohibited,
955944
// then cuda can map to GLES resource
956945
/*
@@ -965,12 +954,10 @@ inline int findIntegratedGPU() {
965954
checkCudaErrors(DPCT_CHECK_ERROR(dpct::select_device(current_device)));
966955

967956
int major = 0, minor = 0;
968-
checkCudaErrors(DPCT_CHECK_ERROR(major = dpct::dev_mgr::instance()
969-
.get_device(current_device)
970-
.get_major_version()));
971-
checkCudaErrors(DPCT_CHECK_ERROR(minor = dpct::dev_mgr::instance()
972-
.get_device(current_device)
973-
.get_minor_version()));
957+
checkCudaErrors(DPCT_CHECK_ERROR(
958+
major = dpct::get_device(current_device).get_major_version()));
959+
checkCudaErrors(DPCT_CHECK_ERROR(
960+
minor = dpct::get_device(current_device).get_minor_version()));
974961
printf("GPU Device %d: \"%s\" with compute capability %d.%d\n\n",
975962
current_device, _ConvertSMVer2ArchName(major, minor), major, minor);
976963

@@ -997,12 +984,11 @@ inline bool checkCudaCapabilities(int major_version, int minor_version) {
997984
int dev;
998985
int major = 0, minor = 0;
999986

987+
checkCudaErrors(DPCT_CHECK_ERROR(dev = dpct::get_current_device_id()));
988+
checkCudaErrors(
989+
DPCT_CHECK_ERROR(major = dpct::get_device(dev).get_major_version()));
1000990
checkCudaErrors(
1001-
DPCT_CHECK_ERROR(dev = dpct::dev_mgr::instance().current_device_id()));
1002-
checkCudaErrors(DPCT_CHECK_ERROR(
1003-
major = dpct::dev_mgr::instance().get_device(dev).get_major_version()));
1004-
checkCudaErrors(DPCT_CHECK_ERROR(
1005-
minor = dpct::dev_mgr::instance().get_device(dev).get_minor_version()));
991+
DPCT_CHECK_ERROR(minor = dpct::get_device(dev).get_minor_version()));
1006992

1007993
if ((major > major_version) ||
1008994
(major == major_version &&

0 commit comments

Comments
 (0)