Migrating to SYCL
One-stop forum for getting assistance migrating your existing code to SYCL
43 Discussions

DPCT cannot migrate these CUDA APIs

Damon
Employee
2,499 Views

I tried to migrate CUDA sample https://github.com/NVIDIA/cuda-samples/tree/v11.5/Samples/SobelFilter using dpct. But got a lot of issues that some CUDA APIs not declared.

cudaGraphicsMapResources
cudaGraphicsResourceGetMappedPointer
cudaGraphicsUnmapResources
cudaGraphicsUnregisterResource
cudaGraphicsMapFlagsWriteDiscard
findCudaDevice
checkCudaErrors

And 

SobelFilter/migration$ make

dpcpp -I../../common/inc -lGL -lGLU -lglut SobelFilter.cpp.dp.cpp SobelFilter_kernels.dp.cpp -o SobelFilter_dpcpp

SobelFilter_kernels.dp.cpp:96:40: error: use of undeclared identifier 'tex2D'

        LocalBlock[SharedIdx+4*ib+1] = tex2D<unsigned char>(tex,

                                       ^

SobelFilter_kernels.dp.cpp:98:40: error: use of undeclared identifier 'tex2D'

        LocalBlock[SharedIdx+4*ib+2] = tex2D<unsigned char>(tex,

...

My oneAPI version is 2021.4.

Does anyone know how to solve this? 

 

 

0 Kudos
1 Solution
Alex_Y_Intel
Moderator
2,236 Views

First of all, according to our developers, cudaGraph* integration is not yet supported.

Second, the two errors you saw:

findCudaDevice

checkCudaErrors

are resulted from ​not including the correct header files while integrating.


1. copy necessary files to the workspace, my workspace folder is: ~/testfolder/cuda_test, you need to copy /usr/local/cuda/samples/common and SobelFilter in it like:

~/testfolder/cuda_test$ ls

common SobelFilter


2. change the SobelFilter/Makefile (since the location of folder common is changed)

change line 282 from:

280

281 # Common includes and paths for CUDA

282 INCLUDES := -I../../common/inc

283 LIBRARIES :=

284

to:

280

281 # Common includes and paths for CUDA

282 INCLUDES := -I../common/inc

283 LIBRARIES :=

284


3. generate compile_commands.json

~/testfolder/cuda_test$ cd SobelFilter/

~/testfolder/cuda_test/SobelFilter$ intercept-build make


4. use dpct to migrate

dpct -p . --in-root .. --out-root migration


5. cd into migration folder

~/testfolder/cudat_test/SobelFilter$ cd migration/


6. prepare Makefile

~/testfolder/cudat_test/SobelFilter/migration$ cat Makefile.dpct

CC := dpcpp


LD := $(CC)


#DPCT2001:40: You can link with more library by add them here.

LIB :=


FLAGS :=


TARGET_0_SRC_0 = ./SobelFilter/SobelFilter_kernels.dp.cpp

TARGET_0_OBJ_0 = ./SobelFilter/SobelFilter_kernels.dp.o

TARGET_0_FLAG_0 = -I./common/inc ${FLAGS}


TARGET_0_SRC_1 = ./SobelFilter/SobelFilter.cpp.dp.cpp

TARGET_0_OBJ_1 = ./SobelFilter/SobelFilter.cpp.dp.o

TARGET_0_FLAG_1 = -I./common/inc ${FLAGS}


TARGET_0 := SobelFilter


TARGET := ${TARGET_0}


.PHONY:all clean

OBJS_0 := ${TARGET_0_OBJ_0} ${TARGET_0_OBJ_1}

all: $(TARGET)

$(TARGET_0): $(OBJS_0)

$(LD) -o $@ $^ $(LIB)


$(TARGET_0_OBJ_0):$(TARGET_0_SRC_0)

$(CC) -c ${TARGET_0_SRC_0} -o ${TARGET_0_OBJ_0} $(TARGET_0_FLAG_0)


$(TARGET_0_OBJ_1):$(TARGET_0_SRC_1)

$(CC) -c ${TARGET_0_SRC_1} -o ${TARGET_0_OBJ_1} $(TARGET_0_FLAG_1)


clean:

rm -f ${OBJS_0} $(TARGET)


7. build with dpcpp

make -f Makefile.dpct


To be more specific, the two errors about findCudaDevice and checkCudaErrors occurred because you needed the files in /usr/local/cuda/samples/common; you had to put them in the same directory with your source files so they could be integrated together.



View solution in original post

0 Kudos
7 Replies
HemanthCH_Intel
Moderator
2,467 Views

Hi,


Thanks for reaching out to us.


We are able to reproduce your issue at our end using the latest oneAPI 2021.4 on a ubuntu 18.04 machine. we are working on your issue internally and will get back to you soon.


Thanks & Regards,

Hemanth.


0 Kudos
Alex_Y_Intel
Moderator
2,405 Views

I'm working on it and will get back to you as soon as I have any update. ​


0 Kudos
Alex_Y_Intel
Moderator
2,400 Views

Can you please clarify for me--

  1. "got a lot of issues that some CUDA APIs not declared"--can you tell me what those are?
  2. From which file are you seeing the errors?
  3. What are you reproducing steps?

Thanks.


0 Kudos
Damon
Employee
2,391 Views

Here's my steps:
 System Ubuntu 20.04.3

1. Setup Intel® oneAPI Base Toolkit  https://www.intel.com/content/www/us/en/develop/documentation/installation-guide-for-intel-oneapi-toolkits-linux/top/installation/install-using-package-managers/apt.html 

2. Download and install CUDA tookit.  https://developer.nvidia.com/cuda-11.1.1-download-archive

3.  Navigate the SobelFilter code in Cuda sample  installed into system.

    # cd /usr/local/cuda-11.1/samples/3_Imaging/SobelFilter/

    Run

    # intercept-build make
    # dpct -p compile_commands.json --in-root=. --out-root=migration    

   Fixed the warning with DPCT1049, DPCT1050 following the instruction in Diagnostic Reference  .

.
   Next to enter migrate folder, and copy the following contents as my Makefile in current dir.

   # cd migrate/    

CXX = dpcpp

TARGET = SobelFilter_dpcpp

SRCS = SobelFilter.cpp.dp.cpp

DEPS = SobelFilter_kernels.dp.cpp

INCS := -I../../../common/inc

 

all: $(TARGET)

 

$(TARGET): $(SRCS) $(DEPS)

        $(CXX)  $(INCS) $(SRCS) $(DEPS) -o $@

 

run: $(TARGET)

        ./$(TARGET)

 

.PHONY: clean

clean:

        rm -f $(TARGET) *.o result.txt

    

    Active the oneAPI  and then run make command:

    #  source /opt/intel/oneapi/setvars.sh

    # make 

   

Here is my screenshot:

 

Damon_1-1639571422122.png

This make message appears all errors in SobelFilter.cpp.dp.cpp. And the incomptiable  APIs include:

cudaGraphicsMapResources

cudaGraphicsResourceGetMappedPointer

cudaGraphicsUnmapResources

cudaGraphicsUnregisterResource

cudaGraphicsMapFlagsWriteDiscard

findCudaDevice

checkCudaErrors

and in  migration/SobelFilter_kernels.dp.cpp

Damon_2-1639571775176.png

 

 

0 Kudos
Alex_Y_Intel
Moderator
2,376 Views

Your issue has been escalated to the developers. We'll work on it internally and get back to you with update.


0 Kudos
Alex_Y_Intel
Moderator
2,237 Views

First of all, according to our developers, cudaGraph* integration is not yet supported.

Second, the two errors you saw:

findCudaDevice

checkCudaErrors

are resulted from ​not including the correct header files while integrating.


1. copy necessary files to the workspace, my workspace folder is: ~/testfolder/cuda_test, you need to copy /usr/local/cuda/samples/common and SobelFilter in it like:

~/testfolder/cuda_test$ ls

common SobelFilter


2. change the SobelFilter/Makefile (since the location of folder common is changed)

change line 282 from:

280

281 # Common includes and paths for CUDA

282 INCLUDES := -I../../common/inc

283 LIBRARIES :=

284

to:

280

281 # Common includes and paths for CUDA

282 INCLUDES := -I../common/inc

283 LIBRARIES :=

284


3. generate compile_commands.json

~/testfolder/cuda_test$ cd SobelFilter/

~/testfolder/cuda_test/SobelFilter$ intercept-build make


4. use dpct to migrate

dpct -p . --in-root .. --out-root migration


5. cd into migration folder

~/testfolder/cudat_test/SobelFilter$ cd migration/


6. prepare Makefile

~/testfolder/cudat_test/SobelFilter/migration$ cat Makefile.dpct

CC := dpcpp


LD := $(CC)


#DPCT2001:40: You can link with more library by add them here.

LIB :=


FLAGS :=


TARGET_0_SRC_0 = ./SobelFilter/SobelFilter_kernels.dp.cpp

TARGET_0_OBJ_0 = ./SobelFilter/SobelFilter_kernels.dp.o

TARGET_0_FLAG_0 = -I./common/inc ${FLAGS}


TARGET_0_SRC_1 = ./SobelFilter/SobelFilter.cpp.dp.cpp

TARGET_0_OBJ_1 = ./SobelFilter/SobelFilter.cpp.dp.o

TARGET_0_FLAG_1 = -I./common/inc ${FLAGS}


TARGET_0 := SobelFilter


TARGET := ${TARGET_0}


.PHONY:all clean

OBJS_0 := ${TARGET_0_OBJ_0} ${TARGET_0_OBJ_1}

all: $(TARGET)

$(TARGET_0): $(OBJS_0)

$(LD) -o $@ $^ $(LIB)


$(TARGET_0_OBJ_0):$(TARGET_0_SRC_0)

$(CC) -c ${TARGET_0_SRC_0} -o ${TARGET_0_OBJ_0} $(TARGET_0_FLAG_0)


$(TARGET_0_OBJ_1):$(TARGET_0_SRC_1)

$(CC) -c ${TARGET_0_SRC_1} -o ${TARGET_0_OBJ_1} $(TARGET_0_FLAG_1)


clean:

rm -f ${OBJS_0} $(TARGET)


7. build with dpcpp

make -f Makefile.dpct


To be more specific, the two errors about findCudaDevice and checkCudaErrors occurred because you needed the files in /usr/local/cuda/samples/common; you had to put them in the same directory with your source files so they could be integrated together.



0 Kudos
Damon
Employee
2,226 Views
0 Kudos
Reply