Bash style history in Power Shell

how bizarre

For those of us coming from the linux world, Power shell has a tempting assortment of linux like commands, however every so often it still feels like you are trapped in bizaro land and the commands don’t quite match up. Today was one of those days.

Bash has a great history command that will list all (or most) of your recent shell commands. In PoSH history (er ok it is Get-History under the hood) only gives you for your current session.

Fear not, there is a one-liner that will get you the history that you need and love:

Get-Content (Get-PSReadlineOption).HistorySavePath | tail -n 20

(this will get the text from your power shell history file and print the last 20 commands)

OpenMP Scheduling (default is default for a reason)

scheduling is easy, right?

This post was inspired by an interesting post from a friend and colleague about dynamic scheduling in OpenMP as well as a question that I was asked in an interview around a coding problem. (My solution as well as the interview question is at my gitlab page)

In Kyle’s problem he is implementing a naïve prime number generator where each loop takes an increasing amount of time. As he discovers, the dynamic scheduler makes the most sense in his case as each thread picks up a chunk of work (by default the chunks are sized 1). This sounds great but as with all things there is no such thing as a free lunch. Dynamic scheduling has a performance cost in added overhead.

In my case, I am leveraging the GNUMP library to run a test that will check to see if a number is very likely to be prime. Since the test takes a constant amount of time the default scheduler for Open MP ends up being the best as it does not have the overhead of the added book keeping that dynamic has. By default the static scheduler chunks the work into loop_count/number_of_threads chunks and then divides the work evenly between all of the threads.

Of note and worth further investigation is the auto scheduler where the developer yields control to the compiler to make the best scheduling decision. However this apparently requires using a better implementation than g++ and the default libgomp as it is hardcoded to take the static scheduler.

Additional References: