# \#multithreading

**URL:** https://discourse.julialang.org/tag/multithreading/100.md?page=3

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

**Page:** 4

---

## [Parallelized calls to Optim.optimize use the same number of threads as a single threaded call](https://discourse.julialang.org/t/parallelized-calls-to-optim-optimize-use-the-same-number-of-threads-as-a-single-threaded-call/121388)

<div class="topic-metadata">

**Author:** [@adannenberg](https://discourse.julialang.org/u/adannenberg)\
**Replies:** 4\
**Last updated:** [October 16, 2024, 4:56pm UTC](https://discourse.julialang.org/t/parallelized-calls-to-optim-optimize-use-the-same-number-of-threads-as-a-single-threaded-call/121388 "2024-10-16T16:56:18Z")

</div>

To investigate how sample size affects uncertainty in parameter inference, I do something like: Θ\_example = something #Θ is a vector of the parameters I'm trying to infer Θvec = zeros(numSamples, size(Θ\_example)) for …

---

## [IO Parallelism Strategies](https://discourse.julialang.org/t/io-parallelism-strategies/120970)

<div class="topic-metadata">

**Author:** [@mrufsvold](https://discourse.julialang.org/u/mrufsvold)\
**Replies:** 3\
**Last updated:** [October 6, 2024, 9:14pm UTC](https://discourse.julialang.org/t/io-parallelism-strategies/120970 "2024-10-06T21:14:46Z")

</div>

I have a use case with many small IOs (get/put S3 objects \<300mb), a heartbeat (keep SQS message from timing out), and a heavy compute task which consumes a constant stream of inputs. The machine I’m using has 2 cores. R…

---

## [Terminate a task](https://discourse.julialang.org/t/terminate-a-task/120855)

<div class="topic-metadata">

**Author:** [@zoythum](https://discourse.julialang.org/u/zoythum)\
**Replies:** 2\
**Last updated:** [October 3, 2024, 1:03pm UTC](https://discourse.julialang.org/t/terminate-a-task/120855 "2024-10-03T13:03:22Z")

</div>

I am using ZMQ to create a publisher subscriber infrastructure. The main problem I am facing is that the recv function blocks the execution of the code. I would like to spawn a Task that is responsible for receiving a ne…

---

## [How to call PythonCall.jl behind a julia HTTP webserver?](https://discourse.julialang.org/t/how-to-call-pythoncall-jl-behind-a-julia-http-webserver/119563)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 2\
**Last updated:** [September 24, 2024, 2:09pm UTC](https://discourse.julialang.org/t/how-to-call-pythoncall-jl-behind-a-julia-http-webserver/119563 "2024-09-24T14:09:21Z")

</div>

Hi there, I am wondering how I could use langchain from Python as part of a webserver. I am running into segmenation faults certainly due to multithreading. Does someone know a way whether the new @unlock and @lock are …

---

## [Is it safe to run Revise from multiple threads?](https://discourse.julialang.org/t/is-it-safe-to-run-revise-from-multiple-threads/119743)

<div class="topic-metadata">

**Author:** [@frankier](https://discourse.julialang.org/u/frankier)\
**Replies:** 2\
**Last updated:** [September 23, 2024, 5:26pm UTC](https://discourse.julialang.org/t/is-it-safe-to-run-revise-from-multiple-threads/119743 "2024-09-23T17:26:45Z")

</div>

Is it safe to run Revise from multiple threads? It seems that Revise in typical usage, e.g. a REPL session, will only run in the interactive thread, and then the updated code will end up run in existing threads, assuming…

---

## [Acquiring locks in finalizers](https://discourse.julialang.org/t/acquiring-locks-in-finalizers/119628)

<div class="topic-metadata">

**Author:** [@remysucre](https://discourse.julialang.org/u/remysucre)\
**Replies:** 3\
**Last updated:** [September 20, 2024, 5:05pm UTC](https://discourse.julialang.org/t/acquiring-locks-in-finalizers/119628 "2024-09-20T17:05:56Z")

</div>

The manual has an example with a finalizer that acquires a lock (without blocking). However, in the Locks section it also says: The following are definitely leaf locks (level 1), and must not try to acquire any other l…

---

## [How to increase the stack size of Julia threads?](https://discourse.julialang.org/t/how-to-increase-the-stack-size-of-julia-threads/70359)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 2\
**Last updated:** [September 15, 2024, 12:15pm UTC](https://discourse.julialang.org/t/how-to-increase-the-stack-size-of-julia-threads/70359 "2024-09-15T12:15:28Z")

</div>

I’m doing multiple recursive computations (Welzl’s algorithm) in parallel using Threads.@threads, producing a stack overflow. This is on latest Linux and Julia 1.7.0-rc2. How do increase the size of a thread’s stack? (…

---

## [Correct use of @spawn with data frames](https://discourse.julialang.org/t/correct-use-of-spawn-with-data-frames/118921)

<div class="topic-metadata">

**Author:** [@kobusherbst](https://discourse.julialang.org/u/kobusherbst)\
**Replies:** 2\
**Last updated:** [September 3, 2024, 11:15am UTC](https://discourse.julialang.org/t/correct-use-of-spawn-with-data-frames/118921 "2024-09-03T11:15:46Z")

</div>

I am new to multithreading, I have the following snippet of code: memberships = table\_read(db, "IndividualMemberships") sort!(memberships, \[:IndividualId, :HouseholdId, :StartDate\]) gdf\_memberships = groupby(memberships…

---

## [Help needed getting started with threads!](https://discourse.julialang.org/t/help-needed-getting-started-with-threads/118911)

<div class="topic-metadata">

**Author:** [@TimG](https://discourse.julialang.org/u/TimG)\
**Replies:** 27\
**Last updated:** [September 2, 2024, 11:09am UTC](https://discourse.julialang.org/t/help-needed-getting-started-with-threads/118911 "2024-09-02T11:09:05Z")

</div>

I can’t get threads to work for me despite the sense I’ve picked up here that it should be easy. I have a large number (hundreds) of Excel files to write out. I construct them from a largeish dataset using a simple temp…

---

## [How to use Base.Libc.errno](https://discourse.julialang.org/t/how-to-use-base-libc-errno/118832)

<div class="topic-metadata">

**Author:** [@nhz2](https://discourse.julialang.org/u/nhz2)\
**Replies:** 3\
**Last updated:** [September 1, 2024, 7:20am UTC](https://discourse.julialang.org/t/how-to-use-base-libc-errno/118832 "2024-09-01T07:20:21Z")

</div>

The docs for errno in Julia states: The value of errno is only valid immediately after a ccall to a C library routine that sets it. Specifically, you cannot call errno at the next prompt in a REPL, because lots of code…

---

## [Manage tasks from Threads.@spawn without using map()](https://discourse.julialang.org/t/manage-tasks-from-threads-spawn-without-using-map/118493)

<div class="topic-metadata">

**Author:** [@felipe\_1](https://discourse.julialang.org/u/felipe_1)\
**Replies:** 16\
**Last updated:** [August 27, 2024, 2:55pm UTC](https://discourse.julialang.org/t/manage-tasks-from-threads-spawn-without-using-map/118493 "2024-08-27T14:55:57Z")

</div>

Hi, I need to analyze a long vector and calculate the occurrences of certain letters, as it will be very long it will be better to use parallel processing for this. The thing is, I can do this with map(), storing tasks…

---

## [Bitten by BLAS threading. Again. (Interaction w/ MPI.)](https://discourse.julialang.org/t/bitten-by-blas-threading-again-interaction-w-mpi/118533)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 2\
**Last updated:** [August 24, 2024, 2:19pm UTC](https://discourse.julialang.org/t/bitten-by-blas-threading-again-interaction-w-mpi/118533 "2024-08-24T14:19:10Z")

</div>

I ran some MPI codes. On a Mac 2 Ultra (16 performance cores), and on a Grace+Grace system (two sockets, 72 cores each). The runs were carried out with 4 processes on a single machine (node). There was a weird mismatch …

---

## [Julia -\> C (Pthread) -\> Julia Saxpy with Threads](https://discourse.julialang.org/t/julia-c-pthread-julia-saxpy-with-threads/118097)

<div class="topic-metadata">

**Author:** [@miniskar](https://discourse.julialang.org/u/miniskar)\
**Replies:** 1\
**Last updated:** [August 12, 2024, 4:49pm UTC](https://discourse.julialang.org/t/julia-c-pthread-julia-saxpy-with-threads/118097 "2024-08-12T16:49:28Z")

</div>

I am having an C++ library environment where I am supposed to call Julia kernel (example SAXPY) with threading. A minimum work example to illustrate the issue is given below. The Julia main() function calls ‘call\_direc…

---

## [\[ANN\] Announcing ThreadPinning.jl](https://discourse.julialang.org/t/ann-announcing-threadpinning-jl/92230)

<div class="topic-metadata">

**Author:** [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Replies:** 13\
**Last updated:** [August 8, 2024, 8:50am UTC](https://discourse.julialang.org/t/ann-announcing-threadpinning-jl/92230 "2024-08-08T08:50:37Z")

</div>

Hi all, It’s already been out there for a while but I nonetheless wanted to properly announce ThreadPinning.jl here. :slight\_smile: What is ThreadPinning.jl about? In short, it’s about pinning Julia threads to specific…

---

## [Multithreaded broadcast on a grouped DimensionalData array](https://discourse.julialang.org/t/multithreaded-broadcast-on-a-grouped-dimensionaldata-array/117607)

<div class="topic-metadata">

**Author:** [@aasdelat](https://discourse.julialang.org/u/aasdelat)\
**Replies:** 33\
**Last updated:** [August 6, 2024, 4:04pm UTC](https://discourse.julialang.org/t/multithreaded-broadcast-on-a-grouped-dimensionaldata-array/117607 "2024-08-06T16:04:30Z")

</div>

Hello: I am using the Rasters.jl package to read and work with data on a spatial and a time dimension (two dimensions). So it is a Raster with two dimensions. I have gropued the raster by means of the groupby() functio…

---

## [Macro to turn on/off parallelisation](https://discourse.julialang.org/t/macro-to-turn-on-off-parallelisation/117808)

<div class="topic-metadata">

**Author:** [@jibe](https://discourse.julialang.org/u/jibe)\
**Replies:** 15\
**Last updated:** [August 5, 2024, 4:50am UTC](https://discourse.julialang.org/t/macro-to-turn-on-off-parallelisation/117808 "2024-08-05T04:50:32Z")

</div>

I want to define a macro, @parallel, to turn on/off parallelisation in for loops, depending on a command-line argument. Here, parallelisation is embarassing and uses Threads.@threads. Why would I want to do this? Becaus…

---

## [Parallel Branch and Bound Priority Queue](https://discourse.julialang.org/t/parallel-branch-and-bound-priority-queue/117818)

<div class="topic-metadata">

**Author:** [@phK3](https://discourse.julialang.org/u/phK3)\
**Replies:** 1\
**Last updated:** [August 4, 2024, 7:41pm UTC](https://discourse.julialang.org/t/parallel-branch-and-bound-priority-queue/117818 "2024-08-04T19:41:58Z")

</div>

I’ve implemented code for a simple branch and bound procedure for maximizing a function in Julia (actually I’ve tweaked the code in NeuralPriorityOptimizer.jl). Currently the code runs on a single thread, but I’d like t…

---

## [Thread-safe array building](https://discourse.julialang.org/t/thread-safe-array-building/3275)

<div class="topic-metadata">

**Author:** [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Replies:** 21\
**Last updated:** [October 24, 2017, 4:09pm UTC](https://discourse.julialang.org/t/thread-safe-array-building/3275 "2017-10-24T16:09:35Z")

</div>

I want to use threading to build a result. But it seems push! isn’t thread-safe: num\_monte = Int(1e6) solution\_data = Vector{Float64}() Threads.@threads for i in 1:num\_monte push!(solution\_data,i) …

---

## [Objects not being finalized until exit() when using multithreading. Is this a bug?](https://discourse.julialang.org/t/objects-not-being-finalized-until-exit-when-using-multithreading-is-this-a-bug/117595)

<div class="topic-metadata">

**Author:** [@cjdoris](https://discourse.julialang.org/u/cjdoris)\
**Replies:** 2\
**Last updated:** [July 29, 2024, 4:17pm UTC](https://discourse.julialang.org/t/objects-not-being-finalized-until-exit-when-using-multithreading-is-this-a-bug/117595 "2024-07-29T16:17:21Z")

</div>

Here’s a script which defines a mutable struct Foo, creates 10 of them, loops over them using Threads.@threads and then calls GC: mutable struct Foo value::Int function Foo(value) finalizer(new(value)) d…

---

## [How to achieve Non blocking IO with Julia](https://discourse.julialang.org/t/how-to-achieve-non-blocking-io-with-julia/117503)

<div class="topic-metadata">

**Author:** [@Chamika\_Kasun](https://discourse.julialang.org/u/Chamika_Kasun)\
**Replies:** 3\
**Last updated:** [July 29, 2024, 6:48am UTC](https://discourse.julialang.org/t/how-to-achieve-non-blocking-io-with-julia/117503 "2024-07-29T06:48:23Z")

</div>

I have a function that is executed through a Julia thread. In this function, there is a execute\_psql\_string\_await function that performs a PostgreSQL stored procedure call using the LibPQ library. Currently, while this q…

---

## [Bad performances when using Multithreading and Distributed with heavy LinearAlgebra calculations](https://discourse.julialang.org/t/bad-performances-when-using-multithreading-and-distributed-with-heavy-linearalgebra-calculations/117258)

<div class="topic-metadata">

**Author:** [@albertomercurio](https://discourse.julialang.org/u/albertomercurio)\
**Replies:** 26\
**Last updated:** [July 25, 2024, 10:59pm UTC](https://discourse.julialang.org/t/bad-performances-when-using-multithreading-and-distributed-with-heavy-linearalgebra-calculations/117258 "2024-07-25T22:59:58Z")

</div>

Hello, I have noticed that Julia multithreading and Distributed scale very badly when calculating relatively heavy computations involving BLAS and LAPACK. As an example, here I show you the calculation of the expv funct…

---

## [Automatic Compiler Optimizations and Multithreading](https://discourse.julialang.org/t/automatic-compiler-optimizations-and-multithreading/117321)

<div class="topic-metadata">

**Author:** [@NonDairyNeutrino](https://discourse.julialang.org/u/NonDairyNeutrino)\
**Replies:** 11\
**Last updated:** [July 24, 2024, 1:29pm UTC](https://discourse.julialang.org/t/automatic-compiler-optimizations-and-multithreading/117321 "2024-07-24T13:29:24Z")

</div>

I learned in my HPC class that for languages such as C/C++ and Fortran, invoking automatic compiler optimizations using the (gcc) -On flag could lead to unintended behaviors when compiling multithreaded programs; somethi…

---

## [Looking to parallelize (not parametrize) the solution to a large and highly stiff ODE system](https://discourse.julialang.org/t/looking-to-parallelize-not-parametrize-the-solution-to-a-large-and-highly-stiff-ode-system/116727)

<div class="topic-metadata">

**Author:** [@balaji\_sriram](https://discourse.julialang.org/u/balaji_sriram)\
**Replies:** 7\
**Last updated:** [July 13, 2024, 12:41pm UTC](https://discourse.julialang.org/t/looking-to-parallelize-not-parametrize-the-solution-to-a-large-and-highly-stiff-ode-system/116727 "2024-07-13T12:41:42Z")

</div>

I am solving a system of linear differential equations (of type \[dx/dt\]= \[Jacobian\]\*\[ x \] ) with about 1 million simultaneous differential equations. The system is highly stiff and the jacobian is sparse and banded. I us…

---

## [Julia -\> C function (Create thead) -\> Julia CUDA kernel issue](https://discourse.julialang.org/t/julia-c-function-create-thead-julia-cuda-kernel-issue/116965)

<div class="topic-metadata">

**Author:** [@miniskar](https://discourse.julialang.org/u/miniskar)\
**Replies:** 1\
**Last updated:** [July 12, 2024, 12:26pm UTC](https://discourse.julialang.org/t/julia-c-function-create-thead-julia-cuda-kernel-issue/116965 "2024-07-12T12:26:32Z")

</div>

I am facing a weird problem in our application. We have a julia function calling a C function, which is creating a pthread and calling Julia CUDA kernel. I have created a small example to illustrate and reproduce the pro…

---

## [Threaded double loop](https://discourse.julialang.org/t/threaded-double-loop/116144)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 10\
**Last updated:** [July 11, 2024, 1:15pm UTC](https://discourse.julialang.org/t/threaded-double-loop/116144 "2024-07-11T13:15:14Z")

</div>

I am trying to write threaded code for the following calculation: given an opaque object x, and indices i, calculate y\_i = g(x, i), given each y\_i and indices j, calculate {z\_i}\_j = h(x, y\_i, j), reduce all the z…

---

## [Segmentation Fault with FFTW plans and multi-threading](https://discourse.julialang.org/t/segmentation-fault-with-fftw-plans-and-multi-threading/116777)

<div class="topic-metadata">

**Author:** [@leonardromano](https://discourse.julialang.org/u/leonardromano)\
**Replies:** 1\
**Last updated:** [July 8, 2024, 3:47pm UTC](https://discourse.julialang.org/t/segmentation-fault-with-fftw-plans-and-multi-threading/116777 "2024-07-08T15:47:14Z")

</div>

I am trying to optimize a routine that performs FFTs on timeseries of various 3D boxes with fixed but different sizes (typically 256 - 512 cells per dimension). For each box I thus had in mind to plan an FFT using FFTWs…

---

## [Is it possible to run Julia / Turing sampling with multicores without using the command line or the env file](https://discourse.julialang.org/t/is-it-possible-to-run-julia-turing-sampling-with-multicores-without-using-the-command-line-or-the-env-file/116720)

<div class="topic-metadata">

**Author:** [@DominiqueMakowski](https://discourse.julialang.org/u/DominiqueMakowski)\
**Replies:** 1\
**Last updated:** [July 8, 2024, 2:01am UTC](https://discourse.julialang.org/t/is-it-possible-to-run-julia-turing-sampling-with-multicores-without-using-the-command-line-or-the-env-file/116720 "2024-07-08T02:01:56Z")

</div>

Might be a silly question, but I am wondering if it is possible to run MCMC sampling from a Turing model using the multiple cores of the CPU without having to start Julia in a particular way / setting environment variabl…

---

## [Does \`@atomic\` syntax support non-primitive-type fields in a \`mutable struct\`?](https://discourse.julialang.org/t/does-atomic-syntax-support-non-primitive-type-fields-in-a-mutable-struct/116703)

<div class="topic-metadata">

**Author:** [@frankwswang](https://discourse.julialang.org/u/frankwswang)\
**Replies:** 2\
**Last updated:** [July 6, 2024, 7:30pm UTC](https://discourse.julialang.org/t/does-atomic-syntax-support-non-primitive-type-fields-in-a-mutable-struct/116703 "2024-07-06T19:30:30Z")

</div>

I was reading the documentation on per-field atomics, and it seems that @atomic can be put in front of any type of field (unlike Base.Threads.Atomic) as long as the struct is mutable. I also tested it with the following …

---

## [Julia to C function to Julia function call](https://discourse.julialang.org/t/julia-to-c-function-to-julia-function-call/115997)

<div class="topic-metadata">

**Author:** [@miniskar](https://discourse.julialang.org/u/miniskar)\
**Replies:** 5\
**Last updated:** [July 1, 2024, 11:32am UTC](https://discourse.julialang.org/t/julia-to-c-function-to-julia-function-call/115997 "2024-07-01T11:32:08Z")

</div>

I am trying having a runtime framework implemented in C++ launguage. Julia application calls this framework and this framework will call some other Julia function. I am facing some issue when the framework calls Julia fu…

---

## [Distributed computing or Multi-threading on Optimization](https://discourse.julialang.org/t/distributed-computing-or-multi-threading-on-optimization/116147)

<div class="topic-metadata">

**Author:** [@benjamin.nunez](https://discourse.julialang.org/u/benjamin.nunez)\
**Replies:** 1\
**Last updated:** [June 24, 2024, 7:05pm UTC](https://discourse.julialang.org/t/distributed-computing-or-multi-threading-on-optimization/116147 "2024-06-24T19:05:21Z")

</div>

Hello! I am currently working on an algorithm to solve stochastic optimization problems by decomposing them into scenarios (very similar to Progressive Hedging). I am not very knowledgeable in the area of task parallel…

[Previous page](https://discourse.julialang.org/tag/multithreading/100.md?match_all_tags=true&page=2&tags%5B%5D=multithreading)

[Next page](https://discourse.julialang.org/tag/multithreading/100.md?match_all_tags=true&page=4&tags%5B%5D=multithreading)
