Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
65 lines (58 loc) · 2.33 KB

File metadata and controls

65 lines (58 loc) · 2.33 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/// The core GPU.js function
///
/// The parameter object contains the following sub parameters
///
/// +---------+---------------+---------------------------------------------------------------------------+
/// | Name | Default value | Description |
/// +---------+---------------+---------------------------------------------------------------------------+
/// | thread | [1024] | Thread dimension array |
/// | block | [1] | Block dimension array |
/// | mode | null | The CPU / GPU configuration mode, "auto" / null. Has the following modes. |
/// | | | + null / "auto" : Attempts to build GPU mode, else fallbacks |
/// | | | + "gpu" : Attempts to build GPU mode, else fallbacks |
/// | | | + "cpu" : Forces JS fallback mode only |
/// +---------+---------------+---------------------------------------------------------------------------+
///
/// @param inputFunction The calling to perform the conversion
/// @param paramObj The parameter configuration object
///
/// @returns callable function to run
var GPU = function(kernal, paramObj) {
//
// basic parameters safety checks
//
if( kernal == null ) {
throw "Missing kernal parameter";
}
if( {}.toString.call(kernal) !== '[object Function]' ) {
throw "kernal parameter not a function";
}
if( paramObj == null ) {
paramObj = {};
}
//
// Get the thread and block config, fallbacks to default value if not set
//
var thread = paramObj.thread || [1024];
var block = paramObj.block || [1];
var mode = paramObj.mode && paramObj.mode.toLowerCase();
//
// Attempts to do the webclgl conversion, returns if success
//
var ret = null;
if( mode == null || mode == "gpu" ) {
// Attempts to do the conversion to webclgl
if( (ret = GPU_jsToWebclgl(kernal, thread, block, paramObj)) != null) {
return ret;
}
// GPU only mode failed, return null
if( mode == "gpu" ) {
return null;
}
}
//
// Fallback to pure native JS
//
return GPU_jsFallback(kernal, thread, block, paramObj);
};
GPU._jsStrToWebclglStr = GPU_jsStrToWebclglStr;
Morty Proxy This is a proxified and sanitized view of the page, visit original site.