Hi:
     I write the opencl demo. In this demo , I wrote the half2 type .  But it 
compile it failed.

   The output as below:
                2018-07-13 03:24:42.805561780] POCL: in fn void 
pocl_incr_device_ref() at line 294:
*** INFO ***  [GPUStub] void pocl_incr_device_ref() devices_ref=2
### use a saved llvm::Module
### fetching kernel metadata for kernel testHalf program 0x7f80a43000 input 
llvm::Module 0x7f80bf9580
[2018-07-13 03:24:42.805712080] POCL: in fn cl_mem POclCreateBuffer(cl_context, 
cl_mem_flags, size_t, void *, cl_int *) at line 94:
[2018-07-13 03:24:42.805752880] POCL: in fn cl_int 
POclEnqueueNDRangeKernel(cl_command_queue, cl_kernel, cl_uint, const size_t *, 
const size_t *, const size_t *, cl_uint, const cl_event *, cl_event *) at line 
133:
*** INFO ***  Preferred WG size multiple 8
[2018-07-13 03:24:42.805786020] POCL: in fn cl_int 
POclEnqueueNDRangeKernel(cl_command_queue, cl_kernel, cl_uint, const size_t *, 
const size_t *, const size_t *, cl_uint, const cl_event *, cl_event *) at line 
209:
*** INFO ***  Queueing kernel testHalf with local size 1 x 1 x 1 group sizes 3 
x 1 x 1...
### calling the kernel compiler for kernel testHalf local_x 1 local_y 1 local_z 
1 parallel_filename: 
/sdcard/pocl/kcache/HK/BOCDHECGLACEHDFDNAGEMLIFMJJKNKIKKHGMB/testHalf/1-1-1/parallel.bc
### cloning the preloaded LLVM IR
[2018-07-13 03:24:42.806801840] POCL: in fn llvm::Module 
*kernel_library(cl_device_id) at line 1341:
*** INFO ***  Using 
/data/data/org.pocl.libs/files/share/pocl/kernel-aarch64-unknown-linux-android-generic.bc
 as the built-in lib.
### autovectorizer enabled

LV: Checking a loop in "_cl_printf" from /sdcard/pocl/kcache/temp_t6kfN4.cl
LV: Loop hints: force=? width=0 unroll=0
LV: Found a loop: .lr.ph.i
LV: Can't if-convert the loop.
LV: Not vectorizing: Cannot prove legality.

LV: Checking a loop in "_cl_printf" from /sdcard/pocl/kcache/temp_t6kfN4.cl
LV: Loop hints: force=? width=0 unroll=0
LV: Found a loop:
LV: Can't if-convert the loop.
LV: Not vectorizing: Cannot prove legality.

LV: Checking a loop in "_cl_printf" from /sdcard/pocl/kcache/temp_t6kfN4.cl
LV: Loop hints: force=? width=0 unroll=0
LV: Found a loop:
LV: Can't if-convert the loop.
LV: Not vectorizing: Cannot prove legality.

LV: Checking a loop in "_cl_printf" from /sdcard/pocl/kcache/temp_t6kfN4.cl
LV: Loop hints: force=? width=0 unroll=0
LV: Found a loop:
LV: Can't if-convert the loop.
LV: Not vectorizing: Cannot prove legality.

LV: Checking a loop in "_cl_printf" from /sdcard/pocl/kcache/temp_t6kfN4.cl
LV: Loop hints: force=? width=0 unroll=0
LV: Found a loop:
LV: Can't if-convert the loop.
LV: Not vectorizing: Cannot prove legality.

LV: Checking a loop in "_cl_printf" from /sdcard/pocl/kcache/temp_t6kfN4.cl
LV: Loop hints: force=? width=0 unroll=0
LV: Found a loop:
LV: Can't if-convert the loop.
LV: Not vectorizing: Cannot prove legality.

LV: Checking a loop in "_cl_printf" from /sdcard/pocl/kcache/temp_t6kfN4.cl
LV: Loop hints: force=? width=0 unroll=0
LV: Not vectorizing: Cannot prove legality.

LV: Checking a loop in "_cl_printf" from /sdcard/pocl/kcache/temp_t6kfN4.cl
LV: Loop hints: force=? width=0 unroll=0
LV: Not vectorizing: Cannot prove legality.

LV: Checking a loop in "_cl_printf" from /sdcard/pocl/kcache/temp_t6kfN4.cl
LV: Loop hints: force=? width=0 unroll=0
LV: Not vectorizing: Cannot prove legality.

