# How to set parallel parameters very easily， use other packages

**URL:** <https://discourse.julialang.org/t/how-to-set-parallel-parameters-very-easily-use-other-packages/97567>\
**Category:** General Usage\
**Tags:** package, distributed\
**Created:** [April 17, 2023, 9:09am UTC](https://discourse.julialang.org/t/how-to-set-parallel-parameters-very-easily-use-other-packages/97567 "2023-04-17T09:09:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![13299118606](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/13299118606/32/49095_2.png) [@13299118606](https://discourse.julialang.org/u/13299118606)\
**Post date:** [April 17, 2023, 9:09am UTC](https://discourse.julialang.org/t/how-to-set-parallel-parameters-very-easily-use-other-packages/97567/1 "2023-04-17T09:09:45Z")

</div>

How to set parallel parameters very easily, where the function needs to use other packages. Using LinearAlgebra as an example, I want to set an isparfor parameter and package it into a function:  
At present, if you want to use parallelism, you must set it in the Main main function file like this

```julia
if isparfor==1 #1 parallel, 0 not parallel
	Preformatted textusing Distributed
 	addprocs(4)
  	@everywhere using LinearAlgebra
  	fun1
else
	using Linear Algebra
	fun1
end

```

I want to make this into a function, but the using must be at the first level, but other parallel processes must use other packages. Is there a good way to pack the parallel parameter using package into a function or module,  
so that the call only needs  
**funparfor(1) enables parallel**

**funparfor(0) does not enable parallel!**  
The desired function is similar to the following

```julia
using Distributed
function funparfor(isparfor)
if isparfor ==0
  	addprocs(4)
 	@everywhere using LinearAlgebra
  	fun1
else
     using Linear Algebra
     fun1
end

```
