# Multi-threaded batch job on SGE

**URL:** <https://discourse.julialang.org/t/multi-threaded-batch-job-on-sge/85777>\
**Category:** New to Julia\
**Tags:** question, multithreading\
**Created:** [August 15, 2022, 1:51pm UTC](https://discourse.julialang.org/t/multi-threaded-batch-job-on-sge/85777 "2022-08-15T13:51:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dhryniuk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dhryniuk/32/28885_2.png) [@dhryniuk](https://discourse.julialang.org/u/dhryniuk)\
**Post date:** [August 15, 2022, 1:51pm UTC](https://discourse.julialang.org/t/multi-threaded-batch-job-on-sge/85777/1 "2022-08-15T13:51:51Z")

</div>

I would like to run a Julia script which makes use of multi-threading on a Sun Grid Engine cluster. I can reserve 2 cores, load Julia, and run the script with 4 threads by submitting

```julia
#!/bin/csh
#$ -pe smp 2
module load julia/1.7.1
julia --threads 4 xyz.jl > ...

```

The script runs correctly except that it takes it about 4 times as long to finish the calculation as using just a single thread, so it looks like Julia doesn’t actually distribute the treads over all of the available cores and so doesn’t run them in parallel. I don’t have this problem when running the script on my PC instead of on the cluster. What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Rasmus\_Hoier](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rasmus_hoier/32/24036_2.png) [@Rasmus\_Hoier](https://discourse.julialang.org/u/Rasmus_Hoier)\
**Post date:** [August 16, 2022, 7:56am UTC](https://discourse.julialang.org/t/multi-threaded-batch-job-on-sge/85777/2 "2022-08-16T07:56:24Z")

</div>

Hi, I think it usually is faster to limit the number of threads to the number of physical cores. By 2 cores do you mean physical or logical cores?

If you are working with 2 logical cores on a single physical processor, then I think the slowdown you observe makes sense.
