Patch for CUDA Scale Filter
Please find attached a CUDA based scale filter. This filter will be a starting point to add other CUDA based filters. The filter supports 420-8, 420-10, 444-8, 444-10 formats and will help to do complete 10-bit HW accelerated transcoding when using CUVID. Currently the filter requires a manual step of generating the PTX files. The commands for generating the PTX files have been put in build.bat inside the CUDA folder that has been created as a subfolder within libavfilter. There is an existing scale_npp filter however that filter supports only 8 bit and has lower performance than the current one. Thanks, Yogender ----------------------------------------------------------------------------------- This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. -----------------------------------------------------------------------------------
Please find attached a CUDA based scale filter. This filter will be a starting point to add other CUDA based filters. The filter supports 420-8, 420-10, 444-8, 444-10 formats and will help to do complete 10-bit HW accelerated transcoding when using >> CUVID. Currently the filter requires a manual step of generating the PTX files. The commands for generating the PTX files have been put in build.bat inside the CUDA folder that has been created as a subfolder within libavfilter. There is an existing scale_npp filter however that filter supports only 8 bit and has lower performance than the current one.
Are there any plans to include this in the repo. Anything that I can support here to make it worthy. Thanks, Yogender ----------------------------------------------------------------------------------- This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. -----------------------------------------------------------------------------------
Am 17.04.2017 um 08:59 schrieb Yogender Gupta:
Please find attached a CUDA based scale filter. This filter will be a starting point to add other CUDA based filters. The filter supports 420-8, 420-10, 444-8, 444-10 formats and will help to do complete 10-bit HW accelerated transcoding when using >> CUVID. Currently the filter requires a manual step of generating the PTX files. The commands for generating the PTX files have been put in build.bat inside the CUDA folder that has been created as a subfolder within libavfilter. There is an existing scale_npp filter however that filter supports only 8 bit and has lower performance than the current one.
Are there any plans to include this in the repo. Anything that I can support here to make it worthy.
Thanks, Yogender
I'm generally in favor of adding CUDA based filtering, there's a lot of nice stuff that could be done that way. But there is one big issue with this approach: Having to run a .bat file prior to building isn't really nice, and not something I and some other people on IRC would like to see in ffmpeg. Instead, it would be nice if configure/make would learn how to handle .cu files, converting them straight to an object-file. My idea for this would be to teach the Makefiles about .cu files, and using a shell script as their compiler. That script can then call nvcc and include the ptx2c functionality, and additionally also calls the designated C compiler, so for the build system it converts .cu to .o. Also, due to these kind of filters having to include cuda.h, they need to be put behind --enable-nonfree in configure. That's what I have in mind so far. I didn't have time for a full review of the code yet, so can't say much about the filter itself.
Having to run a .bat file prior to building isn't really nice, and not something I and some other people on IRC would like to see in ffmpeg.
Instead, it would be nice if configure/make would learn how to handle .cu files, converting them straight to an object-file. My idea for this would be to teach the Makefiles about .cu files, and using a shell script as their compiler. That script can then call nvcc and include the ptx2c functionality, and additionally also calls the designated C compiler, so for the build system it converts .cu to .o.
I wanted to fix the Makefiles but find it pretty complicated. Are there any pointers that could be useful as a start point. Thanks, Yogender ----------------------------------------------------------------------------------- This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. -----------------------------------------------------------------------------------
Having to run a .bat file prior to building isn't really nice, and not something I and some other people on IRC would like to see in ffmpeg.
Instead, it would be nice if configure/make would learn how to handle .cu files, converting them straight to an object-file. My idea for this would be to teach the Makefiles about .cu files, and using a shell script as their compiler. That script can then call nvcc and include the ptx2c functionality, and additionally also calls the designated C compiler, so for the build system it converts .cu to .o.
I wanted to fix the Makefiles but find it pretty complicated. Are there any pointers that could be useful as a start point.
Yeah, they are quite complex. From how I understand it, it basically should boil down to adding something to common.mak like: CU2C=..../compat/cuda/cu2c.sh %.ptx.c: %.cu $(CU2C) $< Then adding something.ptx.o to the OBJS list _should_ cause make to do the right thing. But I'm not a Makefile expert.
On Mon, 17 Apr 2017 12:22:00 +0200 Timo Rothenpieler <timo@rothenpieler.org> wrote:
Am 17.04.2017 um 08:59 schrieb Yogender Gupta:
Please find attached a CUDA based scale filter. This filter will be a starting point to add other CUDA based filters. The filter supports 420-8, 420-10, 444-8, 444-10 formats and will help to do complete 10-bit HW accelerated transcoding when using >> CUVID. Currently the filter requires a manual step of generating the PTX files. The commands for generating the PTX files have been put in build.bat inside the CUDA folder that has been created as a subfolder within libavfilter. There is an existing scale_npp filter however that filter supports only 8 bit and has lower performance than the current one.
Are there any plans to include this in the repo. Anything that I can support here to make it worthy.
Thanks, Yogender
I'm generally in favor of adding CUDA based filtering, there's a lot of nice stuff that could be done that way.
But there is one big issue with this approach:
Having to run a .bat file prior to building isn't really nice, and not something I and some other people on IRC would like to see in ffmpeg.
Instead, it would be nice if configure/make would learn how to handle .cu files, converting them straight to an object-file. My idea for this would be to teach the Makefiles about .cu files, and using a shell script as their compiler. That script can then call nvcc and include the ptx2c functionality, and additionally also calls the designated C compiler, so for the build system it converts .cu to .o.
Also, due to these kind of filters having to include cuda.h, they need to be put behind --enable-nonfree in configure.
That's what I have in mind so far. I didn't have time for a full review of the code yet, so can't say much about the filter itself.
I'm against. Building the "script" seems pretty terribly complicated, and adding generated code is usually not what we do in this project. This is probably done better with a d3d11 video scale filter, although I'm not sure about the tradeoffs yet.
I'm generally in favor of adding CUDA based filtering, there's a lot of nice stuff that could be done that way.
But there is one big issue with this approach:
Having to run a .bat file prior to building isn't really nice, and not something I and some other people on IRC would like to see in ffmpeg.
Instead, it would be nice if configure/make would learn how to handle .cu files, converting them straight to an object-file. My idea for this would be to teach the Makefiles about .cu files, and using a shell script as their compiler. That script can then call nvcc and include the ptx2c functionality, and additionally also calls the designated C compiler, so for the build system it converts .cu to .o.
Also, due to these kind of filters having to include cuda.h, they need to be put behind --enable-nonfree in configure.
That's what I have in mind so far. I didn't have time for a full review of the code yet, so can't say much about the filter itself.
I'm against. Building the "script" seems pretty terribly complicated, and adding generated code is usually not what we do in this project. This is probably done better with a d3d11 video scale filter, although I'm not sure about the tradeoffs yet.
That's exactly what I said though? Making configure/make generate the code at build time, so the generated code is not in the repo, only the actual .cu file. One problem with that is, that nvcc require cl.exe on Windows, it doesn't work with gcc. So that would limit it to MSVC builds on Windows, which is fine with me.
On Mon, Apr 17, 2017 at 2:51 PM, Timo Rothenpieler <timo@rothenpieler.org> wrote:
I'm generally in favor of adding CUDA based filtering, there's a lot of nice stuff that could be done that way.
But there is one big issue with this approach:
Having to run a .bat file prior to building isn't really nice, and not something I and some other people on IRC would like to see in ffmpeg.
Instead, it would be nice if configure/make would learn how to handle .cu files, converting them straight to an object-file. My idea for this would be to teach the Makefiles about .cu files, and using a shell script as their compiler. That script can then call nvcc and include the ptx2c functionality, and additionally also calls the designated C compiler, so for the build system it converts .cu to .o.
Also, due to these kind of filters having to include cuda.h, they need to be put behind --enable-nonfree in configure.
That's what I have in mind so far. I didn't have time for a full review of the code yet, so can't say much about the filter itself.
I'm against. Building the "script" seems pretty terribly complicated, and adding generated code is usually not what we do in this project. This is probably done better with a d3d11 video scale filter, although I'm not sure about the tradeoffs yet.
That's exactly what I said though? Making configure/make generate the code at build time, so the generated code is not in the repo, only the actual .cu file.
One problem with that is, that nvcc require cl.exe on Windows, it doesn't work with gcc. So that would limit it to MSVC builds on Windows, which is fine with me.
FWIW there are non-nvcc cuda compilers that run on Windows, like clang. http://llvm.org/docs/CompileCudaWithLLVM.html
FWIW there are non-nvcc cuda compilers that run on Windows, like clang. http://llvm.org/docs/CompileCudaWithLLVM.html
As this needs nonfree anyway, it might as well use NVRTC and compile the code at runtime, same way OpenCL does it. That's probably even easier than fiddling with integrating nvcc into the build process, and also allows for it to work on Windows with MinGW builds.
participants (4)
-
Alex Converse -
Timo Rothenpieler -
wm4 -
Yogender Gupta