Sets the degree of parallelism for the iteration.

@param parallelism The degree of parallelism.
@return The iteration object, for function call chaining.
199013
public DeltaIteration<ST, WT> parallelism(int parallelism) {
		Validate.isTrue(parallelism > 0 || parallelism == -1, "The degree of parallelism must be positive, or -1 (use default).");
		this.parallelism = parallelism;
		return this;
	}
511392
BigInteger setMultiChoiceCount() {
    if (fields != null)
      for (int i = 0; i < fields.length; i++)
        multiChoiceCount = multiChoiceCount.multiply(fields[i].setMultiChoiceCount());
    return multiChoiceCount;
  }
1349407
public <T extends CacheSpec<K, V>> T concurrencyLevel(int concurrencyLevel) {
      checkArgument(concurrencyLevel > 0, "Concurrency Level must be > 0");
      this.concurrencyLevel = concurrencyLevel;
      return Cast.as(this);
   }
188336
def set_mpi_procs(self, mpi_procs):
        """"""
        QueueAdapter.set_mpi_procs(self, mpi_procs)

        num_nodes, rest_cores = self.hw.divmod_node(mpi_procs, omp_threads=1)
        if num_nodes == 0:
            self.qparams["nodes"] = 1
            self.qparams["ppn"] = mpi_procs
        else:
            if rest_cores != 0:
                # Pack cores as much as possible.
                num_nodes += 1
            self.qparams["nodes"] = num_nodes
            self.qparams["ppn"] = self.hw.cores_per_node
1175708
@Override
    public SpoutDeclarer setSpout(String id, IRichSpout spout, Number parallelismHint) throws IllegalArgumentException {
        return setSpout(id, spout, parallelismHint, true);
    }
320047
public @Nonnull SetType where(ProcessThread.Predicate pred) {
        HashSet<ThreadType> subset = new HashSet<ThreadType>(size() / 2);
        for (ThreadType thread: threads) {
            if (pred.isValid(thread)) subset.add(thread);
        }

        return runtime.getThreadSet(subset);
    }
1126247
protected int executeProgram(PackagedProgram program, Client client, int parallelism) {
		JobExecutionResult execResult;
		try {
			client.setPrintStatusDuringExecution(true);
			execResult = client.run(program, parallelism, true);
		}
		catch (ProgramInvocationException e) {
			return handleError(e);
		}
		finally {
			program.deleteExtractedLibraries();
		}
		
		// we come here after the job has finished
		if (execResult != null) {
			System.out.println("Job Runtime: " + execResult.getNetRuntime());
			Map<String, Object> accumulatorsResult = execResult.getAllAccumulatorResults();
			if (accumulatorsResult.size() > 0) {
				System.out.println("Accumulator Results: ");
				System.out.println(AccumulatorHelper.getResultsFormated(accumulatorsResult));
			}
		}
		return 0;
	}
1362729
public static <T> Stream<T> iteratorToStream(final Iterator<T> iterator, final Boolean parallel) {
        return stream(spliteratorUnknownSize(iterator, IMMUTABLE), parallel);
    }
1054028
public void setPduProcessorDegree(int pduProcessorDegree) throws IllegalStateException {
        if (!getSessionState().equals(SessionState.CLOSED)) {
            throw new IllegalStateException(
                    "Cannot set PDU processor degree since the PDU dispatcher thread already created");
        }
        this.pduProcessorDegree = pduProcessorDegree;
    }
846416
@Override public final void lcompute() {
    if( _hi-_lo >= 2 ) { // Multi-key case: just divide-and-conquer to 1 key
      final int mid = (_lo+_hi)>>>1; // Mid-point
      assert _left == null && _rite == null;
      T l = clone();
      T r = clone();
      _left = l; l._reservedMem = 0;
      _rite = r; r._reservedMem = 0;
      _left._hi = mid;          // Reset mid-point
      _rite._lo = mid;          // Also set self mid-point
      setPendingCount(1);
      // Compute min. memory required to run the right branch in parallel.  Min
      // memory equals to the max memory used if the right branch will be
      // executed single threaded (but in parallel with our left branch).
      // Assuming all memory is kept in the tasks and it is halved by reduce
      // operation, the min memory is proportional to the depth of the right
      // subtree.
      long reqMem = (log2(_hi - mid)+3)*memOverheadPerChunk();

      if(!_runSingleThreaded && MemoryManager.tryReserveTaskMem(reqMem)){
        _reservedMem += reqMem;   // Remember the amount of reserved memory to free it later.
        _left.fork();             // Runs in another thread/FJ instance
      } else {
        _left.compute2();
      }
      _rite.compute2();         // Runs in THIS F/J thread
    } else {
      if( _hi > _lo ) {         // Single key?
        try {
          map(_keys[_lo]);      // Get it, run it locally
        } catch( RuntimeException re ) { // Catch user-map-thrown exceptions
          throw H2O.setDetailMessage(re,re.getMessage()+" while mapping key "+_keys[_lo]);
        } catch( AssertionError re ) { // Catch user-map-thrown exceptions
          throw H2O.setDetailMessage(re,re.getMessage()+" while mapping key "+_keys[_lo]);
        } catch( OutOfMemoryError re ) { // Catch user-map-thrown exceptions
          throw H2O.setDetailMessage(re,re.getMessage()+" while mapping key "+_keys[_lo]);
        }
      }
      tryComplete();            // And this task is complete
    }
  }
1272928
@Override
  public Streamlet<R> repartition(int numPartitions) {
    return this.map((a) -> a).setNumPartitions(numPartitions);
  }
