[x264-devel] x264 + Intel 4th gen CPUs and OpenCL

Steve Borho sborho at multicorewareinc.com
Tue Nov 26 19:04:16 CET 2013


On Tue, Nov 26, 2013 at 8:08 AM, Anders Cedronius <
anders.cedronius at netinsight.net> wrote:

>  I’ve been playing around with the OpenCL implementation in x264 and
> intels 4th generation CPUs
>
>
>
> On Linux currently Intel ‘only’ support CPU based OpenCL. So I changed
> opencl.c in x264 to support ‘CL_DEVICE_TYPE_CPU’
>
>
>
> Compiled the snapshot downloaded 2013-11-25  and ran.
>
>
>
> ./x264 --bitrate 20000 --demuxer raw --input-csp i420 --input-range tv
> --input-depth 8 --input-res 1280x720 --fps 50 --preset medium --opencl -o
> /media/LaCie/yuv/x264_out/test.264
> /media/LaCie/yuv/seq/parkjoy_420_8bit.yuv
>
> raw [info]: 1280x720p 0:0 @ 50/1 fps (cfr)
>
> x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2
> FMA3 LZCNT BMI2
>
> x264 [info]: OpenCL acceleration enabled with Intel(R) Corporation Genuine
> Intel(R) CPU 0000 @ 2.00GHz
>
> x264 [info]: profile High, level 4.1
>
> x264 [info]: frame I:2     Avg QP:22.04
> size:282044
>
> x264 [info]: frame P:497   Avg QP:30.78  size: 46261
>
> x264 [info]: mb I  I16..4:  7.1% 56.5% 36.5%
>
> x264 [info]: mb P  I16..4:  0.2%  1.4%  0.6%  P16..4: 36.8% 21.6% 19.1%
> 0.0%  0.0%    skip:20.2%
>
> x264 [info]: final ratefactor: 19.61
>
> x264 [info]: 8x8 transform intra:61.6% inter:44.9%
>
> x264 [info]: coded y,uvDC,uvAC intra: 95.8% 96.4% 88.8% inter: 44.9% 29.2%
> 13.7%
>
> x264 [info]: i16 v,h,dc,p:  6%  3% 50% 42%
>
> x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 11% 12% 26%  7%  9%  9%  9%
> 8% 10%
>
> x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 12% 12% 20%  9% 10%  9%  9%
> 8% 10%
>
> x264 [info]: i8c dc,h,v,p: 62% 11% 15% 11%
>
> x264 [info]: Weighted P-Frames: Y:0.0% UV:0.0%
>
> x264 [info]: ref P L0: 76.3% 16.4%  5.5%  1.8%
>
> x264 [info]: kb/s:18882.34
>
>
>
> Well the performance as expected is not good but there are no complaints
> about OpenCL
>
>
>
> But I want to check the performance of x264/OpenCL running on the GPUs so
> I went ahead and installed windows 7 64bit + the latest drivers for intels
> platform and Intels OpenCL SDK that reports two OpenCL devices: CL_DEVICE_TYPE_CPU
> (the CPU) and CL_DEVICE_TYPE_GPU (Intel(R) HD Graphics 4600)
>
>
>
> However when running OpenCL now using the pre-compiled (http://download.videolan.org/pub/x264/binaries/win64/x264-r2377-1ca7bb9.exe)
>
>
>
> I get this:
>
>
>
> C:\x264>x264.exe --bitrate 15000 --demuxer raw --input-csp i420
> --input-range tv
>
> --input-depth 8 --input-res 1280x720 --fps 50 --preset medium --opencl -o
> d:\yu
>
> v\x264_out\test.264 d:\yuv\seq\parkjoy_420_8bit.yuv
>
> raw [info]: 1280x720p 0:0 @ 50/1 fps (cfr)
>
> x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2
> FMA3 LZ
>
> CNT BMI2
>
> x264 [info]: OpenCL acceleration enabled with Intel(R) Corporation
> Intel(R) HD Graphics 4600
>
> x264 [info]: Compiling OpenCL kernels...
>
> x264 [info]: profile High, level 4.1
>
> x264 [error]: OpenCL: Unknown error
>

This is OpenCL's ubiquitous "oh crap, something somewhere failed and now
it's way too late to do anything about it".  When this happens the OpenCL
driver sets a flag in the context that makes all future API calls fail
(presumably to prevent outright crashes).

 x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: x264 [error]: OpenCL: Unknown error
>
> x264_encoder_encode failed
>

the main loop should have exited  here; not sure why there's so many
failures afterwards.. perhaps it's still flushing the encoder


>  x264 [error]:  OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
> x264 [error]: OpenCL: Unknown error
>
> x264 [error]: OpenCL: fatal error, aborting encode
>
 x264 [info]: final ratefactor: 10.92
>
> aborted at input frame 46, output frame 0
>
>
>
> Just for testing I compiled the daily snapshot and got the exact same
> result as the above printout.
>
>
>
> Then I modified the opencl.c to accept OpenCL CPU’s
>
>
>
> Then I got a different behaviour:
>
>
>
> C:\x264_new>x264.exe --bitrate 15000 --demuxer raw --input-csp i420
> --input-range tv --input-depth 8 --input-res 1280x720 --fps 50 --preset
> medium --opencl -o d:\yuv\x264_out\test.264 d:\yuv\seq\parkjoy_420_8bit.yuv
>
> raw [info]: 1280x720p 0:0 @ 50/1 fps (cfr)
>
> x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2
> FMA3 LZCNT BMI2
>
> x264 [info]: OpenCL acceleration enabled with Intel(R) Corporation Genuine
> Intel(R) CPU 0000 @ 2.00GHz
>
> x264 [info]: Compiling OpenCL kernels...
>
> x264 [info]: profile High, level 4.1
>
> 0x00471D37 (0x211D09C0 0x1633E020 0x00000003 0x00000050)
>
> 0x7599A00B (0x00000029 0x00000029 0x00001C20 0x00000001), memmove() +
> 0x1B1 byte
>
> s(s)
>
> 0x0049B177 (0x00000029 0x00001C20 0x00000001 0x00000026)
>

This is par for the course with unstable drivers.

OpenCL is still very much a "Write once, debug everywhere" platform.  Buggy
drivers and JIT compilers are common.  Intel's drivers have historically
been on the bad side, but they have been improving lately.  Having an app
go from functional to busted following a driver update is typical.

The kernels in x264 haven't changed in over a year, AFAIK, and they run
well on many different GPUs of multiple vendors.  But they don't work on
every device claiming to be OpenCL compliant. YMMV. Thus the feature is
still disabled by default.

--
Steve Borho
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x264-devel/attachments/20131126/ba738234/attachment-0001.html>


More information about the x264-devel mailing list