WebCL
Khronos
 

WebCL KHR_fp16 Extension Specification

Name

KHR_fp16

Contact

WebCL working group (public_webcl 'at' khronos.org)

Contributors

Tomi Aarnio, Nokia Research

Mikael Bourges-Sevenier, Advanced Micro Devices

Steven Eliuk, Samsung Electronics

Tasneem Brutch, Samsung Electronics

Members of the WebCL working group

Version

Last modified date: August 14, 2014
Revision: 2

Number

WebCL extension #2

Dependencies

Written against the WebCL API 1.0 specification.

Overview

This extension exposes the cl_khr_fp16 functionality to WebCL.

There are no WebCL-specific behavioral changes.

Consult the above extension for documentation, issues and new functions and enumerants.

When this extension is enabled:

IDL

partial interface WebCL {
  CLenum DEVICE_PREFERRED_VECTOR_WIDTH_HALF = 0x1034;
  CLenum DEVICE_NATIVE_VECTOR_WIDTH_HALF    = 0x103C;
};
  

Sample Code

// Enables KHR_fp16 on all devices that support it, and
// returns those devices in an array.  If there are no
// such devices, an empty array is returned.

function getFP16Devices() {
  var devices = [];
  webcl.getPlatforms().forEach(function(plat) {
    plat.getDevices().forEach(function(dev) {
      var isSupported = dev.enableExtension("KHR_fp16");
      if (isSupported) devices.push(dev);
    });
  });

  if (devices.length === 0) {
    console.error("Your system does not support KHR_fp16.");
  } else {
    console.info("Enabled KHR_fp16 on "+devices.length+" devices.");
    console.info("Make sure to include '#pragma OPENCL EXTENSION cl_khr_fp16 : enable' in your kernel code.");
  }
  return devices;
}

Revision History

Revision 1, 2013/11/19

Revision 2, 2014/08/14