AvtechScientific / ASL

Advanced Simulation Library - hardware accelerated multiphysics simulation platform.
http://asl.org.il
GNU Affero General Public License v3.0
217 stars 54 forks source link

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

Open simingbayer opened 7 years ago

simingbayer commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

@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_f11*0.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_f18*0.041666666666666664354)+pv_f19*0.041666666666666664354)+pv_f20*0.041666666666666664354)+pv_f21*0.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_f12*0.33333333333333331483+pv_f15*-0.33333333333333331483)+pv_f18*0.041666666666666664354)+pv_f19*0.041666666666666664354)+pv_f20*0.041666666666666664354)+pv_f21*0.041666666666666664354)+pv_f22*-0.041666666666666664354)+pv_f23*-0.041666666666666664354)+pv_f24*-0.041666666666666664354)+pv_f25*-0.041666666666666664354))); ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ Thanks, best, Siming
AvtechScientific commented 7 years ago
  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 commented 7 years ago

Thank you! I will try these solutions!

best, Siming

simingbayer commented 7 years ago

@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 commented 7 years ago
  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 commented 7 years ago

@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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

Thanks for the information!

Am 28.07.2017 um 00:21 schrieb Dr. Rolf Jansen notifications@github.com:

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

I found a solution to this problem following the hint to the issue https://github.com/oseiskar/raytracer/issues/1 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.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/AvtechScientific/ASL/issues/31#issuecomment-318503009, or mute the thread https://github.com/notifications/unsubscribe-auth/AFZ8eN19tqmsm6A-EE8f0JsvQ7411ACNks5sSQ1vgaJpZM4MKmF0.

Senui commented 6 years ago

@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 commented 6 years ago

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 commented 6 years ago

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

Thank you very much.