Announcement

Collapse
No announcement yet.

Trying Intel OpenCL On Linux For Video Encoding

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trying Intel OpenCL On Linux For Video Encoding

    Phoronix: Trying Intel OpenCL On Linux For Video Encoding

    Following my testing and reporting last weekend about Intel Beignet starting to provide very usable open-source OpenCL support on Linux, one of the most common requests was to next see if this Intel OpenCL Linux supprot benefits x264 encoding at all...

    http://www.phoronix.com/vr.php?view=MTc3ODc

  • #2
    After a quick google the Haswell GPU seems (theoretically) to have 2,5-3x more GFLOPS than the CPU. In this task the GPU was slower, but it would be nice if they could work together.

    Comment


    • #3
      Well, at least it runs and doesn't simply fall back to non-OpenCL, looks like.

      Comment


      • #4
        Not too surprising given the amount of effort that goes into x264's SIMD/avx support (which is very fast for Intel). Also opencl, currently, really needs its kernels targeted to particular hardware in order to get best performance. My guess is that x264 was aiming for compatibility rather than speed.

        Comment


        • #5
          Originally posted by opensource View Post
          After a quick google the Haswell GPU seems (theoretically) to have 2,5-3x more GFLOPS than the CPU. In this task the GPU was slower, but it would be nice if they could work together.
          AFAIK opencl in x264 is used only for part of the ecnoding process, so CPU and GPU actually work together here.

          Comment


          • #6
            You has to use a 2 pass encoding for best benefits. And set a high lookahead value (max 250 and is the default settings its 40 )

            Comment


            • #7
              OpenCL option only works with 8bit profiles, donth work with 10bits(Hi10p) (--bit-depth=10)

              greetings

              Comment


              • #8
                the opencl support in x264 does not actually run video encoding via opencl. all it does is offload the lookahead functionality, which at best gains like 2-3% overall encoding speed increase. i think it was basically added as "well we could try this just for the hell of it and see how miniscule the gains are...yep just as miniscule as we thought..."

                Comment


                • #9
                  For Haswell machine, currently we need a patch to be applied to make beignet fully functional.
                  You can get the details at:
                  https://01.org/zh/beignet/downloads/...ch-hsw-support
                  You can also get the above link in the wiki page.

                  There is also another issue which hasn't been documented:

                  For linux kernel 3.16, there is a cmdparser issue which will bring problems on both IVB and HSW.
                  The work around is to disable it as below:
                  echo 0 > /sys/module/i915/parameters/enable_cmd_parser
                  We will update the document shortly.

                  Thanks for the testing and reporting.

                  Comment


                  • #10
                    I for one only get this segfault: http://pastebin.com/raw.php?i=GTirsFBb
                    Possibly since the 3.17 rcs. I haven't really checked again with 3.16.

                    Also libgbe seems to be compiled without debug symbols no matter what.

                    Comment


                    • #11
                      Could you run the utest_run correctly?

                      Originally posted by ChrisXY View Post
                      I for one only get this segfault: http://pastebin.com/raw.php?i=GTirsFBb
                      Possibly since the 3.17 rcs. I haven't really checked again with 3.16.

                      Also libgbe seems to be compiled without debug symbols no matter what.

                      Comment


                      • #12
                        Originally posted by gongzg View Post
                        Could you run the utest_run correctly?
                        Hm, yes, they work.

                        What I'm getting segfaults with are programs like this:
                        Code:
                        #include <stdio.h>
                        #include <stdlib.h>
                        #include <CL/cl.h>
                        int main() {
                            int i, j;
                            char* info;
                            size_t infoSize;
                            cl_uint platformCount;
                            cl_platform_id *platforms;
                            const char* attributeNames[5] = { "Name", "Vendor",
                                "Version", "Profile", "Extensions" };
                            const cl_platform_info attributeTypes[5] = { CL_PLATFORM_NAME, CL_PLATFORM_VENDOR,
                                CL_PLATFORM_VERSION, CL_PLATFORM_PROFILE, CL_PLATFORM_EXTENSIONS };
                            const int attributeCount = sizeof(attributeNames) / sizeof(char*);
                            clGetPlatformIDs(5, NULL, &platformCount);
                            platforms = (cl_platform_id*) malloc(sizeof(cl_platform_id) * platformCount);
                            clGetPlatformIDs(platformCount, platforms, NULL);
                            for (i = 0; i < platformCount; i++) {
                                printf("\n %d. Platform \n", i+1);
                                for (j = 0; j < attributeCount; j++) {
                                    clGetPlatformInfo(platforms[i], attributeTypes[j], 0, NULL, &infoSize);
                                    info = (char*) malloc(infoSize);
                                    clGetPlatformInfo(platforms[i], attributeTypes[j], infoSize, info, NULL);
                                     printf("  %d.%d %-11s: %s\n", i+1, j+1, attributeNames[j], info);
                                    free(info);
                                 }
                                 printf("\n");
                             }
                             free(platforms);
                            return 0;
                         }
                        But it worked some time ago and I'm not sure what I changed other than upgrading the kernel.

                        Comment


                        • #13
                          It doesn't look like a kernel issue. I'm guessing it may be caused by incorrect environment variables.
                          Could you try to run this case in a new terminal window? And please make sure there is no any OCL* env
                          variables set.

                          Originally posted by ChrisXY View Post
                          Hm, yes, they work.

                          What I'm getting segfaults with are programs like this:
                          Code:
                          #include <stdio.h>
                          #include <stdlib.h>
                          #include <CL/cl.h>
                          int main() {
                              int i, j;
                              char* info;
                              size_t infoSize;
                              cl_uint platformCount;
                              cl_platform_id *platforms;
                              const char* attributeNames[5] = { "Name", "Vendor",
                                  "Version", "Profile", "Extensions" };
                              const cl_platform_info attributeTypes[5] = { CL_PLATFORM_NAME, CL_PLATFORM_VENDOR,
                                  CL_PLATFORM_VERSION, CL_PLATFORM_PROFILE, CL_PLATFORM_EXTENSIONS };
                              const int attributeCount = sizeof(attributeNames) / sizeof(char*);
                              clGetPlatformIDs(5, NULL, &platformCount);
                              platforms = (cl_platform_id*) malloc(sizeof(cl_platform_id) * platformCount);
                              clGetPlatformIDs(platformCount, platforms, NULL);
                              for (i = 0; i < platformCount; i++) {
                                  printf("\n %d. Platform \n", i+1);
                                  for (j = 0; j < attributeCount; j++) {
                                      clGetPlatformInfo(platforms[i], attributeTypes[j], 0, NULL, &infoSize);
                                      info = (char*) malloc(infoSize);
                                      clGetPlatformInfo(platforms[i], attributeTypes[j], infoSize, info, NULL);
                                       printf("  %d.%d %-11s: %s\n", i+1, j+1, attributeNames[j], info);
                                      free(info);
                                   }
                                   printf("\n");
                               }
                               free(platforms);
                              return 0;
                           }
                          But it worked some time ago and I'm not sure what I changed other than upgrading the kernel.

                          Comment


                          • #14
                            I'm not aware of any environment variable that could influence beignet. Certainly none that start with OCL... are set.

                            But that made me try this:
                            ./ocl simply segfaults when dlopen libgbe.so
                            I saw that it returns before that dlopen when OCL_NON_COMPILER=1 is set, so I tried this:
                            OCL_NON_COMPILER=1 ./ocl
                            and all the rest works, so just loading the compiler some
                            Code:
                            [...]
                             3. Platform 
                              3.1 Name       : Intel Gen OCL Driver
                              3.2 Vendor     : Intel
                              3.3 Version    : OpenCL 1.2 beignet 0.9
                              3.4 Profile    : FULL_PROFILE
                              3.5 Extensions : cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_icd
                            And then it's this super early crash where nothing has actually happened yet... bgeloader -> dlopen -> "global constructors keyed to a () from /usr/lib/beignet//libgbe.so"...

                            Comment


                            • #15
                              That should be a pure dlopen issue with libgbe.so. Could you please send the details of how to reproduce this issue
                              to beignet mail list? Including the detail distribution version you are using and the toolchain version.

                              The beignet mail list is beignet@lists.freedesktop.org.

                              We will check whether we can reproduce it here and if so, will fix it soon. Thanks.

                              Originally posted by ChrisXY View Post
                              I'm not aware of any environment variable that could influence beignet. Certainly none that start with OCL... are set.

                              But that made me try this:
                              ./ocl simply segfaults when dlopen libgbe.so
                              I saw that it returns before that dlopen when OCL_NON_COMPILER=1 is set, so I tried this:
                              OCL_NON_COMPILER=1 ./ocl
                              and all the rest works, so just loading the compiler some
                              Code:
                              [...]
                               3. Platform 
                                3.1 Name       : Intel Gen OCL Driver
                                3.2 Vendor     : Intel
                                3.3 Version    : OpenCL 1.2 beignet 0.9
                                3.4 Profile    : FULL_PROFILE
                                3.5 Extensions : cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_icd
                              And then it's this super early crash where nothing has actually happened yet... bgeloader -> dlopen -> "global constructors keyed to a () from /usr/lib/beignet//libgbe.so"...

                              Comment

                              Working...
                              X