Skip to content

How to force to generate "TypeFloat 32" instead of "TypeFloat 64" when calling "printf("%f") #57

@ncybmh99

Description

@ncybmh99

Given a simple 'printf' test kernel as:

__kernel void test(const float x)
{
printf("%f\n", x);
}

My question is:

Suppose the platform doesn't support 'double'. Is there any way for the tool to generate "TypeFloat 32" instead of "TypeFloat 64" and not to introduce "FConvert" when calling "printf"? Is there any compilation options to control it?

The tool generates the following SPV code:

119734787 65536 393230 25 0
2 Capability Addresses
2 Capability Kernel
2 Capability Float64
5 ExtInstImport 1 "OpenCL.std"
3 MemoryModel 1 2
5 EntryPoint 6 16 "test"
3 Source 3 102000
4 Name 12 ".str"
3 Name 17 "x"
4 Name 18 "entry"
4 Name 20 "conv"
4 Name 24 "call"
3 Decorate 12 Constant
4 Decorate 12 Alignment 1
4 TypeInt 2 8 0
4 TypeInt 7 32 0
4 Constant 2 3 37
4 Constant 2 4 102
4 Constant 2 5 10
4 Constant 2 6 0
4 Constant 7 8 4
4 Constant 7 21 0
4 TypeArray 9 2 8
4 TypePointer 11 0 9
2 TypeVoid 13
3 TypeFloat 14 32
4 TypeFunction 15 13 14
3 TypeFloat 19 64
4 TypePointer 22 0 2
7 ConstantComposite 9 10 3 4 5 6
5 Variable 11 12 0 10

5 Function 13 16 0 15
3 FunctionParameter 14 17

2 Label 18
4 FConvert 19 20 17
6 InBoundsPtrAccessChain 22 23 12 21 21
7 ExtInst 7 24 1 printf 23 20
1 Return

1 FunctionEnd

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions