Help. Porting "FreeOCL" fails (atomic_ops.h missing, CLANG++ libc++ issues ...)

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Help. Porting "FreeOCL" fails (atomic_ops.h missing, CLANG++ libc++ issues ...)

Hartmann, O.
Hello.

FreeBSD has fallen back far behind the standards of modern scientific
computing and I dsperately look for solutions having OpenCL support on
FreeBSD anyway.

I stumbled into this project recently:

FreeOCL at
http://code.google.com/p/freeocl/

or the sources located at

http://code.google.com/p/freeocl/downloads/detail?name=FreeOCL-0.3.6-src.tar.gz&can=2&q=

For your convenience, please find my naive attempt of a port attached to
this email.

Well, I tried LLVM/CLANG, but Cmake of the sources fairly fails many
checks especuially for OpenMP. Using clang++ requisites the usage of the
new libc++ (CXXFLAGS+= -stdlib=libc++). But this fails with this error:


[...]
[ 17%] Building CXX object src/CMakeFiles/FreeOCL.dir/codebuilder.cpp.o
In file included from
/usr/ports/devel/freeocl/work/FreeOCL-0.3.6-Source/src/codebuilder.cpp:26:
/usr/ports/devel/freeocl/work/FreeOCL-0.3.6-Source/src/parser/parser.h:118:15:
error: no viable conversion from 'std::__1::basic_istream<char>' to
'const bool'
                        const bool ok = in.get(c);
                                   ^    ~~~~~~~~~
/usr/ports/devel/freeocl/work/FreeOCL-0.3.6-Source/src/codebuilder.cpp:444:13:
warning: 70 enumeration values not handled in switch: 'VOID', 'BOOL',
'HALF'... [-Wswitch]
                                        switch(native->get_type_id())
                                               ^
1 warning and 1 error generated.
*** [src/CMakeFiles/FreeOCL.dir/codebuilder.cpp.o] Error code 1
[..]


I tried also setting USE_GCC= 4.7+ using gcc-4.7 I installed, but that
fails with

[...]
-- Build files have been written to:
/usr/ports/devel/freeocl/work/FreeOCL-0.3.6-Source
===>  Building for freeocl-0.3.6
Scanning dependencies of target FreeOCL
[  1%] Building CXX object src/CMakeFiles/FreeOCL.dir/freeocl.cpp.o
In file included from
/usr/ports/devel/freeocl/work/FreeOCL-0.3.6-Source/src/freeocl.cpp:18:0:
/usr/ports/devel/freeocl/work/FreeOCL-0.3.6-Source/src/freeocl.h:71:2:
error: 'u_int64_t' does not name a type
*** [src/CMakeFiles/FreeOCL.dir/freeocl.cpp.o] Error code 1
[...]

I think patches are required.

More disturbing is the use of gcc-4.6 via

USE_GCC= 4.6+

The error is then a compalin about a missing include file

atomic_ops.h

which is located in the abandoned KSE facility of the kernel, so the
includes seem not to be installed anymore - but since I'm not involved
in the development, I can only guess and ask the people here.

Maybe some experienced freeBSD developers with the same need for OpenCl
is willing to pick up this and help a bit.

Well, as far as I see, the FreeOCL project of Roland Borchard is a
OpenCL library for CPU usage. As far as I can understand, if we on
FreeBSd could have a library "libOpenCL" as this is usually installed by
the nVidia BLOB drivers on Linux for the use of OpenCL/GPGPU support
with their GPUs, this would fill a still painfull open gap in FreeBSD as
a scientific development platform.

There is still no suitable compiler for OpenCL out here for freeBSD, but
I have still the hope that LLVM can provide such a thing in the near future.

I cross post this posting also to "performance" in the hope finding some
people attracted and "lurd" into this subject.

Regards,

O. Hartmann

Makefile (623 bytes) Download Attachment
signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Help. Porting "FreeOCL" fails (atomic_ops.h missing, CLANG++ libc++ issues ...)

Dimitry Andric-4
On 2012-09-05 16:45, O. Hartmann wrote:
...
> Well, I tried LLVM/CLANG, but Cmake of the sources fairly fails many
> checks especuially for OpenMP.

Yes, it is currently not supported.  I am not sure if there are serious
attempts to add it.


> Using clang++ requisites the usage of the
> new libc++ (CXXFLAGS+= -stdlib=libc++). But this fails with this error:
...
> /usr/ports/devel/freeocl/work/FreeOCL-0.3.6-Source/src/parser/parser.h:118:15:
> error: no viable conversion from 'std::__1::basic_istream<char>' to
> 'const bool'
>                          const bool ok = in.get(c);
>                                     ^    ~~~~~~~~~

This is a bug in FreeOCL.  The istream::get() function returns an
istream reference, which can't be cast directly to bool.  However, there
is a negation operator defined for istream, so the line can be changed
to:

                          const bool ok = !!in.get(c);

I have attached a patch for the port as I have built it here with clang.
I didn't add the dependency on atomic_ops yet, but it should be fairly
trivial.

