use external sMem, need to find an optimized upper bound