parallel-processing

GNU Parallel: split file into children

只愿长相守 提交于 2021-02-18 11:34:09
问题 Goal Use GNU Parallel to split a large .gz file into children. Since the server has 16 CPUs, create 16 children. Each child should contain, at most, N lines. Here, N = 104,214,420 lines. Children should be in .gz format. Input File name: file1.fastq.gz size: 39 GB line count: 1,667,430,708 (uncompressed) Hardware 36 GB Memory 16 CPUs HPCC environment (I'm not admin) Code Version 1 zcat "${input_file}" | parallel --pipe -N 104214420 --joblog split_log.txt --resume-failed "gzip > ${input_file}

How to get the result of multiprocessing.Pool.apply_async

懵懂的女人 提交于 2021-02-18 10:45:07
问题 I want to get the result of the function run by Pool.apply_async in Python. How to assign the result to a variable in the parent process? I tried to use callback but it seems complicated. 回答1: The solution is very simple: import multiprocessing def func(): return 2**3**4 p = multiprocessing.Pool() result = p.apply_async(func).get() print(result) Since Pool.apply_async() returns an AsyncResult, you can simply get the result from the AsyncResult.get() method. Hope this helps! 回答2: Well an easy

Code coverage using gcov on parallel run

試著忘記壹切 提交于 2021-02-18 06:25:31
问题 I have C/C++ code coverage setup with gcov for several files in the project. The executables are being run in parallel. This results in some shared piece of code to be run in parallel. I am getting corrupt .da files or zero sized .da files. Is this a problem on parallel run? Because two or more executable instance is trying to write on the same .da file for writing the coverage count for each statement in execution? If so, is there any workaround? Gcov version being used is 1.5 回答1: I had a

Two functions in parallel with multiple arguments and return values

做~自己de王妃 提交于 2021-02-17 19:42:37
问题 I've got two separate functions. Each of them takes quite a long time to execute. def function1(arg): do_some_stuff_here return result1 def function2(arg1, arg2, arg3): do_some_stuff_here return result2 I'd like to launch them in parallel, get their results (knowing which is which) and process the results afterwards. For what I've understood, multiprocessing is more efficient than Threading in Python 2.7 (GIL related issue). However I'm a bit lost whether it is better to use Process, Pool or

c++ how to elegantly use c++17 parallel execution with for loop that counts an integer?

泄露秘密 提交于 2021-02-16 10:48:49
问题 I can do std::vector<int> a; a.reserve(1000); for(int i=0; i<1000; i++) a.push_back(i); std::for_each(std::execution::par_unseq, std::begin(a), std::end(a), [&](int i) { ... do something based on i ... }); but is there a more elegant way of creating a parallelized version of for(int i=0; i<n; i++) that does not require me to first fill a vector with ascending ints? 回答1: You could use std::generate to create a vector {0, 1, ..., 999} std::vector<int> v(1000); std::generate(v.begin(), v.end(),

c++ how to elegantly use c++17 parallel execution with for loop that counts an integer?

回眸只為那壹抹淺笑 提交于 2021-02-16 10:48:23
问题 I can do std::vector<int> a; a.reserve(1000); for(int i=0; i<1000; i++) a.push_back(i); std::for_each(std::execution::par_unseq, std::begin(a), std::end(a), [&](int i) { ... do something based on i ... }); but is there a more elegant way of creating a parallelized version of for(int i=0; i<n; i++) that does not require me to first fill a vector with ascending ints? 回答1: You could use std::generate to create a vector {0, 1, ..., 999} std::vector<int> v(1000); std::generate(v.begin(), v.end(),

R nested foreach loop

亡梦爱人 提交于 2021-02-11 15:21:46
问题 I have an input dataset: # environment require(pacman) p_load( data.table , doParallel , foreach ) doParallel::registerDoParallel(makeCluster(4)) # create input runDT <- data.table(run = c(F,T,F,T) , input1 = 1:4 , run_id = 1:4) print(runDT) run input1 run_id 1: FALSE 1 1 2: TRUE 2 2 3: FALSE 3 3 4: TRUE 4 4 and this is another raw dataset: dataDT <- data.table( ID = 1:4 , c1 = c(1:4)) print(dataDT) ID c1 1: 1 1 2: 2 2 3: 3 3 4: 4 4 I would like to run nested foreach loops, but it's giving me

How to write efficient nested functions for parallelization?

爱⌒轻易说出口 提交于 2021-02-11 13:32:48
问题 I have a dataframe with two grouping variables class and group . For each class, I have a plotting task per group. Mostly, I have 2 levels per class and 500 levels per group . I'm using parallel package for parallelization and mclapply function for the iteration through class and group levels. I'm wondering which is the best way to write my iterations. I think I have two options: Run parallelization for class variable. Run parallelization for group variable. My computer has 3 cores working

Tasks combine result and continue

一曲冷凌霜 提交于 2021-02-11 12:41:01
问题 I have 16 tasks doing the same job, each of them return an array. I want to combine the results in pairs and do same job until I have only one task. I don't know what is the best way to do this. public static IComparatorNetwork[] Prune(IComparatorNetwork[] nets, int numTasks) { var tasks = new Task[numTasks]; var netsPerTask = nets.Length/numTasks; var start = 0; var concurrentSet = new ConcurrentBag<IComparatorNetwork>(); for(var i = 0; i < numTasks; i++) { IComparatorNetwork[] taskNets; if

Using Parallel Processing in C# to test a site's ability to withstand a DDOS

纵饮孤独 提交于 2021-02-11 07:14:14
问题 I have a website and I am also exploring Parallel Processing in C# and I thought it would be a good idea to see if I could write my own DDOS test script to see how the site would handle a DDOS attack. However when I run it, there only seems to be 13 threads in use and they always return 200 status codes, never anything to suggest the response wasn't quick and accurate and when going to the site and refreshing at the same time as the script runs the site loads quickly. I know there are tools