Skip to content

Commit

Permalink
first!@
Browse files Browse the repository at this point in the history
  • Loading branch information
juliancoy committed Nov 3, 2022
0 parents commit 7993da2
Show file tree
Hide file tree
Showing 9 changed files with 564 additions and 0 deletions.
Empty file added __init__.py
Empty file.
Binary file added __pycache__/platform_constants.cpython-38.pyc
Binary file not shown.
Binary file added a.spv
Binary file not shown.
270 changes: 270 additions & 0 deletions debug.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,270 @@
{
"X": [
[
0.4850345677623107,
0.49256887049068876,
0.9544215323752723,
0.8316750879387192,
0.2455178209744614,
0.2224894737708638,
0.05922014629196104,
0.7096989504108208,
0.29608457541476074,
0.06701213544329854
],
[
0.19960161529425802,
0.020210890721017116,
0.09787379078417391,
0.9651742404006396,
0.28096785053844886,
0.5422414279663501,
0.602005603427683,
0.013684287967642872,
0.45704021659788463,
0.22355829500053792
],
[
0.3122667890130594,
0.6340635804626944,
0.8072278075473777,
0.0680372317705723,
0.19750799126182983,
0.6954054247569231,
0.6845712887758783,
0.6328866656851714,
0.6848390178386987,
0.6542514990141443
],
[
0.3703243912528851,
0.6590061585146761,
0.6494486394982105,
0.18249100787954953,
0.018441132658261083,
0.47207303344340823,
0.3399809463248953,
0.7502235453188846,
0.4183741708483327,
0.49019183810175027
],
[
0.6143378445042829,
0.6294068166470141,
0.9624826756056465,
0.9830776784027497,
0.790378361599205,
0.7818601286316995,
0.7882306710643836,
0.19500461523669776,
0.07087522574305294,
0.35487484717662654
],
[
0.257452569329091,
0.10002213931278647,
0.04403838378374525,
0.5333930899170357,
0.44653916805219973,
0.2794215933803682,
0.36559192123265505,
0.4577665343810915,
0.24700469827727656,
0.695785137866247
],
[
0.48650240448414017,
0.9064684711354465,
0.34413807692218823,
0.3688553848087046,
0.8544087356474218,
0.8293928442993455,
0.5414118516429892,
0.9245702516050001,
0.6374953956098276,
0.27981425386570336
],
[
0.598003719801128,
0.7655818199267701,
0.6134184540482582,
0.23541215021502748,
0.026682876639427033,
0.879729540213243,
0.33709858901266176,
0.4514661541628887,
0.9471087562770654,
0.6365244683982263
],
[
0.2916166518290815,
0.20328244884175262,
0.3675255607232898,
0.03358616793629465,
0.8188848775842635,
0.19285241665425024,
0.9738098776131882,
0.916317141008338,
0.8218695990879115,
0.8488011560199451
],
[
0.46438412130972695,
0.9832894192996664,
0.0607135777673905,
0.35018954724195894,
0.1469396029837352,
0.2835956644875304,
0.07922917872871826,
0.23540437335655184,
0.4238740854985594,
0.3471526377396901
]
],
"Y": [
0.5556480848672603,
0.11833895491364355,
0.3661189487776325,
0.5785537982923099,
0.6061376825763163,
0.03061047005112061,
0.9146032856013869,
0.12600241009766855,
0.9898577617060005,
0.02571329299739189
],
"Z": [
1.7524187499713502,
1.904915911810351,
2.1250257559273353,
1.4849537327087465,
2.6647674827379366,
1.413268574099614,
2.5101701012231166,
2.145830313425626,
2.6838095851285915,
1.2276003774566175
],
"thisAdd": [
[
0.2695085286715473,
0.05829008535686194,
0.34943180812397184,
0.48116878107203687,
0.14881760303664693,
0.006810507373552611,
0.05416294037242236,
0.08942377819554917,
0.29308161509572656,
0.0017231026730344452
],
[
0.1109082552746661,
0.002391735685799021,
0.03583344939478369,
0.5584052227976851,
0.1703052018038242,
0.016598264991240834,
0.5505963028454044,
0.0017242532643935284,
0.45240480581120773,
0.005748419941346202
],
[
0.17351044328275528,
0.07503442146075819,
0.29554139632331894,
0.03936319886615883,
0.11971703611374886,
0.0212866869279086,
0.6261111499427942,
0.07974524519500902,
0.67789321732675,
0.016822960488133542
],
[
0.20577003877929959,
0.07798610008028169,
0.23777545317814847,
0.10558086576290523,
0.011177865413560797,
0.014450377452161106,
0.310947690550618,
0.09452997482219692,
0.4141309203115345,
0.012604446358040394
],
[
0.3413556467602855,
0.07448334489753092,
0.3523831454094224,
0.5687633248562968,
0.47907810845820786,
0.023933106051645944,
0.7209183615672713,
0.024571051499992457,
0.07015639231442589,
0.00912500092285727
],
[
0.14305302709186496,
0.011836515434502011,
0.01612328677677075,
0.3085965981543726,
0.2706642165027166,
0.008553226315806161,
0.33437157234870973,
0.05767968659407478,
0.24449951776761097,
0.017890927113185517
],
[
0.2703241293349297,
0.10727053153633699,
0.12599547095710759,
0.21340268390164763,
0.5178893309982887,
0.025388104821038853,
0.4951770583762086,
0.11649808000683781,
0.6310297653962252,
0.007194945894495427
],
[
0.3322796216509945,
0.09059815247101922,
0.2245841195569488,
0.13619859367106396,
0.01617349701069203,
0.026928934743783578,
0.30831147708257206,
0.05688582350204956,
0.9375029535805699,
0.016367140155932706
],
[
0.16203623410423174,
0.024056232548219213,
0.13455807194092081,
0.019431405029626665,
0.49635698199571593,
0.00590330312428116,
0.8906497136161063,
0.11545816818085579,
0.813534001767368,
0.021825472821265797
],
[
0.25803414764851523,
0.11636144225756596,
0.022228391268726052,
0.20260349267909963,
0.08906563043124523,
0.008680996594423196,
0.07246326718078525,
0.029661518390456925,
0.4195750535167819,
0.008926437489018096
]
]
}
9 changes: 9 additions & 0 deletions platform_constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import numpy as np


default_constants = {
"PLATFORM_SIMPLE": "Default",
"LOCAL_X": 32,
"LOCAL_Y": 16,
"LOCAL_Z": 1,
}
82 changes: 82 additions & 0 deletions sdot.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#version 450
#extension GL_EXT_shader_explicit_arithmetic_types_float64 : require
//#extension GL_EXT_shader_explicit_arithmetic_types_int64 : enable
#extension GL_ARB_separate_shader_objects : enable
#extension GL_EXT_scalar_block_layout : require
DEFINE_STRING // This will be (or has been) replaced by constant definitions
layout (local_size_x = LOCAL_X, local_size_y = LOCAL_Y, local_size_z = LOCAL_Z ) in;
BUFFERS_STRING // This will be (or has been) replaced by buffer definitions

//float64_t vectordot(in float64_t* a, in float64_t* b, in uint length){
// sum = 0;
// for(uint i = 0; i < length; i++){
// sum += a[i] * b[i];
// }
//
// return sum;
//}

void main() {
//uint sampleNo = gl_LocalInvocationID.x;
//uint shaderIndexInSample = gl_LocalInvocationID.y;
//uint zindex = gl_LocalInvocationID.z;

//uint globalIndex = gl_LocalInvocationIndex;
uint globalIndex = gl_LocalInvocationID.x*LOCAL_Y + gl_LocalInvocationID.y;

// assume workgroup size 1
//uint workgroupSize = LOCAL_X*LOCAL_Y*LOCAL_Z;
//uint workgroupNo = gl_GlobalInvocationID;
//uint globalIndex = workgroupNo*workgroupSize + indexInWorkgroup;

// now break the problem into workgroupSize parts
// (for max compatibility, 32x16 = 512

uint wPerShader = uint(XDIM0 / (LOCAL_X * LOCAL_Y)) + 1;

float64_t sum = 0;
// assume X array is 2 dimensions, Y array is 1d
// x array, b dimension is the same as y array,
uint startW = globalIndex*wPerShader;
uint endW = (globalIndex+1)*wPerShader;

for(uint w = startW; w < endW; w++){
//Z[w] = vectordot(X+w*XDIM1, Y, XDIM1);

if(w >= XDIM0)
break;
uint startN = w*XDIM1;
sum = 0;
for(uint n = 0; n < XDIM1; n++){
uint nx =startN + n;
thisAdd = X[nx] * Y[n];
sum += thisAdd;
}

Z[w] = sum;
}

//for(uint i = 0; i < 10; i++)
// if(i == globalIndex)
// Z[i] = i + 1;
}

// Multiple W example
// (ex. for Loiacono Transform)
// [ar0, br0, cr0, dr0 ... zr0] * [as0, bs0, cs0 ... zs0]
// [ar1, br1, cr1, dr1 ... zr1]
// [..., ..., ..., ... ... ...]
// [arw, brw, crw, drw ... zrw]
//
// each dispatch should handle 1 (or more) w rows
// in the case of Twelve-Tone Equal Temperment,
// provide 128 notes (MIDI STANDARD)
// this allows for 512/128 = 4 near-frequencies for each note
//. W is on dimension 0
// Provide X is the EIWN array, Y is the real signal

// Complex numbers example
// (ex. for Loiacono Transform)
// [ar0, br, cr, dr ... zr]
// [ai0, bi, ci, di ... zi]
//
Loading

0 comments on commit 7993da2

Please sign in to comment.