6 Replies Latest reply on Sep 14, 2010 5:30 AM by himanshu.gautam

    Seems OpenCL doesn't support Polymorphism?

    edwen

      In my Kernel file .cl, I define several functions with the same name, but have different numbers and types of parameters. The excecution always failed until I named those functions differently. Doesn't anyone have the same experience?

      I wonder if OpenCL support "class" and "derived class", which are very popular in C++.

       

        • Seems OpenCL doesn't support Polymorphism?
          mihzaha

          OpenCL is based on C, not C++. It doesn't support polymorphism or classes, it's not object oriented.

          • Seems OpenCL doesn't support Polymorphism?
            Raistmer
            Originally posted by: edwen

            In my Kernel file .cl, I define several functions with the same name, but have different numbers and types of parameters. The excecution always failed until I named those functions differently. Doesn't anyone have the same experience?




            I wonder if OpenCL support "class" and "derived class", which are very popular in C++.




             



            when you will bound OpenCL kernel with cl_kernel object in your C++ code you will provide only kernel name, not kernel name decorated with its parameters and return type.
            From this fact it's obvious that same kernel names will not go.
              • Seems OpenCL doesn't support Polymorphism?
                bubu

                Btw, I tried a custom mechanism ( ala GObject ) using C function pointers, but it neither supports them so it's impossible to get polymorphism, sorry.

                 

                On the other hand, I think you are referring to function parameter's overriding which is a completely different thing... but C does not support it, you must change the function's name.

                 

                Those things together with templates reminds me each day why C is really awful and why OpenCL 2.0 should support C++.