Note I also needed a fix for Mk/bsd.cmake.mk, otherwise the required
${CPPFLAGS} would not be passed along to CMake, and then the build would
still fail to find the atomic_ops headers in /usr/local/include.

_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-performance
To unsubscribe, send any mail to "[hidden email]"

clangports-devel-freeocl-1.diff (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Help. Porting "FreeOCL" fails (atomic_ops.h missing, CLANG++ libc++ issues ...)

Hartmann, O.
Hello Dimitry,

thanks for your response and patches.


On 09/06/12 14:51, Dimitry Andric wrote:

> On 2012-09-05 16:45, O. Hartmann wrote:
> ...
>> Well, I tried LLVM/CLANG, but Cmake of the sources fairly fails many
>> checks especuially for OpenMP.
>
> Yes, it is currently not supported.  I am not sure if there are serious
> attempts to add it.
>
>
>> Using clang++ requisites the usage of the
>> new libc++ (CXXFLAGS+= -stdlib=libc++). But this fails with this error:
> ...
>> /usr/ports/devel/freeocl/work/FreeOCL-0.3.6-Source/src/parser/parser.h:118:15:
>>
>> error: no viable conversion from 'std::__1::basic_istream<char>' to
>> 'const bool'
>>                          const bool ok = in.get(c);
>>                                     ^    ~~~~~~~~~
>
> This is a bug in FreeOCL.  The istream::get() function returns an
> istream reference, which can't be cast directly to bool.  However, there
> is a negation operator defined for istream, so the line can be changed
> to:
>
>                          const bool ok = !!in.get(c);
>
> I have attached a patch for the port as I have built it here with clang.
> I didn't add the dependency on atomic_ops yet, but it should be fairly
> trivial.
I fixed that, I forgot the pkg-plist, also. Will followup the PR I sent.
it is a simple line:

BUILD_DEPENDS= ...

>
> Note I also needed a fix for Mk/bsd.cmake.mk, otherwise the required
> ${CPPFLAGS} would not be passed along to CMake, and then the build would
> still fail to find the atomic_ops headers in /usr/local/include.

Is this going to be fixed with your patch in the ports tree?

I'm amazed by the speed you came up with the patches ...;-)

My port request can be found here:

http://www.freebsd.org/cgi/query-pr.cgi?pr=171376

and one for providing the OpenCL header:

http://www.freebsd.org/cgi/query-pr.cgi?pr=171375

Matthieu Volat also stated that there is another promising OpenCL port
"Portable OpenCL", pocl. It seems to have a better LLVM support by design:

http://sourceforge.net/apps/mediawiki/pocl/index.php?title=Main_Page

Attached you'll find my first naiv attempt to build a port-Makefile, but
I fail to fetch(1), since there is an authentication error while trying
to fetch from a HTTPS:// source.

My abilities in depp-insight-development are limited, so I'm happy if
some experienced developers could also look at those software projects
and help making a port ;-)

it would be nice having FreeOCL and portable OCL for comparison purposes
available on FreeBSD. I still have the hope to "lurd" more developers
and scientists back to FreeBSD. Never mind ...

oh

Makefile (526 bytes) Download Attachment
signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Help. Porting "FreeOCL" fails (atomic_ops.h missing, CLANG++ libc++ issues ...)

O. Hartmann-4
In reply to this post by Dimitry Andric-4
On 09/06/12 14:51, Dimitry Andric wrote:

> On 2012-09-05 16:45, O. Hartmann wrote:
> ...
>> Well, I tried LLVM/CLANG, but Cmake of the sources fairly fails many
>> checks especuially for OpenMP.
>
> Yes, it is currently not supported.  I am not sure if there are serious
> attempts to add it.
>
>
>> Using clang++ requisites the usage of the
>> new libc++ (CXXFLAGS+= -stdlib=libc++). But this fails with this error:
> ...
>> /usr/ports/devel/freeocl/work/FreeOCL-0.3.6-Source/src/parser/parser.h:118:15:
>>
>> error: no viable conversion from 'std::__1::basic_istream<char>' to
>> 'const bool'
>>                          const bool ok = in.get(c);
>>                                     ^    ~~~~~~~~~
>
> This is a bug in FreeOCL.  The istream::get() function returns an
> istream reference, which can't be cast directly to bool.  However, there
> is a negation operator defined for istream, so the line can be changed
> to:
>
>                          const bool ok = !!in.get(c);
>
> I have attached a patch for the port as I have built it here with clang.
> I didn't add the dependency on atomic_ops yet, but it should be fairly
> trivial.
>
> Note I also needed a fix for Mk/bsd.cmake.mk, otherwise the required
> ${CPPFLAGS} would not be passed along to CMake, and then the build would
> still fail to find the atomic_ops headers in /usr/local/include.

With the patch for Mk/bsd.cmake.mk attached, I can not compile the port
with CLANG, compilation results in

