/*
Copyright (c) 2010-2011, Advanced Micro Devices, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following
disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
If you use the software (in whole or in part), you shall adhere to all applicable U.S., European, and other export
laws, including but not limited to the U.S. Export Administration Regulations ("EAR"), (15 C.F.R. Sections 730 through
774), and E.U. Council Regulation (EC) No 1334/2000 of 22 June 2000. Further, pursuant to Section 740.6 of the EAR,
you hereby certify that, except pursuant to a license granted by the United States Department of Commerce Bureau of
Industry and Security or as otherwise permitted pursuant to a License Exception under the U.S. Export Administration
Regulations ("EAR"), you will not (1) export, re-export or release to a national of a country in Country Groups D:1,
E:1 or E:2 any restricted technology, software, or source code you receive hereunder, or (2) export to Country Groups
D:1, E:1 or E:2 the direct product of such technology or software, if such foreign produced direct product is subject
to national security controls as identified on the Commerce Control List (currently found in Supplement 1 to Part 774
of EAR). For the most current Country Group listings, or for additional information about the EAR or your obligations
under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/.
*/
package com.amd.aparapi;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
import com.amd.aparapi.annotation.Experimental;
import com.amd.aparapi.annotation.OpenCLDelegate;
import com.amd.aparapi.annotation.OpenCLMapping;
import com.amd.aparapi.exception.DeprecatedException;
import com.amd.aparapi.internal.model.ClassModel.ConstantPool.MethodReferenceEntry;
import com.amd.aparapi.internal.util.UnsafeWrapper;
/**
* A <i>kernel</i> encapsulates a data parallel algorithm that will execute either on a GPU
* (through conversion to OpenCL) or on a CPU via a Java Thread Pool.
* <p>
* To write a new kernel, a developer extends the <code>Kernel</code> class and overrides the <code>Kernel.run()</code> method.
* To execute this kernel, the developer creates a new instance of it and calls <code>Kernel.execute(int globalSize)</code> with a suitable 'global size'. At runtime
* Aparapi will attempt to convert the <code>Kernel.run()</code> method (and any method called directly or indirectly
* by <code>Kernel.run()</code>) into OpenCL for execution on GPU devices made available via the OpenCL platform.
* <p>
* Note that <code>Kernel.run()</code> is not called directly. Instead,
* the <code>Kernel.execute(int globalSize)</code> method will cause the overridden <code>Kernel.run()</code>
* method to be invoked once for each value in the range <code>0...globalSize</code>.
* <p>
* On the first call to <code>Kernel.execute(int _globalSize)</code>, Aparapi will determine the EXECUTION_MODE of the kernel.
* This decision is made dynamically based on two factors:
* <ol>
* <li>Whether OpenCL is available (appropriate drivers are installed and the OpenCL and Aparapi dynamic libraries are included on the system path).</li>
* <li>Whether the bytecode of the <code>run()</code> method (and every method that can be called directly or indirectly from the <code>run()</code> method)
* can be converted into OpenCL.</li>
* </ol>
* <p>
* Below is an example Kernel that calculates the square of a set of input values.
* <p>
* <blockquote><pre>
* class SquareKernel extends Kernel{
* private int values[];
* private int squares[];
* public SquareKernel(int values[]){
* this.values = values;
* squares = new int[values.length];
* }
* public void run() {
* int gid = getGlobalID();
* squares[gid] = values[gid]*values[gid];
* }
* public int[] getSquares(){
* return(squares);
* }
* }
* </pre></blockquote>
* <p>
* To execute this kernel, first create a new instance of it and then call <code>execute(Range _range)</code>.
* <p>
* <blockquote><pre>
* int[] values = new int[1024];
* // fill values array
* Range range = Range.create(values.length); // create a range 0..1024
* SquareKernel kernel = new SquareKernel(values);
* kernel.execute(range);
* </pre></blockquote>
* <p>
* When <code>execute(Range)</code> returns, all the executions of <code>Kernel.run()</code> have completed and the results are available in the <code>squares</code> array.
* <p>
* <blockquote><pre>
* int[] squares = kernel.getSquares();
* for (int i=0; i< values.length; i++){
* System.out.printf("%4d %4d %8d\n", i, values[i], squares[i]);
* }
* </pre></blockquote>
* <p>
* A different approach to creating kernels that avoids extending Kernel is to write an anonymous inner class:
* <p>
* <blockquote><pre>
*
* final int[] values = new int[1024];
* // fill the values array
* final int[] squares = new int[values.length];
* final Range range = Range.create(values.length);
*
* Kernel kernel = new Kernel(){
* public void run() {
* int gid = getGlobalID();
* squares[gid] = values[gid]*values[gid];
* }
* };
* kernel.execute(range);
* for (int i=0; i< values.length; i++){
* System.out.printf("%4d %4d %8d\n", i, values[i], squares[i]);
* }
*
* </pre></blockquote>
* <p>
*
* @author gfrost AMD Javalabs
* @version Alpha, 21/09/2010
*/
public abstract class Kernel implements Cloneable {
private KernelState kernelState = new KernelState();
/**
* This class is for internal Kernel state management<p>
* NOT INTENDED FOR USE BY USERS
*/
public final class KernelState {
private int[] globalIds = new int[] {
0,
0,
0
};
private int[] localIds = new int[] {
0,
0,
0
};
private int[] groupIds = new int[] {
0,
0,
0
};
private Range range;
private int passId;
private volatile CyclicBarrier localBarrier;
/**
* Default constructor
*/
protected KernelState() {
}
/**
* Copy constructor
*
* @param kernelState
*/
protected KernelState(KernelState kernelState) {
globalIds = kernelState.getGlobalIds();
localIds = kernelState.getLocalIds();
groupIds = kernelState.getGroupIds();
range = kernelState.getRange();
passId = kernelState.getPassId();
localBarrier = kernelState.getLocalBarrier();
}
/**
* @return the globalIds
*/
public int[] getGlobalIds() {
return globalIds;
}
/**
* @param globalIds the globalIds to set
*/
public void setGlobalIds(int[] globalIds) {
this.globalIds = globalIds;
}
/**
* Set a specific index value
*
* @param _index
* @param value
*/
public void setGlobalId(int _index, int value) {
globalIds[_index] = value;
}
/**
* @return the localIds
*/
public int[] getLocalIds() {
return localIds;
}
/**
* @param localIds the localIds to set
*/
public void setLocalIds(int[] localIds) {
this.localIds = localIds;
}
/**
* Set a specific index value
*
* @param _index
* @param value
*/
public void setLocalId(int _index, int value) {
localIds[_index] = value;
}
/**
* @return the groupIds
*/
public int[] getGroupIds() {
return groupIds;
}
/**
* @param groupIds the groupIds to set
*/
public void setGroupIds(int[] groupIds) {
this.groupIds = groupIds;
}
/**
* Set a specific index value
*
* @param _index
* @param value
*/
public void setGroupId(int _index, int value) {
groupIds[_index] = value;
}
/**
* @return the range
*/
public Range getRange() {
return range;
}
/**
* @param range the range to set
*/
public void setRange(Range range) {
this.range = range;
}
/**
* @return the passId
*/
public int getPassId() {
return passId;
}
/**
* @param passId the passId to set
*/
public void setPassId(int passId) {
this.passId = passId;
}
/**
* @return the localBarrier
*/
public CyclicBarrier getLocalBarrier() {
return localBarrier;
}
/**
* @param localBarrier the localBarrier to set
*/
public void setLocalBarrier(CyclicBarrier localBarrier) {
this.localBarrier = localBarrier;
}
}
/**
* Determine the globalId of an executing kernel.
* <p>
* The kernel implementation uses the globalId to determine which of the executing kernels (in the global domain space) this invocation is expected to deal with.
* <p>
* For example in a <code>SquareKernel</code> implementation:
* <p>
* <blockquote><pre>
* class SquareKernel extends Kernel{
* private int values[];
* private int squares[];
* public SquareKernel(int values[]){
* this.values = values;
* squares = new int[values.length];
* }
* public void run() {
* int gid = getGlobalID();
* squares[gid] = values[gid]*values[gid];
* }
* public int[] getSquares(){
* return(squares);
* }
* }
* </pre></blockquote>
* <p>
* Each invocation of <code>SquareKernel.run()</code> retrieves it's globalId by calling <code>getGlobalId()</code>, and then computes the value of <code>square[gid]</code> for a given value of <code>value[gid]</code>.
* <p>
* @return The globalId for the Kernel being executed
*
* @see #getLocalId()
* @see #getGroupId()
* @see #getGlobalSize()
* @see #getNumGroups()
* @see #getLocalSize()
*/
@OpenCLDelegate
protected final int getGlobalId() {
return getGlobalId(0);
}
@OpenCLDelegate
protected final int getGlobalId(int _dim) {
return kernelState.getGlobalIds()[_dim];
}
/*
@OpenCLDelegate protected final int getGlobalX() {
return (getGlobalId(0));
}
@OpenCLDelegate protected final int getGlobalY() {
return (getGlobalId(1));
}
@OpenCLDelegate protected final int getGlobalZ() {
return (getGlobalId(2));
}
*/
/**
* Determine the groupId of an executing kernel.
* <p>
* When a <code>Kernel.execute(int globalSize)</code> is invoked for a particular kernel, the runtime will break the work into various 'groups'.
* <p>
* A kernel can use <code>getGroupId()</code> to determine which group a kernel is currently
* dispatched to
* <p>
* The following code would capture the groupId for each kernel and map it against globalId.
* <blockquote><pre>
* final int[] groupIds = new int[1024];
* Kernel kernel = new Kernel(){
* public void run() {
* int gid = getGlobalId();
* groupIds[gid] = getGroupId();
* }
* };
* kernel.execute(groupIds.length);
* for (int i=0; i< values.length; i++){
* System.out.printf("%4d %4d\n", i, groupIds[i]);
* }
* </pre></blockquote>
*
* @see #getLocalId()
* @see #getGlobalId()
* @see #getGlobalSize()
* @see #getNumGroups()
* @see #getLocalSize()
*
* @return The groupId for this Kernel being executed
*/
@OpenCLDelegate
protected final int getGroupId() {
return getGroupId(0);
}
@OpenCLDelegate
protected final int getGroupId(int _dim) {
return kernelState.getGroupIds()[_dim];
}
/*
@OpenCLDelegate protected final int getGroupX() {
return (getGroupId(0));
}
@OpenCLDelegate protected final int getGroupY() {
return (getGroupId(1));
}
@OpenCLDelegate protected final int getGroupZ() {
return (getGroupId(2));
}
*/
/**
* Determine the passId of an executing kernel.
* <p>
* When a <code>Kernel.execute(int globalSize, int passes)</code> is invoked for a particular kernel, the runtime will break the work into various 'groups'.
* <p>
* A kernel can use <code>getPassId()</code> to determine which pass we are in. This is ideal for 'reduce' type phases
*
* @see #getLocalId()
* @see #getGlobalId()
* @see #getGlobalSize()
* @see #getNumGroups()
* @see #getLocalSize()
*
* @return The groupId for this Kernel being executed
*/
@OpenCLDelegate
protected final int getPassId() {
return kernelState.getPassId();
}
/**
* Determine the local id of an executing kernel.
* <p>
* When a <code>Kernel.execute(int globalSize)</code> is invoked for a particular kernel, the runtime will break the work into
* various 'groups'.
* <code>getLocalId()</code> can be used to determine the relative id of the current kernel within a specific group.
* <p>
* The following code would capture the groupId for each kernel and map it against globalId.
* <blockquote><pre>
* final int[] localIds = new int[1024];
* Kernel kernel = new Kernel(){
* public void run() {
* int gid = getGlobalId();
* localIds[gid] = getLocalId();
* }
* };
* kernel.execute(localIds.length);
* for (int i=0; i< values.length; i++){
* System.out.printf("%4d %4d\n", i, localIds[i]);
* }
* </pre></blockquote>
*
* @see #getGroupId()
* @see #getGlobalId()
* @see #getGlobalSize()
* @see #getNumGroups()
* @see #getLocalSize()
*
* @return The local id for this Kernel being executed
*/
@OpenCLDelegate
protected final int getLocalId() {
return getLocalId(0);
}
@OpenCLDelegate
protected final int getLocalId(int _dim) {
return kernelState.getLocalIds()[_dim];
}
/*
@OpenCLDelegate protected final int getLocalX() {
return (getLocalId(0));
}
@OpenCLDelegate protected final int getLocalY() {
return (getLocalId(1));
}
@OpenCLDelegate protected final int getLocalZ() {
return (getLocalId(2));
}
*/
/**
* Determine the size of the group that an executing kernel is a member of.
* <p>
* When a <code>Kernel.execute(int globalSize)</code> is invoked for a particular kernel, the runtime will break the work into
* various 'groups'. <code>getLocalSize()</code> allows a kernel to determine the size of the current group.
* <p>
* Note groups may not all be the same size. In particular, if <code>(global size)%(# of compute devices)!=0</code>, the runtime can choose to dispatch kernels to
* groups with differing sizes.
*
* @see #getGroupId()
* @see #getGlobalId()
* @see #getGlobalSize()
* @see #getNumGroups()
* @see #getLocalSize()
*
* @return The size of the currently executing group.
*/
@OpenCLDelegate
protected final int getLocalSize() {
return kernelState.getRange().getLocalSize(0);
}
@OpenCLDelegate
protected final int getLocalSize(int _dim) {
return kernelState.getRange().getLocalSize(_dim);
}
/*
@OpenCLDelegate protected final int getLocalWidth() {
return (range.getLocalSize(0));
}
@OpenCLDelegate protected final int getLocalHeight() {
return (range.getLocalSize(1));
}
@OpenCLDelegate protected final int getLocalDepth() {
return (range.getLocalSize(2));
}
*/
/**
* Determine the value that was passed to <code>Kernel.execute(int globalSize)</code> method.
*
* @see #getGroupId()
* @see #getGlobalId()
* @see #getNumGroups()
* @see #getLocalSize()
*
* @return The value passed to <code>Kernel.execute(int globalSize)</code> causing the current execution.
*/
@OpenCLDelegate
protected final int getGlobalSize() {
return kernelState.getRange().getGlobalSize(0);
}
@OpenCLDelegate
protected final int getGlobalSize(int _dim) {
return kernelState.getRange().getGlobalSize(_dim);
}
/*
@OpenCLDelegate protected final int getGlobalWidth() {
return (range.getGlobalSize(0));
}
@OpenCLDelegate protected final int getGlobalHeight() {
return (range.getGlobalSize(1));
}
@OpenCLDelegate protected final int getGlobalDepth() {
return (range.getGlobalSize(2));
}
*/
/**
* Determine the number of groups that will be used to execute a kernel
* <p>
* When <code>Kernel.execute(int globalSize)</code> is invoked, the runtime will split the work into
* multiple 'groups'. <code>getNumGroups()</code> returns the total number of groups that will be used.
*
* @see #getGroupId()
* @see #getGlobalId()
* @see #getGlobalSize()
* @see #getNumGroups()
* @see #getLocalSize()
*
* @return The number of groups that kernels will be dispatched into.
*/
@OpenCLDelegate
protected final int getNumGroups() {
return kernelState.getRange().getNumGroups(0);
}
@OpenCLDelegate
protected final int getNumGroups(int _dim) {
return kernelState.getRange().getNumGroups(_dim);
}
/*
@OpenCLDelegate protected final int getNumGroupsWidth() {
return (range.getGroups(0));
}
@OpenCLDelegate protected final int getNumGroupsHeight() {
return (range.getGroups(1));
}
@OpenCLDelegate protected final int getNumGroupsDepth() {
return (range.getGroups(2));
}
*/
/**
* The entry point of a kernel.
*
* <p>
* Every kernel must override this method.
*/
public abstract void run();
/**
* When using a Java Thread Pool Aparapi uses clone to copy the initial instance to each thread.
*
* <p>
* If you choose to override <code>clone()</code> you are responsible for delegating to <code>super.clone();</code>
*/
@Override
public Kernel clone() {
try {
final Kernel worker = (Kernel) super.clone();
// We need to be careful to also clone the KernelState
worker.kernelState = worker.new KernelState(kernelState); // Qualified copy constructor
worker.kernelState.setGroupIds(new int[] {
0,
0,
0
});
worker.kernelState.setLocalIds(new int[] {
0,
0,
0
});
worker.kernelState.setGlobalIds(new int[] {
0,
0,
0
});
return worker;
} catch (final CloneNotSupportedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return (null);
}
}
/**
* Wait for all kernels in the current group to rendezvous at this call before continuing execution.
*
* @annotion Experimental
*/
@OpenCLDelegate
@Experimental
protected final void localBarrier() {
try {
kernelState.getLocalBarrier().await();
} catch (final InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (final BrokenBarrierException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* Wait for all kernels in the current group to rendezvous at this call before continuing execution.
*
*
* Java version is identical to localBarrier()
*
* @annotion Experimental
* @deprecated
*/
@OpenCLDelegate
@Experimental
@Deprecated
protected final void globalBarrier() throws DeprecatedException {
throw new DeprecatedException(
"Kernel.globalBarrier() has been deprecated. It was based an incorrect understanding of OpenCL functionality.");
}
public KernelState getKernelState() {
return kernelState;
}
final static Map<String, String> typeToLetterMap = new HashMap<String, String>();
static {
// only primitive types for now
typeToLetterMap.put("double", "D");
typeToLetterMap.put("float", "F");
typeToLetterMap.put("int", "I");
typeToLetterMap.put("long", "J");
typeToLetterMap.put("boolean", "Z");
typeToLetterMap.put("byte", "B");
typeToLetterMap.put("char", "C");
typeToLetterMap.put("short", "S");
typeToLetterMap.put("void", "V");
}
private static String descriptorToReturnTypeLetter(String desc) {
// find the letter after the closed parenthesis
return desc.substring(desc.lastIndexOf(')') + 1);
}
private static String getReturnTypeLetter(Method meth) {
final Class<?> retClass = meth.getReturnType();
final String strRetClass = retClass.toString();
final String mapping = typeToLetterMap.get(strRetClass);
// System.out.println("strRetClass = <" + strRetClass + ">, mapping = " + mapping);
return mapping;
}
public static String getMappedMethodName(MethodReferenceEntry _methodReferenceEntry) {
String mappedName = null;
final String name = _methodReferenceEntry.getNameAndTypeEntry().getNameUTF8Entry().getUTF8();
for (final Method kernelMethod : Kernel.class.getDeclaredMethods()) {
if (kernelMethod.isAnnotationPresent(OpenCLMapping.class)) {
// ultimately, need a way to constrain this based upon signature (to disambiguate abs(float) from abs(int);
// for Alpha, we will just disambiguate based on the return type
if (false) {
System.out.println("kernelMethod is ... " + kernelMethod.toGenericString());
System.out.println("returnType = " + kernelMethod.getReturnType());
System.out.println("returnTypeLetter = " + getReturnTypeLetter(kernelMethod));
System.out.println("kernelMethod getName = " + kernelMethod.getName());
System.out.println("methRefName = " + name + " descriptor = "
+ _methodReferenceEntry.getNameAndTypeEntry().getDescriptorUTF8Entry().getUTF8());
System.out
.println("descToReturnTypeLetter = "
+ descriptorToReturnTypeLetter(_methodReferenceEntry.getNameAndTypeEntry().getDescriptorUTF8Entry()
.getUTF8()));
}
if (_methodReferenceEntry.getNameAndTypeEntry().getNameUTF8Entry().getUTF8().equals(kernelMethod.getName())
&& descriptorToReturnTypeLetter(_methodReferenceEntry.getNameAndTypeEntry().getDescriptorUTF8Entry().getUTF8())
.equals(getReturnTypeLetter(kernelMethod))) {
final OpenCLMapping annotation = kernelMethod.getAnnotation(OpenCLMapping.class);
final String mapTo = annotation.mapTo();
if (!mapTo.equals("")) {
mappedName = mapTo;
// System.out.println("mapTo = " + mapTo);
}
}
}
}
// System.out.println("... in getMappedMethodName, returning = " + mappedName);
return (mappedName);
}
public static boolean isMappedMethod(MethodReferenceEntry methodReferenceEntry) {
boolean isMapped = false;
for (final Method kernelMethod : Kernel.class.getDeclaredMethods()) {
if (kernelMethod.isAnnotationPresent(OpenCLMapping.class)) {
if (methodReferenceEntry.getNameAndTypeEntry().getNameUTF8Entry().getUTF8().equals(kernelMethod.getName())) {
// well they have the same name ;)
isMapped = true;
}
}
}
return (isMapped);
}
public static boolean isOpenCLDelegateMethod(MethodReferenceEntry methodReferenceEntry) {
boolean isMapped = false;
for (final Method kernelMethod : Kernel.class.getDeclaredMethods()) {
if (kernelMethod.isAnnotationPresent(OpenCLDelegate.class)) {
if (methodReferenceEntry.getNameAndTypeEntry().getNameUTF8Entry().getUTF8().equals(kernelMethod.getName())) {
// well they have the same name ;)
isMapped = true;
}
}
}
return (isMapped);
}
public static boolean usesAtomic32(MethodReferenceEntry methodReferenceEntry) {
for (final Method kernelMethod : Kernel.class.getDeclaredMethods()) {
if (kernelMethod.isAnnotationPresent(OpenCLMapping.class)) {
if (methodReferenceEntry.getNameAndTypeEntry().getNameUTF8Entry().getUTF8().equals(kernelMethod.getName())) {
final OpenCLMapping annotation = kernelMethod.getAnnotation(OpenCLMapping.class);
return annotation.atomic32();
}
}
}
return (false);
}
// For alpha release atomic64 is not supported
public static boolean usesAtomic64(MethodReferenceEntry methodReferenceEntry) {
//for (java.lang.reflect.Method kernelMethod : Kernel.class.getDeclaredMethods()) {
// if (kernelMethod.isAnnotationPresent(Kernel.OpenCLMapping.class)) {
// if (methodReferenceEntry.getNameAndTypeEntry().getNameUTF8Entry().getUTF8().equals(kernelMethod.getName())) {
// OpenCLMapping annotation = kernelMethod.getAnnotation(Kernel.OpenCLMapping.class);
// return annotation.atomic64();
// }
// }
//}
return (false);
}
// the flag useNullForLocalSize is useful for testing that what we compute for localSize is what OpenCL
// would also compute if we passed in null. In non-testing mode, we just call execute with the
// same localSize that we computed in getLocalSizeJNI. We don't want do publicize these of course.
// GRF we can't access this from test classes without exposing in in javadoc so I left the flag but made the test/set of the flag reflectively
boolean useNullForLocalSize = false;
/**
* Delegates to either {@link java.lang.Math#acos(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/acos.html">acos(float)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param a value to delegate to {@link java.lang.Math#acos(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/acos.html">acos(float)</a></code>
* @return {@link java.lang.Math#acos(double)} casted to float/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/acos.html">acos(float)</a></code>
*
* @see java.lang.Math#acos(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/acos.html">acos(float)</a></code>
*/
@OpenCLMapping(mapTo = "acos")
public static float acos(float a) {
return (float) Math.acos(a);
}
/**
* Delegates to either {@link java.lang.Math#acos(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/acos.html">acos(double)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param a value to delegate to {@link java.lang.Math#acos(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/acos.html">acos(double)</a></code>
* @return {@link java.lang.Math#acos(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/acos.html">acos(double)</a></code>
*
* @see java.lang.Math#acos(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/acos.html">acos(double)</a></code>
*/
@OpenCLMapping(mapTo = "acos")
public static double acos(double a) {
return Math.acos(a);
}
/**
* Delegates to either {@link java.lang.Math#asin(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/asin.html">asin(float)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _f value to delegate to {@link java.lang.Math#asin(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/asin.html">asin(float)</a></code>
* @return {@link java.lang.Math#asin(double)} casted to float/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/asin.html">asin(float)</a></code>
*
* @see java.lang.Math#asin(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/asin.html">asin(float)</a></code>
*/
@OpenCLMapping(mapTo = "asin")
public static float asin(float _f) {
return (float) Math.asin(_f);
}
/**
* Delegates to either {@link java.lang.Math#asin(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/asin.html">asin(double)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _d value to delegate to {@link java.lang.Math#asin(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/asin.html">asin(double)</a></code>
* @return {@link java.lang.Math#asin(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/asin.html">asin(double)</a></code>
*
* @see java.lang.Math#asin(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/asin.html">asin(double)</a></code>
*/
@OpenCLMapping(mapTo = "asin")
public static double asin(double _d) {
return Math.asin(_d);
}
/**
* Delegates to either {@link java.lang.Math#atan(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/atan.html">atan(float)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _f value to delegate to {@link java.lang.Math#atan(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/atan.html">atan(float)</a></code>
* @return {@link java.lang.Math#atan(double)} casted to float/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/atan.html">atan(float)</a></code>
*
* @see java.lang.Math#atan(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/atan.html">atan(float)</a></code>
*/
@OpenCLMapping(mapTo = "atan")
public static float atan(float _f) {
return (float) Math.atan(_f);
}
/**
* Delegates to either {@link java.lang.Math#atan(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/atan.html">atan(double)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _d value to delegate to {@link java.lang.Math#atan(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/atan.html">atan(double)</a></code>
* @return {@link java.lang.Math#atan(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/atan.html">atan(double)</a></code>
*
* @see java.lang.Math#atan(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/atan.html">atan(double)</a></code>
*/
@OpenCLMapping(mapTo = "atan")
public static double atan(double _d) {
return Math.atan(_d);
}
/**
* Delegates to either {@link java.lang.Math#atan2(double, double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/atan.html">atan2(float, float)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _f1 value to delegate to first argument of {@link java.lang.Math#atan2(double, double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/atan.html">atan2(float, float)</a></code>
* @param _f2 value to delegate to second argument of {@link java.lang.Math#atan2(double, double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/atan.html">atan2(float, float)</a></code>
* @return {@link java.lang.Math#atan2(double, double)} casted to float/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/atan.html">atan2(float, float)</a></code>
*
* @see java.lang.Math#atan2(double, double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/atan.html">atan2(float, float)</a></code>
*/
@OpenCLMapping(mapTo = "atan2")
public static float atan2(float _f1, float _f2) {
return (float) Math.atan2(_f1, _f2);
}
/**
* Delegates to either {@link java.lang.Math#atan2(double, double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/atan.html">atan2(double, double)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _d1 value to delegate to first argument of {@link java.lang.Math#atan2(double, double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/atan.html">atan2(double, double)</a></code>
* @param _d2 value to delegate to second argument of {@link java.lang.Math#atan2(double, double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/atan.html">atan2(double, double)</a></code>
* @return {@link java.lang.Math#atan2(double, double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/atan.html">atan2(double, double)</a></code>
*
* @see java.lang.Math#atan2(double, double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/atan.html">atan2(double, double)</a></code>
*/
@OpenCLMapping(mapTo = "atan2")
public static double atan2(double _d1, double _d2) {
return Math.atan2(_d1, _d2);
}
/**
* Delegates to either {@link java.lang.Math#ceil(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/ceil.html">ceil(float)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _f value to delegate to {@link java.lang.Math#ceil(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/ceil.html">ceil(float)</a></code>
* @return {@link java.lang.Math#ceil(double)} casted to float/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/ceil.html">ceil(float)</a></code>
*
* @see java.lang.Math#ceil(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/ceil.html">ceil(float)</a></code>
*/
@OpenCLMapping(mapTo = "ceil")
public static float ceil(float _f) {
return (float) Math.ceil(_f);
}
/**
* Delegates to either {@link java.lang.Math#ceil(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/ceil.html">ceil(double)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _d value to delegate to {@link java.lang.Math#ceil(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/ceil.html">ceil(double)</a></code>
* @return {@link java.lang.Math#ceil(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/ceil.html">ceil(double)</a></code>
*
* @see java.lang.Math#ceil(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/ceil.html">ceil(double)</a></code>
*/
@OpenCLMapping(mapTo = "ceil")
public static double ceil(double _d) {
return Math.ceil(_d);
}
/**
* Delegates to either {@link java.lang.Math#cos(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/cos.html">cos(float)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _f value to delegate to {@link java.lang.Math#cos(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/cos.html">cos(float)</a></code>
* @return {@link java.lang.Math#cos(double)} casted to float/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/cos.html">cos(float)</a></code>
*
* @see java.lang.Math#cos(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/cos.html">cos(float)</a></code>
*/
@OpenCLMapping(mapTo = "cos")
public static float cos(float _f) {
return (float) Math.cos(_f);
}
/**
* Delegates to either {@link java.lang.Math#cos(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/cos.html">cos(double)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _d value to delegate to {@link java.lang.Math#cos(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/cos.html">cos(double)</a></code>
* @return {@link java.lang.Math#cos(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/cos.html">cos(double)</a></code>
*
* @see java.lang.Math#cos(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/cos.html">cos(double)</a></code>
*/
@OpenCLMapping(mapTo = "cos")
public static double cos(double _d) {
return Math.cos(_d);
}
/**
* Delegates to either {@link java.lang.Math#exp(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/exp.html">exp(float)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _f value to delegate to {@link java.lang.Math#exp(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/exp.html">exp(float)</a></code>
* @return {@link java.lang.Math#exp(double)} casted to float/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/exp.html">exp(float)</a></code>
*
* @see java.lang.Math#exp(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/exp.html">exp(float)</a></code>
*/
@OpenCLMapping(mapTo = "exp")
public static float exp(float _f) {
return (float) Math.exp(_f);
}
/**
* Delegates to either {@link java.lang.Math#exp(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/exp.html">exp(double)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _d value to delegate to {@link java.lang.Math#exp(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/exp.html">exp(double)</a></code>
* @return {@link java.lang.Math#exp(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/exp.html">exp(double)</a></code>
*
* @see java.lang.Math#exp(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/exp.html">exp(double)</a></code>
*/
@OpenCLMapping(mapTo = "exp")
public static double exp(double _d) {
return Math.exp(_d);
}
/**
* Delegates to either {@link java.lang.Math#abs(float)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fabs.html">fabs(float)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _f value to delegate to {@link java.lang.Math#abs(float)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fabs.html">fabs(float)</a></code>
* @return {@link java.lang.Math#abs(float)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fabs.html">fabs(float)</a></code>
*
* @see java.lang.Math#abs(float)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fabs.html">fabs(float)</a></code>
*/
@OpenCLMapping(mapTo = "fabs")
public static float abs(float _f) {
return Math.abs(_f);
}
/**
* Delegates to either {@link java.lang.Math#abs(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fabs.html">fabs(double)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _d value to delegate to {@link java.lang.Math#abs(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fabs.html">fabs(double)</a></code>
* @return {@link java.lang.Math#abs(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fabs.html">fabs(double)</a></code>
*
* @see java.lang.Math#abs(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fabs.html">fabs(double)</a></code>
*/
@OpenCLMapping(mapTo = "fabs")
public static double abs(double _d) {
return Math.abs(_d);
}
/**
* Delegates to either {@link java.lang.Math#abs(int)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/abs.html">abs(int)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param n value to delegate to {@link java.lang.Math#abs(int)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/abs.html">abs(int)</a></code>
* @return {@link java.lang.Math#abs(int)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/abs.html">abs(int)</a></code>
*
* @see java.lang.Math#abs(int)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/abs.html">abs(int)</a></code>
*/
@OpenCLMapping(mapTo = "abs")
public static int abs(int n) {
return Math.abs(n);
}
/**
* Delegates to either {@link java.lang.Math#abs(long)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/abs.html">abs(long)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param n value to delegate to {@link java.lang.Math#abs(long)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/abs.html">abs(long)</a></code>
* @return {@link java.lang.Math#abs(long)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fabs.html">abs(long)</a></code>
*
* @see java.lang.Math#abs(long)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/abs.html">abs(long)</a></code>
*/
@OpenCLMapping(mapTo = "abs")
public static long abs(long n) {
return Math.abs(n);
}
/**
* Delegates to either {@link java.lang.Math#floor(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/abs.html">floor(float)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _f value to delegate to {@link java.lang.Math#floor(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/floor.html">floor(float)</a></code>
* @return {@link java.lang.Math#floor(double)} casted to float/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/floor.html">floor(float)</a></code>
*
* @see java.lang.Math#floor(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/floor.html">floor(float)</a></code>
*/
@OpenCLMapping(mapTo = "floor")
public static float floor(float _f) {
return (float) Math.floor(_f);
}
/**
* Delegates to either {@link java.lang.Math#floor(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/abs.html">floor(double)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _d value to delegate to {@link java.lang.Math#floor(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/floor.html">floor(double)</a></code>
* @return {@link java.lang.Math#floor(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/floor.html">floor(double)</a></code>
*
* @see java.lang.Math#floor(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/floor.html">floor(double)</a></code>
*/
@OpenCLMapping(mapTo = "floor")
public static double floor(double _d) {
return Math.floor(_d);
}
/**
* Delegates to either {@link java.lang.Math#max(float, float)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fmax.html">fmax(float, float)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _f1 value to delegate to first argument of {@link java.lang.Math#max(float, float)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fmax.html">fmax(float, float)</a></code>
* @param _f2 value to delegate to second argument of {@link java.lang.Math#max(float, float)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fmax.html">fmax(float, float)</a></code>
* @return {@link java.lang.Math#max(float, float)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fmax.html">fmax(float, float)</a></code>
*
* @see java.lang.Math#max(float, float)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fmax.html">fmax(float, float)</a></code>
*/
@OpenCLMapping(mapTo = "fmax")
public static float max(float _f1, float _f2) {
return Math.max(_f1, _f2);
}
/**
* Delegates to either {@link java.lang.Math#max(double, double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fmax.html">fmax(double, double)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _d1 value to delegate to first argument of {@link java.lang.Math#max(double, double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fmax.html">fmax(double, double)</a></code>
* @param _d2 value to delegate to second argument of {@link java.lang.Math#max(double, double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fmax.html">fmax(double, double)</a></code>
* @return {@link java.lang.Math#max(double, double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fmax.html">fmax(double, double)</a></code>
*
* @see java.lang.Math#max(double, double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fmax.html">fmax(double, double)</a></code>
*/
@OpenCLMapping(mapTo = "fmax")
public static double max(double _d1, double _d2) {
return Math.max(_d1, _d2);
}
/**
* Delegates to either {@link java.lang.Math#max(int, int)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/integerMax.html">max(int, int)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param n1 value to delegate to {@link java.lang.Math#max(int, int)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/integerMax.html">max(int, int)</a></code>
* @param n2 value to delegate to {@link java.lang.Math#max(int, int)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/integerMax.html">max(int, int)</a></code>
* @return {@link java.lang.Math#max(int, int)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/integerMax.html">max(int, int)</a></code>
*
* @see java.lang.Math#max(int, int)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/integerMax.html">max(int, int)</a></code>
*/
@OpenCLMapping(mapTo = "max")
public static int max(int n1, int n2) {
return Math.max(n1, n2);
}
/**
* Delegates to either {@link java.lang.Math#max(long, long)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/integerMax.html">max(long, long)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param n1 value to delegate to first argument of {@link java.lang.Math#max(long, long)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/integerMax.html">max(long, long)</a></code>
* @param n2 value to delegate to second argument of {@link java.lang.Math#max(long, long)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/integerMax.html">max(long, long)</a></code>
* @return {@link java.lang.Math#max(long, long)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/integerMax.html">max(long, long)</a></code>
*
* @see java.lang.Math#max(long, long)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/integerMax.html">max(long, long)</a></code>
*/
@OpenCLMapping(mapTo = "max")
public static long max(long n1, long n2) {
return Math.max(n1, n2);
}
/**
* Delegates to either {@link java.lang.Math#min(float, float)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fmin.html">fmin(float, float)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _f1 value to delegate to first argument of {@link java.lang.Math#min(float, float)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fmin.html">fmin(float, float)</a></code>
* @param _f2 value to delegate to second argument of {@link java.lang.Math#min(float, float)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fmin.html">fmin(float, float)</a></code>
* @return {@link java.lang.Math#min(float, float)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fmin.html">fmin(float, float)</a></code>
*
* @see java.lang.Math#min(float, float)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fmin.html">fmin(float, float)</a></code>
*/
@OpenCLMapping(mapTo = "fmin")
public static float min(float _f1, float _f2) {
return Math.min(_f1, _f2);
}
/**
* Delegates to either {@link java.lang.Math#min(double, double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fmin.html">fmin(double, double)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _d1 value to delegate to first argument of {@link java.lang.Math#min(double, double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fmin.html">fmin(double, double)</a></code>
* @param _d2 value to delegate to second argument of {@link java.lang.Math#min(double, double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fmin.html">fmin(double, double)</a></code>
* @return {@link java.lang.Math#min(double, double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fmin.html">fmin(double, double)</a></code>
*
* @see java.lang.Math#min(double, double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/fmin.html">fmin(double, double)</a></code>
*/
@OpenCLMapping(mapTo = "fmin")
public static double min(double _d1, double _d2) {
return Math.min(_d1, _d2);
}
/**
* Delegates to either {@link java.lang.Math#min(int, int)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/integerMax.html">min(int, int)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param n1 value to delegate to first argument of {@link java.lang.Math#min(int, int)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/integerMax.html">min(int, int)</a></code>
* @param n2 value to delegate to second argument of {@link java.lang.Math#min(int, int)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/integerMax.html">min(int, int)</a></code>
* @return {@link java.lang.Math#min(int, int)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/integerMax.html">min(int, int)</a></code>
*
* @see java.lang.Math#min(int, int)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/integerMax.html">min(int, int)</a></code>
*/
@OpenCLMapping(mapTo = "min")
public static int min(int n1, int n2) {
return Math.min(n1, n2);
}
/**
* Delegates to either {@link java.lang.Math#min(long, long)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/integerMax.html">min(long, long)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param n1 value to delegate to first argument of {@link java.lang.Math#min(long, long)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/integerMax.html">min(long, long)</a></code>
* @param n2 value to delegate to second argument of {@link java.lang.Math#min(long, long)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/integerMax.html">min(long, long)</a></code>
* @return {@link java.lang.Math#min(long, long)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/integerMax.html">min(long, long)</a></code>
*
* @see java.lang.Math#min(long, long)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/integerMax.html">min(long, long)</a></code>
*/
@OpenCLMapping(mapTo = "min")
public static long min(long n1, long n2) {
return Math.min(n1, n2);
}
/**
* Delegates to either {@link java.lang.Math#log(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/log.html">log(float)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _f value to delegate to {@link java.lang.Math#log(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/log.html">log(float)</a></code>
* @return {@link java.lang.Math#log(double)} casted to float/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/log.html">log(float)</a></code>
*
* @see java.lang.Math#log(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/log.html">log(float)</a></code>
*/
@OpenCLMapping(mapTo = "log")
public static float log(float _f) {
return (float) Math.log(_f);
}
/**
* Delegates to either {@link java.lang.Math#log(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/log.html">log(double)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _d value to delegate to {@link java.lang.Math#log(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/log.html">log(double)</a></code>
* @return {@link java.lang.Math#log(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/log.html">log(double)</a></code>
*
* @see java.lang.Math#log(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/log.html">log(double)</a></code>
*/
@OpenCLMapping(mapTo = "log")
public static double log(double _d) {
return Math.log(_d);
}
/**
* Delegates to either {@link java.lang.Math#pow(double, double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/pow.html">pow(float, float)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _f1 value to delegate to first argument of {@link java.lang.Math#pow(double, double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/pow.html">pow(float, float)</a></code>
* @param _f2 value to delegate to second argument of {@link java.lang.Math#pow(double, double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/pow.html">pow(float, float)</a></code>
* @return {@link java.lang.Math#pow(double, double)} casted to float/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/pow.html">pow(float, float)</a></code>
*
* @see java.lang.Math#pow(double, double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/pow.html">pow(float, float)</a></code>
*/
@OpenCLMapping(mapTo = "pow")
public static float pow(float _f1, float _f2) {
return (float) Math.pow(_f1, _f2);
}
/**
* Delegates to either {@link java.lang.Math#pow(double, double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/pow.html">pow(double, double)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _d1 value to delegate to first argument of {@link java.lang.Math#pow(double, double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/pow.html">pow(double, double)</a></code>
* @param _d2 value to delegate to second argument of {@link java.lang.Math#pow(double, double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/pow.html">pow(double, double)</a></code>
* @return {@link java.lang.Math#pow(double, double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/pow.html">pow(double, double)</a></code>
*
* @see java.lang.Math#pow(double, double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/pow.html">pow(double, double)</a></code>
*/
@OpenCLMapping(mapTo = "pow")
public static double pow(double _d1, double _d2) {
return Math.pow(_d1, _d2);
}
/**
* Delegates to either {@link java.lang.Math#IEEEremainder(double, double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/remainder.html">remainder(float, float)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _f1 value to delegate to first argument of {@link java.lang.Math#IEEEremainder(double, double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/remainder.html">remainder(float, float)</a></code>
* @param _f2 value to delegate to second argument of {@link java.lang.Math#IEEEremainder(double, double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/remainder.html">remainder(float, float)</a></code>
* @return {@link java.lang.Math#IEEEremainder(double, double)} casted to float/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/remainder.html">remainder(float, float)</a></code>
*
* @see java.lang.Math#IEEEremainder(double, double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/remainder.html">remainder(float, float)</a></code>
*/
@OpenCLMapping(mapTo = "remainder")
public static float IEEEremainder(float _f1, float _f2) {
return (float) Math.IEEEremainder(_f1, _f2);
}
/**
* Delegates to either {@link java.lang.Math#IEEEremainder(double, double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/remainder.html">remainder(double, double)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _d1 value to delegate to first argument of {@link java.lang.Math#IEEEremainder(double, double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/remainder.html">remainder(double, double)</a></code>
* @param _d2 value to delegate to second argument of {@link java.lang.Math#IEEEremainder(double, double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/remainder.html">remainder(double, double)</a></code>
* @return {@link java.lang.Math#IEEEremainder(double, double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/remainder.html">remainder(double, double)</a></code>
*
* @see java.lang.Math#IEEEremainder(double, double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/remainder.html">remainder(double, double)</a></code>
*/
@OpenCLMapping(mapTo = "remainder")
public static double IEEEremainder(double _d1, double _d2) {
return Math.IEEEremainder(_d1, _d2);
}
/**
* Delegates to either {@link java.lang.Math#toRadians(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/radians.html">radians(float)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _f value to delegate to {@link java.lang.Math#toRadians(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/radians.html">radians(float)</a></code>
* @return {@link java.lang.Math#toRadians(double)} casted to float/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/radians.html">radians(float)</a></code>
*
* @see java.lang.Math#toRadians(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/radians.html">radians(float)</a></code>
*/
@OpenCLMapping(mapTo = "radians")
public static float toRadians(float _f) {
return (float) Math.toRadians(_f);
}
/**
* Delegates to either {@link java.lang.Math#toRadians(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/radians.html">radians(double)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _d value to delegate to {@link java.lang.Math#toRadians(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/radians.html">radians(double)</a></code>
* @return {@link java.lang.Math#toRadians(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/radians.html">radians(double)</a></code>
*
* @see java.lang.Math#toRadians(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/radians.html">radians(double)</a></code>
*/
@OpenCLMapping(mapTo = "radians")
public static double toRadians(double _d) {
return Math.toRadians(_d);
}
/**
* Delegates to either {@link java.lang.Math#toDegrees(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/degrees.html">degrees(float)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _f value to delegate to {@link java.lang.Math#toDegrees(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/degrees.html">degrees(float)</a></code>
* @return {@link java.lang.Math#toDegrees(double)} casted to float/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/degrees.html">degrees(float)</a></code>
*
* @see java.lang.Math#toDegrees(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/degrees.html">degrees(float)</a></code>
*/
@OpenCLMapping(mapTo = "degrees")
public static float toDegrees(float _f) {
return (float) Math.toDegrees(_f);
}
/**
* Delegates to either {@link java.lang.Math#toDegrees(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/degrees.html">degrees(double)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _d value to delegate to {@link java.lang.Math#toDegrees(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/degrees.html">degrees(double)</a></code>
* @return {@link java.lang.Math#toDegrees(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/degrees.html">degrees(double)</a></code>
*
* @see java.lang.Math#toDegrees(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/degrees.html">degrees(double)</a></code>
*/
@OpenCLMapping(mapTo = "degrees")
public static double toDegrees(double _d) {
return Math.toDegrees(_d);
}
/**
* Delegates to either {@link java.lang.Math#rint(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/rint.html">rint(float)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _f value to delegate to {@link java.lang.Math#rint(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/rint.html">rint(float)</a></code>
* @return {@link java.lang.Math#rint(double)} casted to float/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/rint.html">rint(float)</a></code>
*
* @see java.lang.Math#rint(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/rint.html">rint(float)</a></code>
*/
@OpenCLMapping(mapTo = "rint")
public static float rint(float _f) {
return (float) Math.rint(_f);
}
/**
* Delegates to either {@link java.lang.Math#rint(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/rint.html">rint(double)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _d value to delegate to {@link java.lang.Math#rint(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/rint.html">rint(double)</a></code>
* @return {@link java.lang.Math#rint(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/rint.html">rint(double)</a></code>
*
* @see java.lang.Math#rint(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/rint.html">rint(double)</a></code>
*/
@OpenCLMapping(mapTo = "rint")
public static double rint(double _d) {
return Math.rint(_d);
}
/**
* Delegates to either {@link java.lang.Math#round(float)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/round.html">round(float)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _f value to delegate to {@link java.lang.Math#round(float)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/round.html">round(float)</a></code>
* @return {@link java.lang.Math#round(float)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/round.html">round(float)</a></code>
*
* @see java.lang.Math#round(float)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/round.html">round(float)</a></code>
*/
@OpenCLMapping(mapTo = "round")
public static int round(float _f) {
return Math.round(_f);
}
/**
* Delegates to either {@link java.lang.Math#round(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/round.html">round(double)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _d value to delegate to {@link java.lang.Math#round(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/round.html">round(double)</a></code>
* @return {@link java.lang.Math#round(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/round.html">round(double)</a></code>
*
* @see java.lang.Math#round(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/round.html">round(double)</a></code>
*/
@OpenCLMapping(mapTo = "round")
public static long round(double _d) {
return Math.round(_d);
}
/**
* Delegates to either {@link java.lang.Math#sin(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/sin.html">sin(float)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _f value to delegate to {@link java.lang.Math#sin(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/sin.html">sin(float)</a></code>
* @return {@link java.lang.Math#sin(double)} casted to float/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/sin.html">sin(float)</a></code>
*
* @see java.lang.Math#sin(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/sin.html">sin(float)</a></code>
*/
@OpenCLMapping(mapTo = "sin")
public static float sin(float _f) {
return (float) Math.sin(_f);
}
/**
* Delegates to either {@link java.lang.Math#sin(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/sin.html">sin(double)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _d value to delegate to {@link java.lang.Math#sin(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/sin.html">sin(double)</a></code>
* @return {@link java.lang.Math#sin(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/sin.html">sin(double)</a></code>
*
* @see java.lang.Math#sin(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/sin.html">sin(double)</a></code>
*/
@OpenCLMapping(mapTo = "sin")
public static double sin(double _d) {
return Math.sin(_d);
}
/**
* Delegates to either {@link java.lang.Math#sqrt(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/sqrt.html">sqrt(float)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _f value to delegate to {@link java.lang.Math#sqrt(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/sqrt.html">sqrt(float)</a></code>
* @return {@link java.lang.Math#sqrt(double)} casted to float/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/sqrt.html">sqrt(float)</a></code>
*
* @see java.lang.Math#sqrt(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/sqrt.html">sqrt(float)</a></code>
*/
@OpenCLMapping(mapTo = "sqrt")
public static float sqrt(float _f) {
return (float) Math.sqrt(_f);
}
/**
* Delegates to either {@link java.lang.Math#sqrt(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/sqrt.html">sqrt(double)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _d value to delegate to {@link java.lang.Math#sqrt(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/sqrt.html">sqrt(double)</a></code>
* @return {@link java.lang.Math#sqrt(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/sqrt.html">sqrt(double)</a></code>
*
* @see java.lang.Math#sqrt(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/sqrt.html">sqrt(double)</a></code>
*/
@OpenCLMapping(mapTo = "sqrt")
public static double sqrt(double _d) {
return Math.sqrt(_d);
}
/**
* Delegates to either {@link java.lang.Math#tan(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/tan.html">tan(float)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _f value to delegate to {@link java.lang.Math#tan(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/tan.html">tan(float)</a></code>
* @return {@link java.lang.Math#tan(double)} casted to float/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/tan.html">tan(float)</a></code>
*
* @see java.lang.Math#tan(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/tan.html">tan(float)</a></code>
*/
@OpenCLMapping(mapTo = "tan")
public static float tan(float _f) {
return (float) Math.tan(_f);
}
/**
* Delegates to either {@link java.lang.Math#tan(double)} (Java) or <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/tan.html">tan(double)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _d value to delegate to {@link java.lang.Math#tan(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/tan.html">tan(double)</a></code>
* @return {@link java.lang.Math#tan(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/tan.html">tan(double)</a></code>
*
* @see java.lang.Math#tan(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/tan.html">tan(double)</a></code>
*/
@OpenCLMapping(mapTo = "tan")
public static double tan(double _d) {
return Math.tan(_d);
}
// the following rsqrt and native_sqrt and native_rsqrt don't exist in java Math
// but added them here for nbody testing, not sure if we want to expose them
/**
* Computes inverse square root using {@link java.lang.Math#sqrt(double)} (Java) or delegates to <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/sqrt.html">rsqrt(double)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _f value to delegate to {@link java.lang.Math#sqrt(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/sqrt.html">rsqrt(double)</a></code>
* @return <code>( 1.0f / {@link java.lang.Math#sqrt(double)} casted to float )</code>/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/sqrt.html">rsqrt(double)</a></code>
*
* @see java.lang.Math#sqrt(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/sqrt.html">rsqrt(double)</a></code>
*/
@OpenCLMapping(mapTo = "rsqrt")
public static float rsqrt(float _f) {
return (1.0f / (float) Math.sqrt(_f));
}
/**
* Computes inverse square root using {@link java.lang.Math#sqrt(double)} (Java) or delegates to <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/sqrt.html">rsqrt(double)</a></code> (OpenCL).
*
* User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
*
* @param _d value to delegate to {@link java.lang.Math#sqrt(double)}/<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/sqrt.html">rsqrt(double)</a></code>
* @return <code>( 1.0f / {@link java.lang.Math#sqrt(double)} )</code> /<code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/sqrt.html">rsqrt(double)</a></code>
*
* @see java.lang.Math#sqrt(double)
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/sqrt.html">rsqrt(double)</a></code>
*/
@OpenCLMapping(mapTo = "rsqrt")
public static double rsqrt(double _d) {
return (1.0 / Math.sqrt(_d));
}
@OpenCLMapping(mapTo = "native_sqrt")
public static float native_sqrt(float _f) {
int j = Float.floatToIntBits(_f);
j = ((1 << 29) + (j >> 1)) - (1 << 22) - 0x4c00;
return (Float.intBitsToFloat(j));
// could add more precision using one iteration of newton's method, use the following
}
@OpenCLMapping(mapTo = "native_rsqrt")
public static float native_rsqrt(float _f) {
int j = Float.floatToIntBits(_f);
j = 0x5f3759df - (j >> 1);
final float x = (Float.intBitsToFloat(j));
return x;
// if want more precision via one iteration of newton's method, use the following
// float fhalf = 0.5f*_f;
// return (x *(1.5f - fhalf * x * x));
}
// Hacked from AtomicIntegerArray.getAndAdd(i, delta)
/**
* Atomically adds <code>_delta</code> value to <code>_index</code> element of array <code>_arr</code> (Java) or delegates to <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/atomic_add.html">atomic_add(volatile int*, int)</a></code> (OpenCL).
*
*
* @param _arr array for which an element value needs to be atomically incremented by <code>_delta</code>
* @param _index index of the <code>_arr</code> array that needs to be atomically incremented by <code>_delta</code>
* @param _delta value by which <code>_index</code> element of <code>_arr</code> array needs to be atomically incremented
* @return previous value of <code>_index</code> element of <code>_arr</code> array
*
* @see <code><a href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/atomic_add.html">atomic_add(volatile int*, int)</a></code>
*/
@OpenCLMapping(atomic32 = true)
public static int atomicAdd(int[] _arr, int _index, int _delta) {
if (!Config.disableUnsafe) {
return UnsafeWrapper.atomicAdd(_arr, _index, _delta);
} else {
synchronized (_arr) {
final int previous = _arr[_index];
_arr[_index] += _delta;
return previous;
}
}
}
}