Re: "Cannot open file: unsigned" error with nim 2.0

2019-06-07 Thread jackmott
Got everything updated and fixed up thanks everyone. I updated my opengl wrapper and learnopengl tutorial port project: [https://github.com/jackmott/easygl](https://github.com/jackmott/easygl)

Re: "Cannot open file: unsigned" error with nim 2.0

2019-06-07 Thread jackmott
great thank you!

"Cannot open file: unsigned" error with nim 2.0

2019-06-07 Thread jackmott
I went to check if my opengl library would still work with 2.0, when I try to build I get: "/home/jmott/.nimble/pkgs/sdl2-1.1/sdl2.nim(3, 8) Error: cannot open file: unsigned" any ideas?

Re: nimble question

2018-02-13 Thread jackmott
thank you, that is handy

Re: shorthand for literal type annotations?

2018-02-13 Thread jackmott
yes! that is it, thanks!

Re: nimble question

2018-02-13 Thread jackmott
what is the distinction between using nimble install, and nimble develop?

shorthand for literal type annotations?

2018-02-13 Thread jackmott
I have a vague memory of someone tweeting me a way to avoid having to put a type annotation on every field in an array like so: var gradZ = [ 0'f32, 0'f32, 0'f32, 0'f32, 1'f32, 1'f32,-1'f32,-1'f32, 1'f32, 1'f32,-1'f32,-1'f32] But I can't remember,

nimble question

2018-02-13 Thread jackmott
I am familiar with how to use 'requires' to pull in a library that is in package manager. What if I have my own library that is on my filesystem, and I'm starting a new project and I want to use it, how do I use my nimble file to point at it?

Re: nimble question

2018-02-13 Thread jackmott
I think I have figured it out: use 'nimble install' on the library then you can just refer to it by name with 'requires'

Re: ASM on Windows basically dead?

2018-01-02 Thread jackmott
can you implement the same with intrinsics? That is generally the recommendation from Microsoft now.

Any tips on how I might go about narrowing down the cause of this OSX specific error?

2018-01-02 Thread jackmott
I have a SIMD project that does CPU feature detection and uses macros to provide a nice SIMD api, and the sample app works for me on Windows, and Linux, but a user has reported an issue on OSX: [https://github.com/jackmott/nim_simd/issues/4](https://github.com/jackmott/nim_simd/issues/4) I

Re: Would love input / help with SIMD library proof of concept

2017-12-13 Thread jackmott
AVX2 cpu, forgot that I7 doesn't really narrow it down anymore! The code is ported from a friends C++ library, which should be good but I could definitely have introduced mistakes with some of the obscure C bindings.

Re: Would love input / help with SIMD library proof of concept

2017-12-12 Thread jackmott
runtime detection is now in, tested only on my i7 in linux so far.

Re: Would love input / help with SIMD library proof of concept

2017-12-12 Thread jackmott
Ok I've fixed the .gitignore / bin directory setup

Re: Would love input / help with SIMD library proof of concept

2017-12-12 Thread jackmott
> I don't know much about SIMD, it looks like your approach is to figure out > how to take nim code and SIMDify it? No not quite. You will write explicit SIMD instructions, but it will automatically transform them to use the best possible option given runtime detection. So you can write a loop

Re: Would love input / help with SIMD library proof of concept

2017-12-12 Thread jackmott
Yes runtime detection is the plan, the prompt is just a placeholder, so that I know the decision is happening at runtime. Thanks on the.gitignore, its ignoring exe but i am in linux!

Re: Possible to have a template inside of another template?

2017-12-12 Thread jackmott
I don't want the for loop to run at compile time, so that is ok. I was able to print out the template expansion at compile time and it looks like when I added the inner template, the body gets a single quote character appended to it.

Possible to have a template inside of another template?

2017-12-12 Thread jackmott
I have a template like so: template SIMD(width:untyped,body:untyped) = and I'd like to make a template like this; template simdFor[T](a:openarray[T], body:untyped) = for i in countup(0,a.len,width): #etc where the second template depends on the width variable from the

Re: Installation of some packages don't work with Nimble

2017-12-12 Thread jackmott
nim maintainers should really iterate through all the broken nimble packages and fix or remove them. This kind of thing can be very frustrating to people exploring a new language, and cause them to leave. note: I have tried to be the change I want to see in the world here, when I came across

Would love input / help with SIMD library proof of concept

2017-12-12 Thread jackmott
Details are in the readme. If anyone is interested in this and would like to provide input or help out please let me know. [https://github.com/jackmott/nim_simd](https://github.com/jackmott/nim_simd)/

Re: learnopengl.com ported to nim, with a type safe opengl wrapper

2017-11-30 Thread jackmott
no webGL, but no reason you couldn't do something similar.

learnopengl.com ported to nim, with a type safe opengl wrapper

2017-11-29 Thread jackmott
Just wanted to share this: [github link](https://github.com/jackmott/easygl) I may tidy this up and add it to nimble when I have some time.

Re: feedback on macro

2017-11-29 Thread jackmott
This would have to generate all versions of a given statement list at compile time, then execute the correct statement list at run time. So for every block that you use the macro on, there would be N variations of that block in the binary where N is the number of SIMD instructions sets you want

Re: feedback on macro

2017-11-29 Thread jackmott
In cases where there isn't an equivalent function you would have a fallback that does it in non vectorized fashion. So if you used the gather instruction the SSE fallback would just loop over the elements of the simd vector and do them one by one. No doubt you would not be able to write code

Re: feedback on macro

2017-11-29 Thread jackmott
That is an interesting idea, but I suppose it would make it impossible to inline each SIMD call right? There would be a pointer hop each time? That would be no good.

Re: feedback on macro

2017-11-29 Thread jackmott
the idea is to take a statement list, and generate SSE and AVX versions of it at compile time. Then at **runtime** select the proper version to use.

feedback on macro

2017-11-29 Thread jackmott
I'm working on a macro idea to allow a SIMD library where you can write simd code once, and at _runtime_ the correct simd functions will be used based on feature detection of the cpu. I have a simple proof of concept here, this works, but I am unsure if this is the best way to accomplish this:

Re: question about templates / namespaces / modules

2017-11-13 Thread jackmott
yep, looking for a nice runtime solution.

question about templates / namespaces / modules

2017-11-12 Thread jackmott
Here is some pseudocode for what I would like to do: template SIMD(actions:untyped) = if AVX2_Available(): import AVX2 # use the avx2 version of Add/Mul etc. actions else: import SSE# use the sse version of Add/Mul etc. actions

compile time 'asserts'

2017-11-05 Thread jackmott
What would be the idiomatic way to do something like a compile time assert. Say that you had proc foo(bar:int) where you want to restrict bar to values 1,3,5 and 8. I don't think you can use a range here because they are not contiguous. But you could use a when to check at compile time, but

Re: Help with parallelizing a loop

2017-11-03 Thread jackmott
what does the call to sync() do?

Help with parallelizing a loop

2017-11-02 Thread jackmott
I would like some guidance on how to best parallelize this loop. I've played around with the parallel: macro, and using spawn, but haven't gotten a working solution yet. It isn't entirely clear what the best approach should be: for i,face in faces: #face is a path to an image file

question on range types

2017-11-01 Thread jackmott
range types like: type MySubrange = range[0..5] Are they also checked at runtime? Is there a way to disable them being checked at runtime in release mode?

Re: working with pointers from C apis

2017-11-01 Thread jackmott
thank you!

working with pointers from C apis

2017-11-01 Thread jackmott
if I have a C library that returns a pointer to an array like this: proc glMapBuffer(target: GLenum, access: GLenum): pointer If it possible to turn that into a seq without copying the whole contents and allocating a new array? If not can you cast it to an unchecked array

Re: templates with generics question

2017-10-31 Thread jackmott
Thank you, that was indeed the problem, and it makes sense why. As a template it is just being treated as a seq, rather than converted to an openarray as a proc, I suppose.

templates with generics question

2017-10-30 Thread jackmott
The following code works fine as a proc, but not as a template: proc BufferData*[T](target:BufferTarget, data:openarray[T], usage:BufferDataUsage) = glBufferData(target.GLenum,data.len*T.sizeof().GLsizeiptr,data.unsafeAddr,usage.GLenum) Any obvious reason

How to track down missing nimcache/read.o ?

2017-10-28 Thread jackmott
on compile I'm getting this error from gcc: gcc: error: /home/jmott/easygl/examples/model_loading/nimcache/read.o: No such file or directory How can I track down the cause of this? edit: nim -f fixed it.

Re: possible compiler bug with generics?

2017-10-27 Thread jackmott
Ok I figured it out, not sure if bug or user error: proc BufferData in File A which imports opengl, which defines GLenum, used by BufferData File B calls BufferData, but does not import opengl, and I get an error about the type defined in opengl. If I add the opengl import to File B, it

possible compiler bug with generics?

2017-10-27 Thread jackmott
I have this function: proc BufferData*[T](target:BufferTarget, data:openarray[T], usage:BufferDataUsage) {.inline.} = glBufferData(target.GLenum,data.len*T.sizeof().GLsizeiptr,data.unsafeAddr,usage.GLenum) It works fine if I pass it a seq[float32]. If I pass it a

Re: using if expressions

2017-10-25 Thread jackmott
aha! thanks, that is a pretty simple workaround.

Re: using if expressions

2017-10-25 Thread jackmott
Interesting, I wonder if there is any technical reason for this or if if could be enhanced to handle this. Other languages like F# can handle it.

using if expressions

2017-10-25 Thread jackmott
The following is thrown off by the echo. Is there a way to make this work? let format = if channels == 1: TextureInternalFormat.RED elif channels == 3: TextureInternalFormat.RGB

Re: request for feedback - type safe OpenGL wrapper

2017-10-24 Thread jackmott
Krux02- it looks like you are using a struct with a single field instead of a distinct type for things like shader/program ids. What are the pros/cons of that approach? Thanks everyone, some good things to think about.

request for feedback - type safe OpenGL wrapper

2017-10-23 Thread jackmott
your opengl id types. Also the compatible GLenum's for functions are put into enums for easy discovery of what your options are. You can see the [library code here](https://github.com/jackmott/easygl/blob/master/src/easygl/easygl.nim) and some example usage [here](https://github.com/jackmott

Re: object problem - undeclared identifier

2017-10-22 Thread jackmott
ahh, I see. Do people tend to bother with methods then much in nim? Or just leverage the universal call syntax on normal procs? If one was publishing a library, what would people expect? Or what are the pros/cons?

object problem - undeclared identifier

2017-10-22 Thread jackmott
Working on a camera object, using the glm vector/matrix library. The compiler says Front is an undeclared identifier, I can't figure out why: type Camera* = ref object Position*,Front*,Up*,Right*,WorldUp*:Vec3f

Re: procs where you forget to return a value

2017-10-21 Thread jackmott
Thanks Dom, done.

Re: project organization question

2017-10-21 Thread jackmott
I think I found the answers I need here: [https://github.com/nim-lang/nimble#project-structure](https://github.com/nim-lang/nimble#project-structure) In case anyone else finds this with a search, this worked: # Package version = "0.1.0" author= "Jack

Re: Arrays, openarrays, and sequences

2017-10-21 Thread jackmott
awesome, yes this is perfect!

project organization question

2017-10-21 Thread jackmott
>From looking at other nim repos, it looks like the accepted pattern if you are >making a library is to have a src directory under your pojects root directory >with the library code. Then an example directory under the root for example >code. How do you set this up so that you can conveniently

procs where you forget to return a value

2017-10-21 Thread jackmott
I spent about an hour tonight tracking down a weird bug where it turned out I had a proc with a return value, but I forgot to return a value. This compiled fine, but ran wrong. I assume what happened is that the implicit return value was returned, with the default value for the type. Should it

Arrays, openarrays, and sequences

2017-10-21 Thread jackmott
A couple of quick questions: If I have a function that accepts an array as input via an openarray, do the array get copied when you call the function, or no? Is it possible to write a function using generics, or otherwise, that can accept a sequence OR an array, in an efficient manner?

Re: meta programming a nice SIMD library

2017-08-30 Thread jackmott
jxy - I did look at that, and perhaps I am reading the code wrong but I think that one does compile time decision about which SIMD feature set is available, not runtime, is that correct? I'm looking to be able to build one exe, send it to a computer with SSE or AVX or AVX512 and have it use

Re: meta programming a nice SIMD library

2017-08-29 Thread jackmott
While modern C compilers can do some nice auto vectorization, there are many cases where you have to do it by hand. For instance, fractal noise: [https://github.com/jackmott/FastNoise-SIMD/blob/master/FastNoise/FastNoise3d.cpp#L25](https://github.com/jackmott/FastNoise-SIMD/blob/master/FastNoise

meta programming a nice SIMD library

2017-08-29 Thread jackmott
I am learning some Nim, and have a hunch that the metaprogramming features of Nim may allow for a user friendly SIMD library. The primary challenge with SIMD is that various processors support different SIMD features. So to write code that will run as fast as possible on every CPU, you have to

Re: SIMD question

2017-08-29 Thread jackmott
thanks wiffel, that helps

SIMD question

2017-08-17 Thread jackmott
Context: I'm new to Nim, not new to SIMD intrinsics. I'm using this binding library: [https://github.com/bsegovia/x86_simd.nim](https://github.com/bsegovia/x86_simd.nim) I can successfully add two m128i values if I do something like: let a = set1_epi32(1) let b = set1_epi32(1)