Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Julia: Is there a short syntax for making all functions available @everywhere

Suppose I have a smallish number of functions that I have defined in a cell in ijulia (I'm using JuliaBox).

I'd like to be able to call the main function in parallel n times. The annoyance is that the main makes calls to the dozen or so helper functions I have defined.

Do I have to put @everywhere in front of all of these helper functions, or is there some shorter syntax that would work?

e.g. is there a command that would share all functions defined at the global level to all of the processes? Or is there a way to share a list of functions (rather than putting @everywhere in the function declaration).

like image 289
Rob Donnelly Avatar asked Mar 20 '15 00:03

Rob Donnelly


People also ask

What is :: In Julia?

A return type can be specified in the function declaration using the :: operator. This converts the return value to the specified type. This function will always return an Int8 regardless of the types of x and y .

What is the type of a function in Julia?

Method Tables Every function in Julia is a generic function. A generic function is conceptually a single function, but consists of many definitions, or methods. The methods of a generic function are stored in a method table. Method tables (type MethodTable ) are associated with TypeName s.

What does the splat operator do Julia?

The "splat" operator, ... , represents a sequence of arguments. ... can be used in function definitions, to indicate that the function accepts an arbitrary number of arguments. ... can also be used to apply a function to a sequence of arguments.


1 Answers

When I want to do this in the notebook I usually wrap the entire cell containing helper functions in @everywhere like this:

@everywhere begin

... put functions we want to share across all processes here

end
like image 180
spencerlyon2 Avatar answered Oct 01 '22 00:10

spencerlyon2