OpenCL : invalid operands to binary expression

Hi Sam,
   Thanks for your reply and suggestions.
I followed your suggestion, and add necessary source code to CI_opencl.cpp
and input file. However there are same problems.

Here is my input file(atom_kernel.h) and clang consumer file(CI_opencl.cpp)
and error output (error.output). Makefile is the same.

almost the same error. Compiler still complain types and sse instructions
missing.

Thanks,
Xiuxia

Hi,

Have you ensured you are meeting this requirement?

    // <Warning!!> -- Platform Specific Code lives here
    // This depends on A) that you're running linux and
    // B) that you have the same GCC LIBs installed that
    // I do.
    // Search through Clang itself for something like this,
    // go on, you won't find it. The reason why is Clang
    // has its own versions of std* which are installed under
    // /usr/local/lib/clang/<version>/include/
    // See somewhere around Driver.cpp:77 to see Clang adding
    // its version of the headers to its include path.

you're using the gcc include path, and i've always used the clang path instead.

cheers,
sam

Sam Parker
Research Student
Electronic Systems Design Group
Loughborough University
UK

Hi Sam,
Thanks for your advice. I’ve tried to include clang header path instead of gcc header, and it works, and the compiler doesn’t complain the following 2 kinds of errors anymore:

  1. unknown builtin ‘__builtin_ia32_cmpneqps’
  2. error: invalid conversion between vector type ‘__m128’ and integer type ‘int’ of different size

However there are some other 5 kinds of errors reported as before,
/usr/include/stdlib.h:337:4: error: unknown type name ‘size_t’; did you mean ‘ssize_t’?

/usr/include/stdlib.h:857:20: error: unknown type name ‘wchar_t’

/sandbox/xiuxia/llvm_build/Debug+Asserts/lib/clang/3.4/include/mm_malloc.h:33:44: error: unknown type name ‘size_t’; did you mean ‘ssize_t’?

/usr/include/CL/cl.h:562:17: error: redefinition of parameter ‘size_t’

/sandbox/xiuxia/libclc/libclc/generic/include/clc/integer/abs.inc:1:41: error: conflicting types for ‘abs’

atom_kernel.h:45:24: error: invalid operands to binary expression (‘MMD_floatK3’ (aka ‘struct sdouble3’) and ‘MMD_floatK3’)

I am not very familiar with clang, and find it is difficult to find materials about how to learning clang. I feel perplexed when encounter this kind of problems. Hope you could give me some suggestions.

Best,
Xiuxia

Ok, so we're getting somewhere! i'd remove the /usr/include from your search path too, i suspect there's a conflict and kernels shouldn't need anything that
isn't included from clc.h - i think.

Looking at your kernels, I'd also remove the includes too. and if MMD_floatK3 are just a renaming for float3 - why not just use the float3 specifier?

hope that helps,
sam

Sam Parker
Research Student
Electronic Systems Design Group
Loughborough University
UK

Hi Sam,
After I remove the /usr/include path.
5 kinds of errors dispear. But there is still one error left, /sandbox/xiuxia/llvm_build/Debug+Asserts/lib/clang/3.4/include/mm_malloc.h:27:10: fatal error: ‘stdlib.h’ file not found.

stdlib is under /usr/include , and it include lots of other heads which is also located in /usr/include.

Thanks,
Xiuxia

ok, also try adding ci.getHeaderSearchOpts().ResourceDir = "path/to/clang";

sam

Sam Parker
Research Student
Electronic Systems Design Group
Loughborough University
UK

Hi Sam,
I didn’t understand /path/to/clang.
I can only find stdlib.h under llvm’s source directory .

zhangxiuxia@bb30:/sandbox/xiuxia/llvm$ find ./ -name “stdlib.h”
./projects/compiler-rt/SDKs/darwin/usr/include/stdlib.h
./projects/compiler-rt/SDKs/linux/usr/include/stdlib.h

Which is /sandbox/xiuxia/llvm, and llvm’s build directory is /sandbox/xiuxia/llvm_build.
I couldn’t find stdlib.h

I tried to add one line
ci.getHeaderSearchOpts().ResourceDir = “/sandbox/xiuxia/llvm_build/Debug+Asserts/lib/clang/3.4/”;

I also tried
hso->AddPath("/sandbox/xiuxia/llvm/projects/compiler-rt/SDKs/linux/usr/include",clang::frontend::Angled, false, false);

separately, the first one has same errors,
the second one generate more errors.

So what do you mean by /path/to/clang ?

Thanks,
Xiuxia