[ 15%] Building CXX object src/CMakeFiles/FreeOCL.dir/image.cpp.o
/usr/ports/devel/freeocl/work/FreeOCL-0.3.6-Source/src/image.cpp:442:27:
error: member access into incomplete type 'struct _cl_event'
                                if (event_wait_list[i]->status < 0)
                                                      ^
/usr/local/include/CL/cl.h:46:16: note: forward declaration of '_cl_event'
typedef struct _cl_event *          cl_event;
               ^
/usr/ports/devel/freeocl/work/FreeOCL-0.3.6-Source/src/image.cpp:449:58:
error: allocation of incomplete type '_cl_event'
                cmd->event = (blocking_read == CL_TRUE || event) ? new
_cl_event(command_queue->context) : NULL;

^~~~~~~~~
/usr/local/include/CL/cl.h:46:16: note: forward declaration of '_cl_event'
typedef struct _cl_event *          cl_event;
               ^
/usr/ports/devel/freeocl/work/FreeOCL-0.3.6-Source/src/image.cpp:463:14:
error: member access into incomplete type '_cl_event'
                        cmd->event->command_queue = command_queue;
                                  ^
/usr/local/include/CL/cl.h:46:16: note: forward declaration of '_cl_event'
typedef struct _cl_event *          cl_event;
               ^
/usr/ports/devel/freeocl/work/FreeOCL-0.3.6-Source/src/image.cpp:464:14:
error: member access into incomplete type '_cl_event'
                        cmd->event->command_type = CL_COMMAND_READ_IMAGE;
                                  ^
/usr/local/include/CL/cl.h:46:16: note: forward declaration of '_cl_event'
typedef struct _cl_event *          cl_event;


Without the patch, CLANG++ doesn't find the atomic_ops.h header as you
wrote.

Oliver


signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Help. Porting "FreeOCL" fails (atomic_ops.h missing, CLANG++ libc++ issues ...)

Dimitry Andric-4
On 2012-09-06 20:28, O. Hartmann wrote:
...

> With the patch for Mk/bsd.cmake.mk attached, I can not compile the port
> with CLANG, compilation results in
>
> [ 15%] Building CXX object src/CMakeFiles/FreeOCL.dir/image.cpp.o
> /usr/ports/devel/freeocl/work/FreeOCL-0.3.6-Source/src/image.cpp:442:27:
> error: member access into incomplete type 'struct _cl_event'
>                                  if (event_wait_list[i]->status < 0)
>                                                        ^
> /usr/local/include/CL/cl.h:46:16: note: forward declaration of '_cl_event'
> typedef struct _cl_event *          cl_event;
>                 ^

Which package installed that /usr/local/include/CL/cl.h file?  It looks
like it should take this header from the source package, not from
whatever is installed into /usr/local.

In the top-level CMakeLists.txt, there is this fragment:

   include_directories(.)
   include_directories(include)
   include_directories(src)

which indicates to CMake it should add -I flags for each of those
directories.  However, it seems -I/usr/local/include is placed earlier
in the arguments of the actual clang++ invocations:

   /usr/bin/clang++ -DFreeOCL_EXPORTS -O2 -pipe -I/usr/local/include
   -fno-strict-aliasing -I/usr/local/include -stdlib=libc++ -std=c++0x
   -DFREEOCL_USE_CXX0X -DFREEOCL_ARCH_amd64 -O3 -ffast-math -fPIC
   -I/usr/work/share/dim/ports/devel/freeocl/work/FreeOCL-0.3.6-Source/.
   -I/usr/work/share/dim/ports/devel/freeocl/work/FreeOCL-0.3.6-Source/include
   -I/usr/work/share/dim/ports/devel/freeocl/work/FreeOCL-0.3.6-Source/src
   -o CMakeFiles/FreeOCL.dir/image.cpp.o -c
   /usr/work/share/dim/ports/devel/freeocl/work/FreeOCL-0.3.6-Source/src/image.cpp
   
So it will take /usr/local/include/CL/cl.h before the cl.h under
${WRKSRC}.

Now, as to how we can convince CMake to put the -I/usr/local/include at
the end... Maybe we should just patch the CMakeLists.txt, but that is a
rather ugly solution. :)
_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-performance
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Help. Porting "FreeOCL" fails (atomic_ops.h missing, CLANG++ libc++ issues ...)

Jan Beich-2
Dimitry Andric <[hidden email]> writes:

> Now, as to how we can convince CMake to put the -I/usr/local/include at
> the end... Maybe we should just patch the CMakeLists.txt, but that is a
> rather ugly solution. :)

Try using

  CPPFLAGS+= -isystem${LOCALBASE}/include

gcc(1) (and clang) has a flag for systems broken by design:

    -isystem dir
        Search dir for header files, after all directories specified by -I
        but before the standard system directories.  Mark it as a system
        directory, so that it gets the same special treatment as is applied
        to the standard system directories.  If dir begins with "=", then
        the "=" will be replaced by the sysroot prefix; see --sysroot and
        -isysroot.

For example, firefox uses it to avoid picking up lang/spidermonkey headers.
_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-performance
To unsubscribe, send any mail to "[hidden email]"