LV: Checking a loop in "_cl_printf" from /sdcard/pocl/kcache/temp_t6kfN4.cl
LV: Loop hints: force=? width=0 unroll=0
LV: Not vectorizing: Cannot prove legality.

LV: Checking a loop in "_cl_printf" from /sdcard/pocl/kcache/temp_t6kfN4.cl
LV: Loop hints: force=? width=0 unroll=0
LV: Not vectorizing: Cannot prove legality.
/usr1/code/source/pocl/llvm-3.8.0.src/lib/Bitcode/Writer/ValueEnumerator.h:132: 
unsigned int llvm::ValueEnumerator::getTypeID(llvm::Type*) const: assertion "I 
!= TypeMap.end() && "Type not in ValueEnumerator!"" failed
libc: 
/usr1/code/source/pocl/llvm-3.8.0.src/lib/Bitcode/Writer/ValueEnumerator.h:132: 
unsigned int llvm::ValueEnumerator::getTypeID(llvm::Type*) const: assertion "I 
!= TypeMap.end() && "Type not in ValueEnumerator!"" failed

the test is abort now; I have add it ” pragma OPENCL EXTENSION cl_khr_fp16 : 
enable” to cl file  but it still faled

Env:
                CPU: AARCH64
                OS: LINUX / android
                Pocl_version 0.13 + llvm 3.8
                GPU: no



Attachment: Half.cl
Description: Half.cl

#include <stdio.h>
#include <stdlib.h>
#include "CL/cl.h"


__fp16 Add( __fp16 a, __fp16 b ) {
        return a + b;
}

char *ReadSources(const char *fileName)
{
    long size;
    char *src;
    size_t res;
    FILE *file = fopen(fileName, "rb");
    if (!file)
    {
        printf("ERROR: Failed to open file '%s'", fileName);
        return NULL;
    }

    if (fseek(file, 0, SEEK_END))
    {
        printf("ERROR: Failed to seek file '%s'", fileName);
        fclose(file);
        return NULL;
    }

    size = ftell(file);
    if (size == 0)
    {
        printf("ERROR: Failed to check position on file '%s'", fileName);
        fclose(file);
        return NULL;
    }

    rewind(file);

    src = (char *)malloc(sizeof(char) * size + 1);
    if (!src)
    {
        printf("ERROR: Failed to allocate memory for file '%s'", fileName);
        fclose(file);
        return NULL;
    }
//#ifdef DBG_MSG
    printf("Reading file '%s' (size %ld bytes)", fileName, size);
//#endif
    res = fread(src, 1, sizeof(char) * size, file);
    if (res != sizeof(char) * size)
    {
        printf("ERROR: Failed to read file '%s'", fileName);
        fclose(file);
        free(src);
        return NULL;
    }

    src[size] = '\0'; /* NULL terminated */
    fclose(file);
    //file = NULL;

    return src;
}


int main(int argc, char ** argv) {
        __fp16 a = 3.5;
        printf("return  %f \n", (float)Add(a, 0.53) );

        //Create OpenCL
        char * src = ReadSources("Half.cl");
        cl_context context_id;
        cl_device_id device_id;
        cl_platform_id platform_id;
        cl_uint num_platforms;
        cl_int status;
        size_t global_size[2];
                
        cl_int err = clGetPlatformIDs(1, &platform_id, &num_platforms);
        cl_uint num_devices;
        clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_CPU, 1, &device_id, 
&num_devices);
        
        context_id = clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU, NULL, 
NULL, NULL);
        cl_program  prog  = clCreateProgramWithSource(context_id, 1, (const 
char **)&src, NULL, &status);
        status = clBuildProgram(prog, 1, &device_id, "-I.", NULL, NULL);
        
        cl_command_queue  cmdQueue = clCreateCommandQueue(context_id, 
device_id, 0, &status);
        
        cl_kernel  kernel = clCreateKernel( prog, "testHalf", &status);
        __fp16 host[4] = {0.3, 4.8, 2.5, 3.1};
        cl_mem mem1 = clCreateBuffer(context_id,  CL_MEM_READ_WRITE, 
sizeof(__fp16) * 4, host, &status);
        clSetKernelArg(kernel, 0, sizeof(cl_mem), &mem1);
        global_size[0] = 3;

         status = clEnqueueNDRangeKernel(cmdQueue,
                                    kernel,
                                    1,
                                    NULL,
                                    global_size,
                                    NULL,/*&localSize,*/
                                    0,
                                    NULL,
                                    NULL);

        clFinish( cmdQueue );


        
        return 0;
}

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
pocl-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pocl-devel

Reply via email to