Re: Is this use of Nim locks correct?

2017-10-26 Thread mratsim
To be honest I don't know I never used volatile, but if your use case was multi-threading, I would follow Intel advice and find another portable way to sync memory/have memory fences.

Re: Send data structures between threads?

2017-10-26 Thread mratsim
In case it helps, my shared memory, Garbage Collected, data structure (and 64 byte aligned) is this: const FORCE_ALIGN = 64 type BlasBufferArray[T] = object dataRef: ref[ptr T] data*: ptr UncheckedArray[T] len*: int proc

Re: Send data structures between threads?

2017-10-26 Thread monster
Hi @peheje. I'm really not the expert on this, as I'm a newbie at Nim myself, but I'm _pretty sure_ I read that everything you send over a Channel is _copied_. The refs are local to the thread, so if you send data with ref, both the data, and what is pointed by refs, gets cloned "magically".

Re: Is this use of Nim locks correct?

2017-10-26 Thread monster
@mratsim Does that mean I shouldn't use [https://github.com/nim-lang/Nim/blob/master/lib/pure/volatile.nim](https://github.com/nim-lang/Nim/blob/master/lib/pure/volatile.nim) ? @mikra How would you "share" something between threads without globals? Globals are generally considered "evil", but

Re: Send data structures between threads?

2017-10-26 Thread peheje
Anything new on this? I'm trying to implement a simple genetic algorithm where each thread shall have access to a shared seq[seq[int]], its easy to partition the data into chunks so the threads know which items to work on, but Nim seems IMPLICITLY copy the data, whether I try channels, parallel

Re: Is this use of Nim locks correct?

2017-10-26 Thread mikra
@Monster sorry for my late response; I see rayman22201 already answered your question. I think it's a good habit to declare the globals immediately. My code was just to experiment with Locks and Conditions; I personally avoid globals. @rayman22201 It was fun-stuff I have to work now with

Re: How to get real time of parallel code

2017-10-26 Thread jzakiya
The Unix `time` command [https://en.wikipedia.org/wiki/Time_%28Unix%29](https://en.wikipedia.org/wiki/Time_%28Unix%29) [https://www.lifewire.com/command-return-time-command-4054237](https://www.lifewire.com/command-return-time-command-4054237) returns three (3) variants: `real`, `usr`, `sys`.

Re: Wrapping cpp type with integer parameters

2017-10-26 Thread Araq
Can't think of a solution except patching the compiler.

Re: How do you keep your motivation on your open-source projects

2017-10-26 Thread Araq
Slightly off topic, but when I run into compiler limitations/bugs all the time, I fix the compiler. Some random remarks about keeping motivation up: * Our brains evolved in order to control our bodies. A brain is not designed for heavy thought based processes, these get exhausting quickly.

Re: How to get real time of parallel code

2017-10-26 Thread jzakiya
Yes, that did it. This is a good use case example to distinguish in `time` docs between the use of `cpuTime()` and `epochTime()`. The given example for `cpuTime()` assumes single threaded use and not the effect of multi processor/threads use.

How do you keep your motivation on your open-source projects

2017-10-26 Thread mratsim
I've been working on Arraymancer for 6 months now with ups and downs. This is my first big project (and actual the first time I'm developing "for real") and I would like to know how do you keep your energy for the long run. In my case, I seem to alternate between various modes: * "The

Re: using if expressions

2017-10-26 Thread Arrrrrrrrr
And another: let channels = 7 let format = if channels == 1: 1 elif channels == 3: 2 elif channels == 4: 3 else: (block: echo "Texture Format Unknown, assuming RGB" 4 ) echo format

Re: Cannot get name of type using typedesc

2017-10-26 Thread Arrrrrrrrr
I think that the run button should stay hidden by default in top right corner until your mouse hovers the code block, because most code posted right now were not submitted to be run and is wasting three lines of text for no reason. Ideally the output area would appear once the output from run

Re: Is this use of Nim locks correct?

2017-10-26 Thread mratsim
@Rayman2220 @wizzardx I had shared memory issue in OpenMP at one point in Arraymancer (solved since then). I just checked volatile and from this [Intel post](https://software.intel.com/en-us/blogs/2007/11/30/volatile-almost-useless-for-multi-threaded-programming), it says that there is no

Re: How to get real time of parallel code

2017-10-26 Thread Lando
Try _epochTime()_.

Re: Is this use of Nim locks correct?

2017-10-26 Thread wizzardx
Ah, also a reminder - try nimgrep in addition to regular grep: [https://nim-lang.org/docs/nimgrep.html](https://nim-lang.org/docs/nimgrep.html) Nim's style insensitivity means that you may miss a few useful things if you just use the regular grep.

Re: testing private methods in external module

2017-10-26 Thread sflennik
Thank you for the responses and code, I'm learning a lot about the macro system. Nice idea to use a pragma. Testing the macro I was getting the compiler error: t.nim(11, 20) Error: invalid indentation I used treeRepr in the macro to debug the problem. It turned out I was

Re: testing private methods in external module

2017-10-26 Thread mratsim
Argh indeed.

Re: Is this use of Nim locks correct?

2017-10-26 Thread rayman22201
> so I'm not generally a programming newbie. I don't think anyone meant to imply that you were a newbie! I apologize if I came off condescending. I specialized in concurrency and multi-threading at university, and you would be surprised at how many many people would show me code in their hot

Re: Nim T-shirts and mugs now available

2017-10-26 Thread jester
Done and done

Nim T-shirts and mugs now available

2017-10-26 Thread dom96
Hope you guys like these. First iteration so definitely room for improvement. Let me know your thoughts [https://teespring.com/nimlang1](https://teespring.com/nimlang1) [https://teespring.com/nimlang2](https://teespring.com/nimlang2)

Re: testing private methods in external module

2017-10-26 Thread Araq
@mratsim `export` is about forwarding an imported symbol, it cannot be used to export a local symbol.