367591
@Override
  public void setNumThreadsForParsing(Integer numThreadsForParsing) {
    if (numThreadsForParsing == null) {
      this.numThreadsForParsing = Runtime.getRuntime().availableProcessors();
      return;
    }
    if (numThreadsForParsing < 1) {
      throw new IllegalArgumentException("The number of threads can not be less than 1.");
    }
    this.numThreadsForParsing = numThreadsForParsing;
  }
1229107
public void forAllInParallel(final ParallelProcedure procedure)
    {
        MithraCpuBoundThreadPool pool = MithraCpuBoundThreadPool.getInstance();
        final Object[] set = this.table;
        ThreadChunkSize threadChunkSize = new ThreadChunkSize(pool.getThreads(), set.length - 2, 1);
        final ArrayBasedQueue queue =new ArrayBasedQueue(set.length - 2, threadChunkSize.getChunkSize());
        int threads = threadChunkSize.getThreads();
        procedure.setThreads(threads, this.size() /threads);
        CpuBoundTask[] tasks = new CpuBoundTask[threads];
        for(int i=0;i<threads;i++)
        {
            final int thread = i;
            tasks[i] = new CpuBoundTask()
            {
                @Override
                public void execute()
                {
                    ArrayBasedQueue.Segment segment = queue.borrow(null);
                    while(segment != null)
                    {
                        for (int i = segment.getStart(); i < segment.getEnd(); i++)
                        {
                            Object e = arrayAt(set, i);
                            if (e != null)
                            {
                                procedure.execute(e, thread);
                            }
                        }
                        segment = queue.borrow(segment);
                    }
                }
            };
        }
        new FixedCountTaskFactory(tasks).startAndWorkUntilFinished();
    }
905981
def enable_parallel(processnum=None):
    
    global pool, dt, cut, cut_for_search
    from multiprocessing import cpu_count
    if os.name == 'nt':
        raise NotImplementedError(
            "jieba: parallel mode only supports posix system")
    else:
        from multiprocessing import Pool
    dt.check_initialized()
    if processnum is None:
        processnum = cpu_count()
    pool = Pool(processnum)
    cut = _pcut
    cut_for_search = _pcut_for_search
4932
def on_for_degrees(self, speed, degrees, brake=True, block=True):
        
        speed_sp = self._speed_native_units(speed)
        self._set_rel_position_degrees_and_speed_sp(degrees, speed_sp)
        self._set_brake(brake)
        self.run_to_rel_pos()

        if block:
            self.wait_until('running', timeout=WAIT_RUNNING_TIMEOUT)
            self.wait_until_not_moving()
635313
@Override
	public DataSet<Result<K>> runInternal(Graph<K, VV, EV> input)
			throws Exception {
		// s, d(s), 1/log(d(s))
		DataSet<Tuple3<K, LongValue, FloatValue>> inverseLogDegree = input
			.run(new VertexDegree<K, VV, EV>()
				.setParallelism(parallelism))
			.map(new VertexInverseLogDegree<>())
				.setParallelism(parallelism)
				.name("Vertex score");

		// s, t, 1/log(d(s))
		DataSet<Tuple3<K, K, FloatValue>> sourceInverseLogDegree = input
			.getEdges()
			.join(inverseLogDegree, JoinHint.REPARTITION_HASH_SECOND)
			.where(0)
			.equalTo(0)
			.projectFirst(0, 1)
			.<Tuple3<K, K, FloatValue>>projectSecond(2)
				.setParallelism(parallelism)
				.name("Edge score");

		// group span, s, t, 1/log(d(s))
		DataSet<Tuple4<IntValue, K, K, FloatValue>> groupSpans = sourceInverseLogDegree
			.groupBy(0)
			.sortGroup(1, Order.ASCENDING)
			.reduceGroup(new GenerateGroupSpans<>())
				.setParallelism(parallelism)
				.name("Generate group spans");

		// group, s, t, 1/log(d(s))
		DataSet<Tuple4<IntValue, K, K, FloatValue>> groups = groupSpans
			.rebalance()
				.setParallelism(parallelism)
				.name("Rebalance")
			.flatMap(new GenerateGroups<>())
				.setParallelism(parallelism)
				.name("Generate groups");

		// t, u, 1/log(d(s)) where (s, t) and (s, u) are edges in graph
		DataSet<Tuple3<K, K, FloatValue>> twoPaths = groups
			.groupBy(0, 1)
			.sortGroup(2, Order.ASCENDING)
			.reduceGroup(new GenerateGroupPairs<>())
				.name("Generate group pairs");

		// t, u, adamic-adar score
		GroupReduceOperator<Tuple3<K, K, FloatValue>, Result<K>> scores = twoPaths
			.groupBy(0, 1)
			.reduceGroup(new ComputeScores<>(minimumScore, minimumRatio))
				.name("Compute scores");

		if (minimumRatio > 0.0f) {
			// total score, number of pairs of neighbors
			DataSet<Tuple2<FloatValue, LongValue>> sumOfScoresAndNumberOfNeighborPairs = inverseLogDegree
				.map(new ComputeScoreFromVertex<>())
					.setParallelism(parallelism)
					.name("Average score")
				.sum(0)
				.andSum(1);

			scores
				.withBroadcastSet(sumOfScoresAndNumberOfNeighborPairs, SUM_OF_SCORES_AND_NUMBER_OF_NEIGHBOR_PAIRS);
		}

		if (mirrorResults) {
			return scores
				.flatMap(new MirrorResult<>())
					.name("Mirror results");
		} else {
			return scores;
		}
	}
703726
public static void setThreadPoolCPUsFraction(float fraction) {
		setThreadPoolSize(Math.max(1, Math.round(fraction * Runtime.getRuntime().availableProcessors())));
	}