Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot downconvert and widen scalar type 'double' to vector type '__float4' running examples #31

Open
simingbayer opened this issue Feb 23, 2017 · 14 comments

Comments

@simingbayer
Copy link

simingbayer commented Feb 23, 2017

Hi guys,

I just compiled ASL on my machine (macbook pro) following the instruction successfully. However, once I run the exmples, I get the following error:

Cannot downconvert and widen scalar type 'double' to vector type '__float4'
libc++abi.dylib: terminating with uncaught exception of type std::logic_error: ASL ERROR: Program::build() (-11).

And I tried every example, and get the same error. Is this an OpenCL issue? Does anybody knows how to solve it?

best,
Siming

@AvtechScientific
Copy link
Owner

Hello @simingbayer,

take a look a this issue and the attached patch maybe it's relevant for your OS. Let us know whether it helped.

@simingbayer
Copy link
Author

Thank you for your answer! Actually I have already read this post before I open a new issue here. That is also where I got the assumption that my openCL compiler may be the problem. So should I try to use another version of openCL ? If yes, which one should I use? Or is there anyother way to solve this problem (because in the older isse, there is no detailed solution for the problem)? Thanks!

@simingbayer
Copy link
Author

simingbayer commented Feb 27, 2017

@AvtechScientific Hi guys,

I am trying to use the poroelastic file. With the debugger I find out, the error was called in this order. line 124 poroelastic.cc: elasticity ->init() -->line 133 aslFDPoroElasticity.cxx kernel.

Please help me to fix this bug!!! I really need this framework, especially the one for poroelasticity.

Here is a part of the error output:

Data initialization... -2450 0 0 ; 62500; 0.0015625
Finished
Numerics initialization...
BUILD LOG


:54:15: error: Cannot downconvert and widen scalar type 'double' to vector type '__float4'
(pv_f7=pv_f110.5);
~~~~~~^~~~
:55:26: error: Cannot downconvert and widen scalar type 'double' to vector type '__float4'
(pv_f4=(-(((((((((pv_f12
0.33333333333333331483+pv_f15*-0.33333333333333331483)+pv_f180.041666666666666664354)+pv_f190.041666666666666664354)+pv_f200.041666666666666664354)+pv_f210.041666666666666664354)+pv_f22*-0.041666666666666664354)+pv_f23*-0.041666666666666664354)+pv_f24*-0.041666666666666664354)+pv_f25*-0.041666666666666664354)));
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
:55:56: error: Cannot downconvert and widen scalar type 'double' to vector type '__float4'
(pv_f4=(-(((((((((pv_f120.33333333333333331483+pv_f15-0.33333333333333331483)+pv_f180.041666666666666664354)+pv_f190.041666666666666664354)+pv_f200.041666666666666664354)+pv_f210.041666666666666664354)+pv_f22*-0.041666666666666664354)+pv_f23*-0.041666666666666664354)+pv_f24*-0.041666666666666664354)+pv_f25*-0.041666666666666664354)));
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

Thanks,
best,
Siming

@AvtechScientific
Copy link
Owner

  1. Try to use another version of OpenCL - 1.2 should work.
  2. Try another OS - e.g. Debian Linux
  3. The patch of the quoted issue contains possible solution: there they added an "f" after constants, e.g.

const float3 slopes = 1.0 / ray;

was changed to:

const float3 slopes = 1.0f / ray;

So in our case you may try to change:

(pv_f7=pv_f11*0.5);

to

(pv_f7=pv_f11*0.5f);

You can't do this directly, so look for places where constants are fed into kernel, and add an "f" afterwards. Please let us know about your progress.

@simingbayer
Copy link
Author

Thank you! I will try these solutions!

best,
Siming

@simingbayer
Copy link
Author

simingbayer commented Feb 28, 2017

@AvtechScientific Hi guys,

For the 1) st solution: According to the information provided by Apple, MacBook Pro (mid 2015) is delivered Intel Iris Pro GPU and with OpenCL installed. On my machine, the OpenCL version is 2.8.6. The output of cmake was: openCL version 1.1-not found, openCL version 1.2 -- not found,openCL version 2.0 -not found. But the openCL library was found and it is the default version installed by Apple. Unlike in Linux machine, OpenCL on a MacBook can only updated/changed by Apple. Is that possible that the ASL framework doesn´t works with OpenCL 2.8.6 version?

