Repository navigation
Closed
Description
I see that a comment on pthread issue has been removed so I will describe what I'm struggling with
So I'm compiling with this command
emcc -v -O3 -g4 -DINIT_STATIC_MODULES=0 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=16 -s WASM=1 -s ASSERTIONS=1 -s "BINARYEN_METHOD='native-wasm'" -s RESERVED_FUNCTION_POINTERS=1 -s TOTAL_MEMORY=268435456 -s NO_EXIT_RUNTIME=0 -s EXTRA_EXPORTED_RUNTIME_METHODS="['FS', 'cwrap', 'ccall']" -s EXPORTED_FUNCTIONS="['_strlen', '_CsoundObj_closeAudioOut', '_CsoundObj_compileCSD', '_CsoundObj_compileOrc', '_CsoundObj_destroy', '_CsoundObj_evaluateCode', '_CsoundObj_getControlChannel', '_CsoundObj_getInputBuffer', '_CsoundObj_getInputChannelCount', '_CsoundObj_getKsmps', '_CsoundObj_getOutputBuffer', '_CsoundObj_getOutputChannelCount', '_CsoundObj_getTable', '_CsoundObj_getTableLength', '_CsoundObj_getZerodBFS', '_CsoundObj_new', '_CsoundObj_openAudioOut', '_CsoundObj_pause', '_CsoundObj_performKsmps', '_CsoundObj_play', '_CsoundObj_prepareRT', '_CsoundObj_pushMidiMessage', '_CsoundObj_readScore' , '_CsoundObj_inputMessage', '_CsoundObj_inputMessageAsync', '_CsoundObj_render' , '_CsoundObj_reset', '_CsoundObj_setControlChannel', '_CsoundObj_setMidiCallbacks', '_CsoundObj_setOption', '_CsoundObj_setOutputChannelCallback', '_CsoundObj_getScoreTime', '_CsoundObj_setStringChannel', '_CsoundObj_setTable']" CsoundObj.bc FileList.bc libcsound.a ../deps/libsndfile-1.0.25/libsndfile-wasm.a -o libcsound.js
when running this output I get
TypeError: [object Uint32Array] is not an integer shared typed array.
at Atomics.store (<anonymous>)
at Object.initMainThreadBlock (/home/hlolli/csound/csound-wasm/node_modules/libcsound/libcsound.js:1828:17)
at Object.<anonymous> (/home/hlolli/csound/csound-wasm/node_modules/libcsound/libcsound.js:7673:38)
at Module._compile (module.js:662:30)
at Object.Module._extensions..js (module.js:673:10)
at Module.load (module.js:575:32)
at tryModuleLoad (module.js:515:12)
at Function.Module._load (module.js:507:3)
at Module.require (module.js:606:17)
at require (internal/module.js:11:18)
what's happening is that the buffer given to the Uint32Array is not of type SharedArrayBuffer, so when ensureing that
function updateGlobalBufferViews() {
if (!(buffer instanceof SharedArrayBuffer)) {
buffer = new SharedArrayBuffer(buffer.byteLength );
}
Module['HEAP8'] = HEAP8 = new Int8Array(buffer);
Module['HEAP16'] = HEAP16 = new Int16Array(buffer);
Module['HEAP32'] = HEAP32 = new Int32Array(buffer);
Module['HEAPU8'] = HEAPU8 = new Uint8Array(buffer);
Module['HEAPU16'] = HEAPU16 = new Uint16Array(buffer);
Module['HEAPU32'] = HEAPU32 = new Uint32Array(buffer);
Module['HEAPF32'] = HEAPF32 = new Float32Array(buffer);
Module['HEAPF64'] = HEAPF64 = new Float64Array(buffer);
}
I'm welcomed with another error
failed to asynchronously prepare wasm: CompileError: WasmCompile: Compiling wasm function #4442:_sbrk failed: invalid block arity > 1 @+2443509
CompileError: WasmCompile: Compiling wasm function #4442:_sbrk failed: invalid block arity > 1 @+2443509
at /home/hlolli/csound/csound-wasm/node_modules/libcsound/libcsound.js:1612:28
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:160:7)
at Function.Module.runMain (module.js:705:11)
at startup (bootstrap_node.js:193:16)
at bootstrap_node.js:665:3
CompileError: WasmCompile: Compiling wasm function #4442:_sbrk failed: invalid block arity > 1 @+2443509
at /home/hlolli/csound/csound-wasm/node_modules/libcsound/libcsound.js:1612:28
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:160:7)
at Function.Module.runMain (module.js:705:11)
at startup (bootstrap_node.js:193:16)
at bootstrap_node.js:665:3
node.js exiting due to unhandled promise rejection
I'm running on node v9.6.1, emsdk incoming compiled yesterday
add that this all works great then -s USE_PTHREADS=1 is not present. I'm hopeful to see pthread support available in coming days/weeks.
Metadata
Metadata
Assignees
Labels
No labels
Activity
dschuff commentedon Mar 13, 2018
Pthread support is currently built on top of web workers and SharedArrayBuffer. As far as I know, nodejs does not support SharedArrayBuffer, or any other mechanism to share memory. Do you know if I'm wrong about that, or if it's on the roadmap?
hlolli commentedon Mar 13, 2018
@dschuff Nodejs 9x supports atomics and SharedArrayBuffer by default, workers even longer.
ps. workers would be in node the cluster api to be accurate.
timkerchmar commentedon May 22, 2018
WebAssembly/binaryen#1419 is related, depending upon whether or not one uses USE_PTHREAD=1 or USE_PTHREAD=2
Tested on Chrome Version 66.0.3359.181 (Official Build) (64-bit) OSX 10.13.4 (17E202) with SharedArrayBuffers enabled.
kripken commentedon Aug 26, 2019
Closing as this appears to be the same as #6567 and there is more discussion there.