|
have you done any non-CUDA multi-threading ?
|
|
|
|
|
yes, I have worked extensively with threading and even use to debug parallel threading architecture on Java UI's what took advantage of multiple processors on super spark servers. threading it no problem. I fully understand the concept, however on a GPU it is a bit different, the developer is forced to use the parallel design-constructs of the GPU, and to get the correct memory bandwidth ratios of processing data-parallelism you are forced to design the code so it takes advantage of the hardware, simple loops with nested loops and control flow logic seriously complicates the process.
this constraint is a difficult concept to understand, grasp, and implement. Just for matrix multiplication you have to think in three dimensions just to get a global memory ratio of 1.0, which barely makes use of the full processing power of the GPu, stream processors are also used hand have limitations on the number of current threads that can execute a 'block' a quadrant of GPU cores sharing global memory.
so to make full use of a G80 GPU the code has to be written in such a fashion (a dependency caused by manufacturing costs and lithography techniques) to process the three dimensions of the multiplication in what I consider a strange and cumbersome way, where each matrix (G1, G1, R1) are further divided to make use if faster but smaller shared memory which cuts the bandwidth in half. so now you are thinking in six dimensions and also have to consider how many threads a stream processor can handle for the process just to achieve 748Mb band-with and full GPU utilization.
it is algorithms like I have no experience designing.
but I have a strong desire to learn, even if the approach seems unintuitive and abstract!
------Modification-------
I wrote the response on the bus, couldn't hardly see the screen I was typing into, I think I am going to put a sugestion in the site sugestions box to make it wasier to respond to threads using a mobile device, I use to be a mobile device programmer. I could do it in a peice of cake.
-------------------------
~TheArch
|
|
|
|
|
ah...
unfortunately, this sounds like it's well beyond anything i've done.
good luck !
|
|
|
|
|
Hi,
So I am coding CUDA stuff since a year now.
I started to program the examples that they showed in their documentation.
I found that really helpful. I also liked this article :
[^]
Actually, I would not recommend any of the books, because the documentation from Nvidia is enough, but maybe it helps you.
Have fun, cheers
You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)
|
|
|
|
|
I have a mapping program. Upon the map are laid polygons that represent rooms in a building.
The program must tell which room a tracked asset is in, AND if the asset is not within any of the rooms, it must tell which is the closest room to its location.
I have already implemented the code that can tell which polygon contains a given point, BUT I can't see how to figure out the closest polygon to a given point if the point is not within any polygon.
In other words, if the point is not within any of the polygons, how do I figure out which polygon it is closest to?
|
|
|
|
|
Do you mean closest to the walls or closest to the doors?
Because if it is about tracking an asset, it should be closest to the door.
This could be one approach:
You could create a virtual circle around the point and find all polygon falling on it. if there are none, increase the size of circle. eg a circle of 10, 20,40,80 and so on. when you do encounter one polygon, thats your winner. In case you get more than one, reduce the circle slowly till you get a single.
|
|
|
|
|
Thanks! I think this is the plan I will choose, except instead of a circle, I may use a rectangle to make the math easier.
|
|
|
|
|
Hi,
you could replace each polygon by a single point, representing either the room's center, or its door(s); then search for the nearest point by calculating distance squared, and taking the minimum value of those.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
I will consider this as a backup plan in case I can't make the other one work.
Thanks for your input!
|
|
|
|
|
|
've seen that before.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
I will definitely look into that. Thanks!
|
|
|
|
|
What if you iterate over every line segment, and determine argmin(d(ThePoint,line-seg)), the polygon containing the line-seg is closest to the point.
Would that be too slow? The formula for d(point, line-segment) is not pretty and there might be ton of line segments (right? about how many segments do you expect?)modified on Friday, February 19, 2010 1:00 PM
|
|
|
|
|
Actually I came across the formula for figuring the point on a line that is closest to a given point.
It's not too bad, but I don't yet have a sense of how fast it would be with the average layout containing 50+ polygons, and each polygon containing at least 4 and likely many more line segments.
|
|
|
|
|
50 times 4 doesn't sound to bad yet, but "many more" is really a lot... Could it be worth a try? It does seem "cleaner" to me than expanding a circle until it hits something
|
|
|
|
|
I think you're right. I would like to try it, especially since the math would be simpler than the other solution.
|
|
|
|
|
The problem with circle approach is that you need to calculate the radius to every point to determine if it is within the circle, determining the radius of the next circle and iterating through it again.
This is worse than determining the distance to each point once and taking the one with the smallest radial distance.
If you need to do this in real time, you want to take an approach where you break the world up into 2 kinds of polygons, 'rooms', which are obvious, or 'not rooms', where the border between 'not room' polygons is the line equidistant between 2 rooms.
This way, every polygon is a room, or the area closest to a particular room.
If you know what polygon you are in, you either know the room you are in, or the room you are closest to.
You use the same code to determine which polygon you are in, either way.
The only special code is breaking up the world ahead of time.
RichardOpacity, the new Transparency.
|
|
|
|
|
Richard,
This is a lot like the Star mapping question from several years back. Sort the polygons by lowest Y value and lowest X value for a point in the polygon, but save the entries 4 times, once for each vertex. Divide the building into a 10x10 grid and determine which square contains the point. Then scan the list of polygons for one that has the XY point in the same square or in one of the adjacent squares. There may be several. Determine the perpendicular distance from the point to either line connecting with the closest point ot the distance to the point. Chose the polygon with the shortest distance. Remember, do not take the square root of the sum of the squares for comparisons, but just compare the sum of the squares.
Dave.
|
|
|
|
|
Richard,
I hate to double post, but there is a simplification. Sort the points for each polygon manually for lowest Y and lowest X, draw a line between lowest x lowest X and highest y highest Y, then draw a line between the other two points. Calculate the intersection of the lines to form the center point. Put the polygon points and center point into an array as a structure and repeat for all polygons. Sort on the center point Y and X values. Now just look for the closest center to the point. You do not need to divide the building into squares, just look for the closest center to the point. If the list is short enough, don't sort, just scan for the smallest distance between the center and the point (smallest sum of squares).
Dave.
|
|
|
|
|
Using this[^](PDF warning! googledocs version here[^]) paper as reference, I have so far (after a couple of days of being annoyed and rewriting the code from scratch every few hours) only been able to get half of it right.
The problem is mainly that this article is written in weird mathematical language with single-letter names all over the place, with the upper case S being an other variable than the lower case s. Add to that all the "obvious" steps for which the implementation is left as an exercise for the reader. The code in the appendix isn't any better, and may even be worse because it uses variables named n02 etc.
I've searched for implementations, but the best I found was a highly obfuscated Java implementation which passed values to methods by putting them in fields of the class rather than as arguments.
Could anyone please explain step 3 of this algorithm? (or more than that, I don't mind, but step 3 is the only part I don't understand)
|
|
|
|
|
Hi Harold,
I'm not familiar with the matter, however I glanced through the PDF; looks like a decent but though article indeed. The source code at the end doesn't seem that awful; why not just feed it to the C# compiler and fix the remarks it will throw at you?
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
That's possible, but I really prefer understanding it first - and also, all that pointer magic doesn't make me too happy (it can't easily be removed, either, because it's used to change the start of an array several times)
|
|
|
|
|
harold aptroot wrote: I really prefer understanding it first
for a big article and a small snippet I'm often willing to reverse the order, so run it first, observe and understand it later.
harold aptroot wrote: pointer magic ... can't easily be removed
I noticed that; however, adding start parameters solves that, like so:
public bool sleq(int[] s1, int[] s2, int start1, int start2) {
for(int i=0; ; i++) {
if (s1[start1+i]<s2[start2+i]) return true;
if (s1[start1+i]>s2[start2+i]) return false;
}
}
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Ok well it can be removed of course, it just takes.. effort.
Are you sure you couldn't just explain step 3 quickly?
Otherwise I guess I'll work on converting that code..
|
|
|
|
|
harold aptroot wrote: Are you sure you couldn't just explain step 3 quickly?
No, not really. I am sure I could convert the code faster than you could make me understand it though. Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|