Looking for CL_VERSION_2_0
Looking for CL_VERSION_2_0 - not found
Looking for CL_VERSION_1_2
Looking for CL_VERSION_1_2 - not found
Looking for CL_VERSION_1_1
Looking for CL_VERSION_1_1 - not found
Looking for CL_VERSION_1_0
Looking for CL_VERSION_1_0 - not found
Found OpenCL: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/OpenCL.framework (Required is at least version "1.1")

For the 3) rd solution: I've change the constant to .5f and also changed every variable declared as double to float. It didn´t help.

For the 2)nd solution: Since I don´t have a Linux computer, I am try to set up one. It will take some time. So I still don´t know if it works.

Do you have anyother idea?

Thanks in advance.
best,
Siming

@AvtechScientific
Copy link
Owner

  1. There is no OpenCL version 2.8.6 - current stable version is 2.1 and 2.2 has provisional status. 2.8.6 is probably the version of your driver.

  2. Can you show what did you change and what was the error output?

  3. That is the best solution as ASL was developed/tested on Linux.

@simingbayer
Copy link
Author

simingbayer commented Mar 3, 2017

@AvtechScientific
Poroelastic_downconvert_Error.txt

  1. Oh sorry, you're right. 2.8.6 is my driver. According to the information provided by Apple, my machine is pre-installed with OpenCL 1.2.

  2. Attached my error output while runing poroelastic. It was caused in the runtime, in the line 124 elasticity->init();. I have changed every number in the function void FDPoroElasticity::init() in aslFDPoroElasticity.cxx to float. Also the declaration of VectorTemplate (because the variable du in aslFDPoroElasticity.cxx is initialized with VectorTemplate ) was changed to float. But I still get the same error.

I also noticed that the parameters a_f1 to a_f11 (look at the error output, Kernel source code section) was declared as type float4 before elasticity->init();. For some reason, it changed to type float while calling elasticity->init();. Is there anything wrong?

  1. Yes, I am trying to do it. But first I need to set up one Linux machine. This will takes some time. So it will be really cool, if we can solve the problem on Mac.

Thank you!!
best,
Siming

@harishopadrishta
Copy link

Hi,

I am facing a similar problem when I installed ASL on my Mac. My OS is Mac OSSierra. Have you solved this issue and could you provide me a status on this issue?

@cyclaero
Copy link
Contributor

cyclaero commented Jul 27, 2017

I just ran into the same issue with macOS 10.12.6 on a Mac mini late 2014 with Intel Core i5 when trying to run the asl-locomotive example.

I found a solution to this problem following the hint to the issue in message 2 of this thread.

In ...ASL/src/acl/DataTypes/aclConstant.h I changed lines 54 and 60 to:

return (typeid(T) == typeid(float) || typeid(T) == typeid(double)) ? valueStr+"f" : valueStr;

With that in place, the simulation is running now.

I am not an expert in C++, and perhaps there is a better place for adding a trailing "f" on floating point constants.

@simingbayer
Copy link
Author

simingbayer commented Jul 28, 2017 via email

@Senui
Copy link

Senui commented Nov 10, 2017

@cyclaero Adding a trailing "f" does not work when valueStr does not have a decimal separator. For example, float x = 42f will give the compile error invalid digit 'f' in decimal constant. Safer (still hacky though) would be:

return (typeid(T) == typeid(float) || typeid(T) == typeid(double)) ? "(float)"+valueStr : valueStr;

or a static_cast<float> should also work.

In any case precision is lost because of the possible double to float conversion, so the developers might want to find a more elegant way to take care of this in their kernel generator.

@franz
Copy link

franz commented Nov 11, 2017

I'm now hitting the same error when running ASL with pocl. The error comes from LLVM:

266: error: /tmp/POCL_CACHE/tempfile_38wM6Z.cl:12:1681: cannot convert between vector values of different size ('float8' (vector of 8 'float' values) and 'double')

I think that LLVM is correct here, OpenCL 1.2 standard, page 209, on implicit conversions:

Implicit conversions between built-in vector data types are disallowed.

@cyclaero
Copy link
Contributor

@Senui, I like the "(float)"+valueStr notation, this is working for me.

Thank you very much.

cyclaero added a commit to cyclaero/ASL that referenced this issue Nov 12, 2017
…tor data types (here double to float) are disallowed in OpenCL 1.2, and LLVM does enforce this. Therefore explicitly coerce ACL constants to float.
AvtechScientific added a commit that referenced this issue Nov 12, 2017
issue #31 – LLVM does not allow Implicit conversions between built-in vector data types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants