Can someone tell me when exactly the completion of special arguments should pop-up? Example: TextCell[string, style] should automatically suggest the different style types. Let's say I start typing TextCell["blub", does the pop-up appear? Because on Linux it doesn't and in general this works unpredictable.
Even after having restarted the kernel I can't seem to execute Query or Dataset operations. Not even those in the docs. Instead I get things like: GeneralUtilities`Checked[ Map[GeneralUtilities`Slice["b"]] /* StringJoin][{<|"a" -> 1, "b" -> "x", "c" -> {1}|>, <|"a" -> 2, "b" -> "y", "c" -> {2, 3}|>...
Any ideas?
Well, now it works but I'm still interested in ideas because this intermittency is not new.
Am I the only dumbass who struggles with procedural programming in MMA? I'm working the procedural programming chapter in an MMA book and I just can't seem to begin how to solve a problem procedurally. Even when I do, I lose track of my iterators all the time and my evaluation hangs so often, probably due to some infinite recursion.
This is so frustrating. I breezed through the functional programming chapter but procedural programming just seems very intimidating to me. It's kinda makes me dislike MMA a little.
The planet Mars comes into opposition, the point closest to the Earth, about every 780 days, or a bit over two years. The Martial opposition this year was on April 9. This past May, on a rare clear, warm night, I attempted to capture some images of the red planet. Unfortunately once I had my [...]
@halirutan The term "sub-kernels" always confuses me....in your thread..you meant multiple kernels Mathematica launches when you run compiled code with parallelization
@brama There is a difference between the main kernel you are using all the time and the sub-kernel which is used as worker slave by the main kernel.
So when you start up Mathematica and type 1+1 this is evaluated by the main-kernel. When you do a ParallelTable then then main-kernel evaluates the call and gives all the work to the sub-kernels.
@halirutan But in the context of Linux clusters, I have noticed that Mathematica only works on one processor.(.as you showed in your thread) so one needs to explicitly activate them SystemOptions and ParallelThreads
@brama yes, exactly this is a different kind of parallelization.
@brama When you define a function as Listable and use all the parallelization options etc and compile it, then this is fundamentally different from using ParallelTable.
In earlier Mathematica versions you always could compile down simple functions. This was always restricted to numerical code which means you can compiled functions that take numbers or tensors of numbers and output numbers or tensors of numbers. You couldn't do for instance Expand[(a+b)^5].
(Actually, you can do this in compiled code but then the compiled code will call-back to the mathematica kernel to get an answer for this task)
Let us concentrate on the compiled functions that are purely numerical and can be compiled down completely.
@brama So let's say we have a compiled simple function which doesn't need the sophisticated mathematica kernel to calculate its result but it can run on its own. (This is not entirely true because if you don't compile to C then your compiled function is run be a virtual machine similar to java running byte code. This is called now the Wolfram Virtual Machine. Let's ignore that)
Now, having such a function fc which takes numerical arguments and creates numerical output, you could theoretically call it more than one time in parallel because it doesn't depend on the kernel which you have only one.
Now, you need to know that there are several "threading libraries" like pthread which let's you call subroutines independent from each another.
@brama OpenMP or even CUDA use the same paradigm which is called Single Program Multiple Data (I always knew it as SIMD which stands for instruction, but this seems to fit better).
@brama Now, let's assume you want to calculated your function fc for a list of numbers (or arguments). Then you could use a for-loop to go through every number of your list and call fc or you divide your list into several sublists and calculate them in parallel.
@brama This is exactly what happens when you define your function listable and parallel. Your mathematica kernel just runs many fc functions in parallel. Have you noticed that we don't need more than one Mathematica kernel because your function fc is somewhat independent of a kernel and can run on its own?
@halirutan But I have just noticed that when I run the following code on my laptop, it starts a new sub-kernel (I can see it in Task Manager - details).
Now, we have a completely different situation. Let' s assume your function or program is not as simple as `fc` and needs more than just basic numerical operations. Assume you need to make complex analytic simplifications which can only be done by the Mathematica kernel itself.
one thing before we go too far..does it influence how parallelization happens with CompilationTarget "C"? My guess is it will not...but will you please confirm!!
Since you really need a MathKernel for your task, there is no other option than starting other MathKernels and distribute your work. Exactly for this reason Roman Maeder (afaik) started to write the Parallel Computing Tools.
@brama As you might know the front end is just for input/output and some fancy stuff but the calculations you evaluated are sent down to the MathKernel and the result is read back. Now the idea was to give your main-kernel a bunch of slaves which it can use to distributes its work. To make this accessible to the user, a set of new functions aka the ParallelTable, ParallelDo etc were written. Clear so far?
@brama Now the approach is the following: You simply copy the snip of Mathematica code which is required to calculate your stuff to each sub-kernel and initialize all the values and variables it needs and then a ParallelTable will divide your iteration into sub-iterations and each sub-kernel will run a small part of the whole Table. At the end, the result is sent back to the main-kernel and you put it together to your final list. Most of the stuff (copying code, initializing)
is done automatically nowadays.
@brama Even this is done automatically.
@brama Try this:
ParallelTable[i, {i, 100}]
LaunchKernels[]
and note the warning:
> LaunchKernels::nodef : "Some subkernels are already running. Not launching default kernels again."
As I said, most of the stuff happens under the hood.
Yes....So in case of compiled function the the main kernel runs parallel computations and in the case of ParallelTable, many slaves are created and work is shared!!
@brama You can watch at it completely independent: For compiled functions you need to ensure that you don't have a MainEvaluate call in your compiled code. Then Mathematica can run your fc's in parallel. For the many kernels approach you need to weight the pro's and the con's of parallelizing your code.
now tell me this, If I have a compiled function, all it needs is one main kernel and in that case, it does not matter if I have a 10 core machine or a 1 core machine, if the processor speeds are same... right!!!
multicore machine only gives me ability to create more slaves...no special benefit for compiled functions that only need one core!!
@brama Let's say you want to calculate x+x for a numerical x. If you have 1 CPU, then you can calculate only one computation at a time. If you have 10 CPU's then you can calculate 10 x+x at the same time. Ergo, it needs only 1/10th of the time.
@brama Yes. Your main Mathematica kernel can run fc[{1,2,3,4,5...}] and it does it by running the calculations for fc[1], fc[2], etc in many thread in parallel.
@brama I mean, look: you have 4 CPU's. Do you really think currently on your machine there are only 4 processes? Virus scan, browser, porn, Mathematica, porn, email and maybe another porn window.
@brama Look, I have a quad-core which is 1 Intel i7 CPU (the physical chip I plugged onto the mainboard) which has 4 independent Cores. Each core has 2 thread = 8 "cpu"s you see here
but compiled function does not need multiple slave kernels. So I still need to define parallelThreads? You defined threads for using sub-kernels/slaves
in this case, does every processor work as a core? so more the merrier for performance of a simple compiled function?
@brama It is really just a setting. When Mathematica calls your fc for a list, Mathematica decides how many threads to start and for this it looks at this option. You can easily test this: