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.
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
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".
@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
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
@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
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`.
Can't think of a solution except patching the compiler.
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.
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.
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
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
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
@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
Try _epochTime()_.
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.
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
Argh indeed.
> 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
Done and done
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)
@mratsim `export` is about forwarding an imported symbol, it cannot be used to
export a local symbol.
22 matches
Mail list logo