Giter Site home page Giter Site logo

erickingxu / metalqd Goto Github PK

View Code? Open in Web Editor NEW

This project forked from brianswift/metalqd

0.0 2.0 0.0 1.03 MB

QD (Quad Double) Extended Precision Library ported to Metal GPU Language

License: Other

Makefile 17.83% M4 4.98% Fortran 30.30% C++ 44.90% C 1.60% Shell 0.39%

metalqd's Introduction

Metal QD: QD extended precision library for Metal

Metal QD is (preliminary work on) a port of the QD extended precision library to Apple's Metal GPU compute language.

QD is a library for Quad-Double arithmetic in which extended precision numbers are represented by the unevaluated sum of four double precision machine numbers. QD comes from http://crd-legacy.lbl.gov/~dhbailey/mpdist/

Metal QD adapts QD to the Metal environment primarily by using single precision floats instead of doubles. This allows calculations with 96-bits of precision. This port also disables references to features unavailable on the GPU, such as iostream, string, limits, cmath.

Metal QD is based off of qd-2.3.17

What is supported?

  • Constructors
  • Arithmetic operators: +, -, *, =, +=, -=
  • Comparison operators: <, >, ==, !=
  • Special Functions: sqr(), mul_pwr2()

What hasn't been ported?

  • Anything not implemented in the inline library.
  • Division
  • Trig and other transendental functions
  • The DD (Double-Double) type
  • I/O

Usage

  • Copy these files to project: metal_qd.h, qd_real.h, qd_config.h, qd_inline.h, inline.h

  • In Metal or Objective-C++ source file: #include "metal_qd.h"

  • Disable Metal's unsafe floating-point optimizations. Add -fno-fast-math to Build Phases -> Compile Sources -> Compiler Flags for any Metal files using metal_qd.h

  • Read the README_QD section C. Programming techniques

Example Code Snipet

qd_real q;
q=1.;            // native 1.0 converted to qd_real q
q+=exp2(-95.);   // native 2^-95 added to qd_real q
// q now represents 1.000000000000000000000000000025
// This has more precision than can be represented in a native double

// Conversion to/from float4 usefull for passing values between CPU and GPU
simd::float4 vq;
vq=to_float4(q); // Convert qd_real to float4

qd_real qvq;     // Convert and float4 back to qd_real
qvq=vq;

Find the above in tests/metal_qd_test.cpp

Future Work

  • Port non-inline and DD portions of library
  • Create proper Metal framework
  • Create demo app using Metal QD on GPU (in addition to CPU)
  • Test having both QD and Metal_QD in same CPU source
  • Update documentation to reflect Metal_QD

metalqd's People

Contributors

brianswift avatar

Watchers

James Cloos avatar EricKing avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.