[VENTUS][RISCV][fix&feat] Add cl_khr_fp64 support and add missing header file

This commit is contained in:
zhoujing 2023-07-13 09:21:50 +08:00
parent 7b949c1868
commit 760e86baf2
4 changed files with 71 additions and 8 deletions

View File

@ -176,10 +176,10 @@ build_libclc() {
-DCMAKE_LLAsm_COMPILER_WORKS=ON \
-DCMAKE_CLC_COMPILER_WORKS=ON \
-DCMAKE_CLC_COMPILER_FORCED=ON \
-DCMAKE_LLAsm_FLAGS="-target riscv32 -mcpu=ventus-gpgpu -cl-std=CL2.0" \
-DCMAKE_CLC_FLAGS="-target riscv32 -mcpu=ventus-gpgpu -cl-std=CL2.0 -I${DIR}/libclc/generic/include" \
-DCMAKE_LLAsm_FLAGS="-target riscv32 -mcpu=ventus-gpgpu -cl-std=CL2.0 -Dcl_khr_fp64" \
-DCMAKE_CLC_FLAGS="-target riscv32 -mcpu=ventus-gpgpu -cl-std=CL2.0 -I${DIR}/libclc/generic/include -Dcl_khr_fp64" \
-DLIBCLC_TARGETS_TO_BUILD="riscv32--" \
-DCMAKE_CXX_FLAGS="-I ${DIR}/llvm/include/ -std=c++17" \
-DCMAKE_CXX_FLAGS="-I ${DIR}/llvm/include/ -std=c++17 -Dcl_khr_fp64" \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_INSTALL_PREFIX=${VENTUS_INSTALL_PREFIX} \

View File

@ -133,6 +133,7 @@ public:
Opts["__opencl_c_3d_image_writes"] = true;
Opts["cl_khr_3d_image_writes"] = true;
Opts["cl_khr_byte_addressable_store"] = true;
Opts["cl_khr_fp64"] = true;
}
LangAS getOpenCLTypeAddrSpace(OpenCLTypeKind TK) const override {

View File

@ -0,0 +1,63 @@
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#ifndef LIBM_H
#define LIBM_H
#define FE_INVALID 1
#define __FE_DENORM 2
#define FE_DIVBYZERO 4
#define FE_OVERFLOW 8
#define FE_UNDERFLOW 16
#define FE_INEXACT 32
#define FE_ALL_EXCEPT 63
#define FE_TONEAREST 0
#define FE_DOWNWARD 0x400
#define FE_UPWARD 0x800
#define FE_TOWARDZERO 0xc00
typedef unsigned short fexcept_t;
typedef struct {
unsigned short __control_word;
unsigned short __unused1;
unsigned short __status_word;
unsigned short __unused2;
unsigned short __tags;
unsigned short __unused3;
unsigned int __eip;
unsigned short __cs_selector;
unsigned int __opcode;
unsigned int __unused4;
unsigned int __data_offset;
unsigned short __data_selector;
unsigned short __unused5;
unsigned int __mxcsr;
} _fenv_t;
#define FE_DFL_ENV ((const fenv_t *)-1)
static int feclearexcept(int mask) { return 0; }
static int feraiseexcept(int mask) { return 0; }
static int _fetestexcept(int mask) { return 0; }
static int fegetround(void) { return FE_TONEAREST; }
static int fesetround(int r) { return 0; }
static int fegetenv(_fenv_t *envp) { return 0; }
static int fesetenv(const _fenv_t *envp) { return 0; }
#endif // LIBM_H

View File

@ -16,8 +16,11 @@
//
//===----------------------------------------------------------------------===//
#include "types.h"
#ifdef cl_khr_fp64
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
#include "types.h"
float __nextafterf(float x, float y) {
int hx, hy, ix, iy;
@ -96,10 +99,6 @@ float __nextafterf(float x, float y) {
return x;
}
#ifdef cl_khr_fp64
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
double
__nextafter (double x, double y)
{