aboutsummaryrefslogtreecommitdiff
path: root/emscripten.py
diff options
context:
space:
mode:
Diffstat (limited to 'emscripten.py')
-rwxr-xr-xemscripten.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/emscripten.py b/emscripten.py
index f9c8419e..5c74a319 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -145,10 +145,13 @@ def emscript(infile, settings, outfile, libraries=[]):
cores = multiprocessing.cpu_count()
assert cores >= 1
- intended_num_chunks = cores * NUM_CHUNKS_PER_CORE
- chunk_size = max(MIN_CHUNK_SIZE, total_ll_size / intended_num_chunks)
- chunk_size += len(forwarded_data)/3 + 3*len(meta) # keep ratio of lots of function code to meta (expensive to process) and forwarded (cheap)
- chunk_size = min(MAX_CHUNK_SIZE, chunk_size)
+ if cores > 1:
+ intended_num_chunks = cores * NUM_CHUNKS_PER_CORE
+ chunk_size = max(MIN_CHUNK_SIZE, total_ll_size / intended_num_chunks)
+ chunk_size += len(forwarded_data)/3 + 3*len(meta) # keep ratio of lots of function code to meta (expensive to process) and forwarded (cheap)
+ chunk_size = min(MAX_CHUNK_SIZE, chunk_size)
+ else:
+ chunk_size = MAX_CHUNK_SIZE # if 1 core, just use the max chunk size
if DEBUG: t = time.time()
forwarded_json = json.loads(forwarded_data)
@@ -165,7 +168,7 @@ def emscript(infile, settings, outfile, libraries=[]):
if curr:
chunks.append(curr)
curr = ''
- if cores == 1: assert len(chunks) == 1, 'no point in splitting up without multiple cores'
+ if cores == 1 and total_ll_size < MAX_CHUNK_SIZE: assert len(chunks) == 1, 'no point in splitting up without multiple cores'
if DEBUG: print >> sys.stderr, ' emscript: phase 2 working on %d chunks %s (intended chunk size: %.2f MB, meta: %.2f MB, forwarded: %.2f)' % (len(chunks), ('using %d cores' % cores) if len(chunks) > 1 else '', chunk_size/(1024*1024.), len(meta)/(1024*1024.), len(forwarded_data)/(1024*1024.))
commands = [(i, chunk + '\n' + meta, settings_file, compiler, forwarded_file, libraries) for chunk in chunks]