Search Results

Search found 32 results on 2 pages for 'maxp'.

Page 1/2 | 1 2  | Next Page >

  • How to synchronize cuda threads when they are in the same loop and we need to synchronize them to ex

    - by Vickey
    Hi all, I have written a code and Now I want to implement this on cuda GPU but I'm new to synchronization so please help me with this, It's little urgent to me. Below I'm presenting the code and I want to that LOOP1 to be executed by all threads (heance I want to this portion to take advantage of cuda and the remaining portion (the portion other from the LOOP1) is to be executed by only a single thread. do{ point_set = master_Q[(*num_mas) - 1].q; List* temp = point_set; List* pa = point_set; if(master_Q[num_mas[0] - 1].max) max_level = (int) (ceilf(il2 * log(master_Q[num_mas[0] - 1].max))); *num_mas = (*num_mas) - 1; while(point_set){ List* insert_ele = temp; while(temp){ insert_ele = temp; if((insert_ele->dist[insert_ele->dist_index-1] <= pow(2, max_level-1)) || (top_level == max_level)){ if(point_set == temp){ point_set = temp->next; pa = temp->next; } else{ pa->next = temp->next; } temp = NULL; List* new_point_set = point_set; float maximum_dist = 0; if(parent->p_index != insert_ele->point_index){ List* tmp = new_point_set; float *b = &(data[(insert_ele->point_index)*point_len]); **LOOP 1:** while(tmp){ float *c = &(data[(tmp->point_index)*point_len]); float sum = 0.; for(int j = 0; j < point_len; j+=2){ float d1 = b[j] - c[j]; float d2 = b[j+1] - c[j+1]; d1 *= d1; d2 *= d2; sum = sum + d1 + d2; } tmp->dist[tmp->dist_index] = sqrt(sum); if(maximum_dist < tmp->dist[tmp->dist_index]) maximum_dist = tmp->dist[tmp->dist_index]; tmp->dist_index = tmp->dist_index+1; tmp = tmp->next; } max_distance = maximum_dist; } while(new_point_set || insert_ele){ List* far, *par, *tmp, *tmp_new; far = NULL; tmp = new_point_set; tmp_new = NULL; float level_dist = pow(2, max_level-1); float maxdist = 0, maxp = 0; while(tmp){ if(tmp->dist[(tmp->dist_index)-1] > level_dist){ if(maxdist < tmp->dist[tmp->dist_index-1]) maxdist = tmp->dist[tmp->dist_index-1]; if(tmp == new_point_set){ new_point_set = tmp->next; par = tmp->next; } else{ par->next = tmp->next; } if(far == NULL){ far = tmp; tmp_new = far; } else{ tmp_new->next = tmp; tmp_new = tmp; } if(parent->p_index != insert_ele->point_index) tmp->dist_index = tmp->dist_index - 1; tmp = tmp->next; tmp_new->next = NULL; } else{ par = tmp; if(maxp < tmp->dist[(tmp->dist_index)-1]) maxp = tmp->dist[(tmp->dist_index)-1]; tmp = tmp->next; } } if(0 == maxp){ tmp = new_point_set; aloc_mem[*tree_index].p_index = insert_ele->point_index; aloc_mem[*tree_index].no_child = 0; aloc_mem[*tree_index].level = max_level--; parent->children_index[parent->no_child++] = *tree_index; parent = &(aloc_mem[*tree_index]); tree_index[0] = tree_index[0]+1; while(tmp){ aloc_mem[*tree_index].p_index = tmp->point_index; aloc_mem[(*tree_index)].no_child = 0; aloc_mem[(*tree_index)].level = master_Q[(*cur_count_Q)-1].level; parent->children_index[parent->no_child] = *tree_index; parent->no_child = parent->no_child + 1; (*tree_index)++; tmp = tmp->next; } cur_count_Q[0] = cur_count_Q[0]-1; new_point_set = NULL; } master_Q[*num_mas].q = far; master_Q[*num_mas].parent = parent; master_Q[*num_mas].valid = true; master_Q[*num_mas].max = maxdist; master_Q[*num_mas].level = max_level; num_mas[0] = num_mas[0]+1; if(0 != maxp){ aloc_mem[*tree_index].p_index = insert_ele->point_index; aloc_mem[*tree_index].no_child = 0; aloc_mem[*tree_index].level = max_level; parent->children_index[parent->no_child++] = *tree_index; parent = &(aloc_mem[*tree_index]); tree_index[0] = tree_index[0]+1; if(maxp){ int new_level = ((int) (ceilf(il2 * log(maxp)))) +1; if (new_level < (max_level-1)) max_level = new_level; else max_level--; } else max_level--; } if( 0 == maxp ) insert_ele = NULL; } } else{ if(NULL == temp->next){ master_Q[*num_mas].q = point_set; master_Q[*num_mas].parent = parent; master_Q[*num_mas].valid = true; master_Q[*num_mas].level = max_level; num_mas[0] = num_mas[0]+1; } pa = temp; temp = temp->next; } } if((*num_mas) > 1){ List *temp2 = master_Q[(*num_mas)-1].q; while(temp2){ List* temp3 = master_Q[(*num_mas)-2].q; master_Q[(*num_mas)-2].q = temp2; if((master_Q[(*num_mas)-1].parent)->p_index != (master_Q[(*num_mas)-2].parent)->p_index){ temp2->dist_index = temp2->dist_index - 1; } temp2 = temp2->next; master_Q[(*num_mas)-2].q->next = temp3; } num_mas[0] = num_mas[0]-1; } point_set = master_Q[(*num_mas)-1].q; temp = point_set; pa = point_set; parent = master_Q[(*num_mas)-1].parent; max_level = master_Q[(*num_mas)-1].level; if(master_Q[(*num_mas)-1].max) if( max_level > ((int) (ceilf(il2 * log(master_Q[(*num_mas)-1].max)))) +1) max_level = ((int) (ceilf(il2 * log(master_Q[(*num_mas)-1].max)))) +1; num_mas[0] = num_mas[0]-1; } }while(*num_mas > 0);

    Read the article

  • Reducing Integer Fractions Algorithm - Solution Explanation?

    - by Andrew Tomazos - Fathomling
    This is a followup to this problem: Reducing Integer Fractions Algorithm Following is a solution to the problem from a grandmaster: #include <cstdio> #include <algorithm> #include <functional> using namespace std; const int MAXN = 100100; const int MAXP = 10001000; int p[MAXP]; void init() { for (int i = 2; i < MAXP; ++i) { if (p[i] == 0) { for (int j = i; j < MAXP; j += i) { p[j] = i; } } } } void f(int n, vector<int>& a, vector<int>& x) { a.resize(n); vector<int>(MAXP, 0).swap(x); for (int i = 0; i < n; ++i) { scanf("%d", &a[i]); for (int j = a[i]; j > 1; j /= p[j]) { ++x[p[j]]; } } } void g(const vector<int>& v, vector<int> w) { for (int i: v) { for (int j = i; j > 1; j /= p[j]) { if (w[p[j]] > 0) { --w[p[j]]; i /= p[j]; } } printf("%d ", i); } puts(""); } int main() { int n, m; vector<int> a, b, x, y, z; init(); scanf("%d%d", &n, &m); f(n, a, x); f(m, b, y); printf("%d %d\n", n, m); transform(x.begin(), x.end(), y.begin(), insert_iterator<vector<int> >(z, z.end()), [](int a, int b) { return min(a, b); }); g(a, z); g(b, z); return 0; } It isn't clear to me how it works. Can anyone explain it? The equivilance is as follows: a is the numerator vector of length n b is the denominator vector of length m

    Read the article

  • Exponential volume control with a specified midpoint

    - by Lars
    I have a slider that returns values from 0 to 100. I am using this to control the gain of an oscillator. When the slider is at 0, I would like the gain to be 0.0 When the slider is at 50, I would like the gain to be 0.1 When the slider is at 100, I would like the gain to be 0.5 So I need to find an equation to get a smooth curve which passes through all of these points. I've got the following equation which gives an exponential curve and gets the start and end points correct, but I don't know how to force the curve through the middle point. Can anyone help? function logSlider(position){ var minP = 0; var maxP = 100; var minV = Math.log(0.0001); var maxV = Math.log(0.5); var scale = (maxV - minV) / (maxP - minP); return Math.exp(minV + scale*(position-minP)); }

    Read the article

  • Three monitor setup not working on Server 2012

    - by maxp
    Using an ATI firepro 4800 card, with three monitors connected (1 dvi, 2 displayport) on Server 2008 R2 worked fine. Ive now moved to a new machine, although identical spec, with a fresh Server 2012 install, and cannot get a three display output - only two. When I try to extend the display on to the third monitor, I get the message "The display settings could not be saved. Please try a different combination of display settings" The machine is a Dell Precision T1600. Any help appreciated.

    Read the article

  • How to apply a .patch from codeplex / ajax toolkit

    - by maxp
    I have obtained the necessary patch for the asyncfileupload control in the codeplex / microsoft ajax control toolkit. However, what i have download is a .patch (AJAXControlToolkit_Issue_Item_#24854.patch), and i cant see any instructions on what im supposed to do from here onwards?

    Read the article

  • Http requests / concurrency?

    - by maxp
    Say a website on my localhost takes about 3 seconds to do each request. This is fine, and as expected (as it is doing some fancy networking behind the scenes). However, if i open the same url in tabs (in firefox), then reload them all at the same time, it appears to load each page sequentially rather than all at the same time. What is this all about? Have tried it on windows server 2008 iis and windows 7 iis

    Read the article

  • How to build library from source (ajax control toolkit)

    - by maxp
    The latest version of Microsoft's ajax library is only available as source code (not a dll). It can be downloaded here: http://ajax.codeplex.com/sourcecontrol/network/Show?projectName=Ajax&changeSetId=49157 Does anyone know how i can actually go about building this into a library like the older (buggy) version? All of the sln files throw errors in visual studio, and after trying to copy the contents of Server\AjaxControlToolkit into a class library im now getting the error Could not find any resources appropriate for the specified culture or the neutral culture.

    Read the article

  • Accessing a cache with a thread? c#

    - by maxp
    Normally i have a static class that reads and writes to HttpContext.Current.Cache However since adding threading to my project, the threads all get null reference exceptions when trying to retrieve this object. Is there any other way i can access it, workarounds or another cache i can use?

    Read the article

  • Specifying properties when initialising

    - by maxp
    void Foo() { bool ID = "test"; var testctrl = new Control() {ID = (ID**=="abc"?ID:ID**)}; } Is it possible to get the value of ID** in the code above? The problem is they both have the same property names. Please ignore the fact the specific ID assignment is pointless, im just using it as an example.

    Read the article

  • Inconsistent syntax c# ?

    - by maxp
    private string[] GetRoles() { string[] foo = {"Test"}; return foo; } The above compiles, but... private string[] GetRoles() { return {"Test"}; } Does not. Replacing it with: return new string[] { "Test" }; Will obviously compile though. Is this inconsistancy or am i being stupid, or am i just wrong :S.

    Read the article

  • Accessing the ASP.NET Cache from a Separate Thread?

    - by maxp
    Normally i have a static class that reads and writes to HttpContext.Current.Cache However since adding threading to my project, the threads all get null reference exceptions when trying to retrieve this object. Is there any other way i can access it, workarounds or another cache i can use?

    Read the article

  • No middle-click scrolling in visual studio 2010?

    - by maxp
    Just as I started to assume this feature was ubiquitous(middle-clicking on a page, then scrolling speed/direction is relative to the distance of the pointer on the y-axis). I can't believe this hasn't been implemented into the text editor in vs2010, I used it all the time in 2005 and 2008. Has anyone managed to find a workaround or am I a minority user of this feature?

    Read the article

  • Will thread.join() block other clients also?

    - by maxp
    In an asp.net web application, say everytime the user makes the request, and the page loads, a thread is fired off that uses thread.join() to block execution until it's finished. Say this thread takes 10 seconds to complete. Does this mean that if 5 totally seperate users make a request to this page, mere miliseconds after the last, does this mean the last user is going to wait 50 seconds to finish their request? Or is each client request threaded?

    Read the article

  • Matching .NET References to Namespaces

    - by maxp
    This seems confusing to me - im creating a class library, and adding all the necessary references for the source files contained in it. Now, off the bat, there were over 300 compiler errors complaining about missing namespaces. The library will now compile after i just added all of the System.* references, however this is obviously not the best way. I.e. if a classes needs using System.Web.Script;, there is no System.Web.Script reference, how would i find out which one of these references contained it? System.Web didnt.

    Read the article

  • Limited options for accessing events in derived classes?

    - by maxp
    Im refactoring a class, and moving sections into a base class. I have a few events similar to public event EventHandler GridBinding; Which are now in the base class, but i am finding i cannot now check to see if the event is null in my derived class. Doing so gives me the error: The event 'xyz.GridBinding' can only appear on the left hand side of += or -= (except when used from within the type 'xyz._MyBaseClass'). Is this correct, am i missing anything, or is there any way to get around this or is writing an accessor the only way to do this? I am using c#/.net 4.0

    Read the article

  • Trying to parse xml, but xmldocument.loadxml() is trying to download?

    - by maxp
    I have a string input that i do not know whether or not is valid xml. I think the simplest aprroach is to wrap new XmlDocument().LoadXml(strINPUT); In a try/catch. The problem im facing is, sometimes strINPUT is an html file, if the header of this file contains <!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd""> <html xml:lang=""en-GB"" xmlns=""http://www.w3.org/1999/xhtml"" lang=""en-GB""> ...like many do, it actually tries to make a connection to the w3.org url, which i really dont want it doing. Anyone know if its possible to just parse the string without trying to be clever and checking external urls? Failing that is there an alternative to xmldocument?

    Read the article

  • setting z-index jquery ui controls?

    - by maxp
    Annoyingly, the jquery ui's set a few css properties inline, making it impossible to override them in the stylesheet. I tried to override the values with jquery, but then they get changed back as soon as the control is interacted with. Does anyone know if any of the jquery ui control's initialisers/constructors have the ability to override their z-index value or set other css properties?

    Read the article

  • Best practise for overriding static classes

    - by maxp
    As it is not possible to override a static class in c#, if i want to override a method I generally define a delegate matching the signature of the static method, then modify the method along the lines of: public static void foo(int bar) { if (delegatename!=null) { delegatename.Invoke(bar); } else { //execute previous code as normal } } I feel a twinge of guilt, knowing this is a bit messy. Can anyone suggest a neater solution to this problem (other than rewriting the original structure)

    Read the article

  • Relative XPath selection using XmlNode (c#)

    - by maxp
    Say i have the following xml file: <a> <b> <c></c> </b> <b> <c></c> </b> </a> var nodes = doc.SelectNodes("/a/b"); will select the two b nodes. I then loop these two nodes suchas: foreach (XmlNode node in nodes) { } However, when i call node.SelectNodes("/a/b/c"); It still returns both values and not just the descendants. Is it possible to select nodes only descening from the current node?

    Read the article

  • Fundamental question about boxing / c#

    - by maxp
    Is it possible to change the value stored inside bar after it has been added? I have tried 'boxing' the string foo but it doesnt work. string foo = "aaaaaaa"; var bar = new System.Web.UI.HtmlControls.HtmlGenericControl("div") { InnerHtml =foo }; foo = "zzzzzz"; plcBody.Controls.Add(bar);//want this to contain 'zzzzzz'

    Read the article

  • Dealing with development and large javascript files?

    - by maxp
    When dealing with websites with large amount of javascript, i see that these are still usually served to the client as one large javascript file. In the development phase, are the javascript files usually split up (say there are 300 lines of js) to make things abit more manageable, and then merged when the website is 'put live'? Or do the developers just put up with working in one long large file?

    Read the article

  • Javascript/jQuery HasLoaded or equivalent?

    - by maxp
    I know in jquery it is possible to call the javascript/jquery onload()/load() functions on, for example an image (<img>). However, if in jquery if i use .html(htmlString) to insert an image after the dom has loaded, how can i add a listener to handle the images onload event? Is there a property I can check to see various images and if they have loaded?

    Read the article

  • Using Jquery, call function on selection just once

    - by maxp
    Say i have a selection of textboxes like this; var arrayoftextboxes = $('.textbox1, .textbox2, .textbox3'); Is there a way I can call a function on each one in a simpler way than this? It only needs to be called once. arrayoftextboxes.each(function(i){foo(arrayoftextboxes[i]);}); I tried arrayoftextboxes.load(function(){foo(this)}); and arrayoftextboxes.bind(function(){foo(this)}); but the functions dont seem to be called.

    Read the article

  • Lost some intellisense in VS2010

    - by maxp
    Getting to grips with Visual Studio 2010, This compiles: var x = System.Web.Security.Membership.GetUser(); And runs, however VS2010 gives no intellisense for x and reports it just as a 'local variable'. Has anyone got any ideas?

    Read the article

1 2  | Next Page >