C++ AMP function argument

Hello,  I am trying to call functions inside a for loop in main.  My AMP code works fine, but I am not really sure what is going on.  In the following code, am I copying data from host to GPU twice every step of the loop? Both array A and
B are really large. I'm trying to avoid copying as much as I can.  It would be very nice if I can pass arrays on GPU (created by funcX) as funcY arguments.  Is there any way I can pass the array already exist on GPU to funcY?  The arrays I use
are defined as 1-Dimensional on CPU and it is treated as 2-Dimensional on GPU. Thank you in advance for your help.   
void funcX(int* A, int* B ){
array_view<int,2> Aamp(n,m,A);
array_view<int,2> Bamp(n,m,B);
parallel_for_each(…..
//do something here
void funcY(int* A, int* B ){
array_view<int,2> Aamp(n,m,A);
array_view<int,2> Bamp(n,m,B);
parallel_for_each(…..
//do something here
int main(){
For(i=0;i<10;i++){
funcX(A,B);
funcY(A,B);
return 0;
 

Hello pi123 (should it not be 314?:)). For this case, the easiest way to go about things is to use the source-less array_view i.e. do something like this:
array_view<T> tmp(some_size);
parallel_for_each(..., [=](...) restrict(amp) {
// Use tmp here.
That will ensure that the underlying storage lives on the accelerator side, and doesn't get spuriously copied back (unless you explicitly access tmp on the host side). I hope this helps. Cheers!

Similar Messages

  • Using a variable in a js function argument

    Folks,
    This is very basic, but I still cannot get it...
    I have this js function in an ASP page:function MM_changeProp(objId,x,theProp,theValue) { //v9.0
      var obj = null; with (document){ if (getElementById)
      obj = getElementById(objId); }
      if (obj){
        if (theValue == true || theValue == false)
          eval("obj.style."+theProp+"="+theValue);
        else eval("obj.style."+theProp+"='"+theValue+"'");
    }i don't understand the function, as it was put in automatically by dreamweaver. right now, i am using this onclick event of an image:<div id="apDiv19" onclick="MM_changeProp('apDiv7','','backgroundColor','#FFFF00','DIV')"></div>the #FFFF00 is the color YELLOW. it is being passed to the theValue argument of the js. what i simply want to do is establish a global variable that will house a color string (like #FFFF00), and then use it in the function argument everytime i need the function. something like this:<div id="apDiv19" onclick="MM_changeProp('apDiv7','','backgroundColor',VARIABLE,'DIV')">i do not know how to do two things:
    1) initialize and assign the variable a value, and where to establish it (inside the script tags? in the head? in the body?)
    2) how to use the variable as an argument in the function
    any help greatly appreciated for this novice. thanks!

    ajetrumpet wrote:
    Folks,
    This is very basic, but I still cannot get it...
    I have this js function in an ASP page:This forum is not about ASP nor JavaScript. Please use Google to find an appropriate JavaScript forum.

  • Using variables for function arguments AS2

      Hello,
    I am trying to create a function in AS2.
    After creating the function, I want to use values stored in variables for the function arguments rather than manually typing static values for carrying out the function calculation. Also, I want to use the function to assign a new value to the existing variable.
    I have asked a similar question 2 days ago here and got the answer (thank you), but now I got one more question - How can I create the function to assign a value to the variable while that variable itself is also a function argument?
    For example, I have 6 numeric variables:
    var CoinA:Number = 10;
    var CoinB:Number = 20;
    var CoinC:Number;
    var CoinD:Number = 30;
    var CoinE:Number = 40;
    var CoinF:Number;
    Then I tried to create a function to assign values to variables CoinC and CoinF:
    function CalculationA(FirstCoin, SecondCoin, ThirdCoin):Void {
         FirstCoin = SecondCoin + ThirdCoin;
    CalculationA(CoinC, CoinA, CoinB);
    CalculationA(CoinF, CoinE, CoinF);
    The above code didn't really assign the values 30 and 70 to the variables CoinC and CoinF but instead, values of CoinC and CoinF are undefined.
    Please give me the correct code if there's a correct way of doing this.
    Thank you,

    Here is one way of doing it, by passing a string value of the variable name instead of the actual variable name....
    var CoinA:Number = 10;
    var CoinB:Number = 20;
    var CoinC:Number;
    var CoinD:Number = 30;
    var CoinE:Number = 40;
    var CoinF:Number;
    function CalculationA(FirstCoin, SecondCoin, ThirdCoin):Void {
         this[FirstCoin] = SecondCoin + ThirdCoin;
    CalculationA("CoinC", CoinA, CoinB);
    CalculationA("CoinF", CoinD, CoinE);
    (Note that in your second function call I changed the coins since CoinF (ThirdCoin) is undefined at that point.)

  • Bypassing function argument without changing default value

    Hi there
    I’m having some problems understanding how I can bypass function arguments without changing its default value. Here are some examples:
     function myFunction ( arg1:Boolean, arg2:String="default string", arg3:Number=3 ):Array
        return new Array (arg1, arg2, arg3);
    trace(myFunction(true, "new string", 5));
    // true,new string,5
    trace(myFunction(true, undefined, 5));
    // true,,5
    trace(myFunction(true, null, 5));
    // true,,5
    trace(myFunction(true));
    // true,default string,3
    trace(myFunction(true, null));
    // true,,3
    My question is: Shouldn't I be able to call a function bypass the second argument (that has a default value), change third argument and on result second argument maintains its default value?
    Example:
    trace(myFunction(true, null, 5));
    // not desired: true,,5
    // desired: true,default string,5
    I know that applying a defult value to the argument allows one to bypass it. But it will always be redefined or to null or to undefined. At the moment I only see one solution.
    function myFunction ( arg1:Boolean, arg2:String="default string", arg3:Number=3 ):Array
         if (!arg2)arg2 = "deafult string";
         return new Array (arg1, arg2, arg3);
    It just seems like too much code repeated
    Regards

    Hi dmennenoh,
    Yup, this was just an example to show that the use of a default value only helps you to bypass the need to simulate a MouseEvent Object for an onRollOver MouseEvent argument. Other than that you can never bypass it without changing its value. You must always apply a null or undefined value and work with that.
    Thanks anyway

  • "Argument mismatch in property or function argument" on nodes.length

    Hi,
    However I try to get the length on the nodes property, I always get this error:
      "Argument mismatch in property or function argument"
    It happens regardless of which level of the DOM/SOM I try at, even though I can resolve nodes, get values, etc.
    An example that would throw the error: 
        var objDataGroup = xfa.resolveNode("$data");      xfa.host.messageBox (objDataGroup.nodes.length);
    What am I doing wrong?
    Thanks!

    Did you try the below..
    Try the resolveNode on $record instead of $data.
    var objDataGroup = xfa.resolveNode("$record");
    xfa.host.messageBox("" + objDataGroup.nodes.length);
    Thanks
    Srini
    Message was edited by: Srini Dhulipalla

  • Using a conditional staement as part of a function argument.

    I'm trying to consolidate two calls to a function down to one. I'm trying to do it by passing some sort of conditional expression as an argument equivalent to:
    get_exists_psa_req_id(
    decode(fin_sr_id, NULL,' ',' AND sched_requirement_id = '|| to_char(fin_sr_id))
    If fin_sr_id, is NULL the select statement I'm passing this to gets a blank line. If not then the additional AND phrase gets added.
    I tried that and got a message back saying that you can only use decode in a SQL query.
    What can I use or can I do anything like this?

    Use CASE instead:
    get_exists_psa_req_id (CASE fin_sr_id
    WHEN NULL  THEN ' '
    ELSE   
    Sorry Michaels
    Be care full with CASE and NULL
    Please check following posting NULL is treated differently in CASE then DECODE
    may be you have to use
    CASE  WHEN  fin_sr_id IS NULL
             THEN  ' '
    Re: Null values and Switch CASE - Conflict !!!
    Message was edited by:
    devmiral

  • Problem with function arguments

    I am having a problem with arguments to a function not
    working. In the attached example, the values passed to the function
    are never reflected within the function.
    Can any one tell me what I am doing wrong?
    Thanks,
    David

    hey drzeller,
    i just copied and pasted the original code you attached to
    this thread into flash and kglad is right. there is no problem with
    any of it. i didn't check your values before i altered your code
    originally, i just assumed they were outputting the values you
    posted. if you will copy and paste your original code back into
    flash and check the output window you will see what kglad is
    talking about.
    just so you know, all the advice i've ever seen in this forum
    from kglad has been spot on. definitely use his advice.

  • Weird things happen when using .cfc function arguments

    Hey Guys,
    I have a function as the following attached code, I can
    invoke this function and it works well. but when I change the
    number
    32144809 to
    <cfqueryparam value="#arguments.jpRunNum#"
    cfsqltype="cf_sql_integer"> and invoke it by
    <cfset qGetJPDependency =
    CreateObject("component","cfdocs.imd.criticalPath.components.CriticalPath").test(run_num) >,it
    firstly takes a long time waiting without any response, then it
    shows a message "Request timed out waiting to execute", I don't how
    to explain this, is there anyone know the reason caused this
    issue????
    Thanks!

    Have you checked the logs to see what (if anything) else is
    being reported
    back about this?
    Can you check what's going on on the Oracle - am guessing
    it's Oracle from
    the "CONNECT BY PRIOR" - box @ the time? I presume you can
    set it to log
    all SQL or JDBC activity?
    Are you certain (absolutely ~) that arguments.jpRunNum
    contains 32144809,
    for the purposes of the test that's failing?
    What if you factor the query out into a CF template and run
    these tests:
    1) as is in your example
    2) change 32144809 to use a <cfqueryparam>, but still
    hard code the value
    to 32144809.
    3) set a variable to 32144809, and use the variable as the
    value of the
    parameter.
    From what you're describing, it seems like your query is
    getting in a loop,
    which with this sort of thing can be down to giving the
    CONNECT BY PRIOR a
    bung value.
    Adam

  • Sending MovieClip name as function argument

    I have a form in Flash that contains twenty form fields
    comprised of a MovieClip.TextField pair. Each field has a unique
    parent MovieClip name and a common TextField name. Upon submission
    of the form, I want to write the data contained in each field to an
    array.
    Rather than write the same if-else if-else loop for each
    field, I would like to write a function that accepts the unique
    MovieClip name as an argument. Attached is a simplified version of
    my code. What am I doing wrong?!?

    Sorry... answering my own questions a second after asking
    them. I needed to pass the MovieClip name as a MovieClip to the
    argument. See attached code.

  • Procedures vs. Functions - arguments OUT

    I thought a procedure just did something whereas a function returned a value. Oracle says "Specify OUT to indicate that the procedure passes a value for this argument back to its calling environment after execution.", so does this mean a procedure can be like a function but can pass back more that one value?
    Matt

    Matt,
    You can specify IN,OUT, IN OUT parameters in both:
    In the Pl/Sql procedure and in the Pl/Sql function.
    There is a limitation however.
    As soon as you specify OUT or IN OUT parameter in the function, this function cannot be used in SELECT statement.
    It can be still used inside PL/sql block ,procedure or other function.
    From the practical programming point of view, there is very little reason to use
    OUT and IN OUT parameters in the function
    HTH
    Thomas

  • Passing a function argument into LoadListener

    Hi, I was wondering if you could help me, imagin that I have
    a function. This function gets an argument like this:
    function PMFUpdate(PMID){
    Spry.Utils.loadURL("GET", "test/update.php?id="+PMID, true);
    Now, I want to use LoadListener and EventListeners, like
    this:
    Spry.Utils.addLoadListener(function(){
    Spry.Utils.addEventListener("element", "click",
    PMFUpdate(PMID), false);
    But I know this dosn't work! How can I pass PMFUPDATE()
    argument into LoadListener and use it in EventListener.
    Another question, how can I load certain amount of records in
    a XMLDataSet without PagedView.
    Oh, Last question, I bet, How can I stop loading
    XMLDataSet???
    Thanks in advance!

    maby this is what u are looking for in stopping the xml from
    loading;
    http://labs.adobe.com/technologies/spry/articles/data_api/apis/dataset.html#cancelloaddata
    loading data pieces with out paged;
    http://labs.adobe.com/technologies/spry/articles/data_api/apis/dataset.html#getdata
    element selector; maby this will help u out a bit.
    Spry.Utils.addEventListener("element", "click", function(e)
    var PMID = (how ever u where gonna get the id)
    PMFUpdate(PMID);
    return false;
    }, false);

  • Javascript function arguments

    When using JavasScript code in ASP on Sun's server I have encountered a strange problem:-
    Simple code to illustrate is
    <%
    function myClass()
    this.myMethod=myClass_myMethod;
    function myClass_myMethod(nNumber)
    return nNumber+1;
    var oObject=new myClass();
    var nValue=oObject.myMethod(2);
    %>
    I am finding that the interpreter is not able to access the argument nNumber by name in myMethod.
    Instead I have to use:
    function myClass_myMethod()
    var nNumber=myClass_myMethod.arguments[0];
    return nNumber+1;
    Any clues? Is it because the script is enclose in <% %> and not <SCRIPT runat=server> tags.

    Hello,
    Well this is more a pure javascript question than a HTML DB you should ask google.
    But it depends what you are doing with your function, if each value is a specific variable then no your function will have to look like f(nul,null,null,1,null,null,null,.........) .
    If you are using them to populate an js array you can iterate through your arguments or just provide the array are your argument.
    Personally and I do know a little about javascript I would avoid like the plague any js function that requires 50 arguments ( i usally start looking at a different solution at abut 10 arguments) especially if most of them could be null, there absolutely has to be a better way to do it.
    Like breaking up into smaller more specific functions or creating a js object that is more robust, agian you should ask google.
    Carl

  • Function arguments

    hi to there .
    is any way to get argument for onFinishTween's function   ?! ( for onComlete event )
    TweenLite.to(MC, 1.5, {alpha:1, tint:color[Math.floor(Math.random()*(color.length))],onComplete:onFinishTween});
              function onFinishTween():void {
                             //trace("The tween has finished! b-) ");
                             //reNew();
    I want to cheack every finieshfunction ;
    thanks a lot

    first, never nest named functions.  second, tweenlite has onCompleteParams property you can use:
    EF( );
    function EF( ) {
         var A:Array=randomize();
         for (var p:int =0; p<A.length; p++) {
              TweenLite.to(globalStage["square"+A[p]], 1.5, {alpha:1, tint:color[Math.floor(Math.random()*(color.length))],onComplete:onFinishTween,onCompleteParams:[p]});
              TweenMax.to(globalStage["square"+A[p]], 1.5, {glowFilter:{color:color[Math.floor(Math.random()*(color.length))], alpha:1, blurX:50, blurY:50}});
      function onFinishTween(p:int):void {
                                  //trace("The tween has finished! b-) ");
                                  /*if (i==A.length) {
                                       EF( );

  • How to use a lexical variable in a WHERE clause and as a function argument.

    Hello,
    My report has a lexical variable which has values like 'and id in (1,3,4)'. I want to use this variable in two separate queries. In the first, it is used in the WHERE clause, something like:
    .. where date is not null &var;
    In the second query, the variable is used in a function call, something like:
    select * from table (my_function(&var));
    The trouble is that the first query works when the value of the variable is unquoted, but for the second query the value should be quoted.
    Does anyone have an idea how I could solve this problem?
    Thanks in advance,
    Frans
    Message was edited by:
    fransie

    http://tkyte.blogspot.com/2006/06/varying-in-lists.html
    Presents many options.

  • How do I change button skin with function arguments?

    Hi guys, I am building a map witch I represent with buttons grid 40*26, now I wont to create a function in action script that will get a string that contains the folder name where I am storing the buttons skin data for example:
    [Embed("maps/grass/upSkin.jpg")]
    private var _upSkin:Class;
    [Embed("maps/grass/overSkin.jpg")]
    private var _overSkin:Class;
    [Embed("maps/grass/downSkin.jpg")]
    private var _downSkin:Class;
    private function changeMap():void
         slot:Button=new Button();
         slot.setStyle("upSkin",test);
         slot.setStyle("overSkin",_overSkin);
         slot.setStyle("downSkin",_downSkin);
    This is what I managed to do up to now, what I would like to do is to send to changeMap() a string with the path name, but some how I can't embed a variables, I will be glade if you could find a solution for that.
    This is the link for my site, so you can see what I am talking about. I am not always online but you can try.
    http://gazmanwars.zapto.org/
    *Best view under 1280*960 rez

    in this case StyleManager.loadStyleDeclarations(currentTheme + ".swf"); can come handy.This satement will load new style Declarations for your application on runtime whenever you want.
    currentTheme will be your css file containing styles compiled into swf by flex builder  you can do that by right clicking on css file and selecting
    Compile Css To Swf
    for more information on style Manager see following link
    http://livedocs.adobe.com/flex/3/html/help.html?content=styles_07.html

Maybe you are looking for

  • Messages problem with ios 6

    Hi I have problem with messages related to bank or groups or unviersity . I can see the preview of last message but when I enter for example Bank I can't see any Previous messages . Some messages contain imp information . Can u fix this problem soon

  • Address Book, blank, can't add anything

    I haven't used AB for years, and probably did so on a 2004 version on my first laptop. But, when I went to open it (on a 2011 MBP and a 2007 MBP) it opens to a blank page, and nothing "works." When I try to add a new card, nothing happens. When I try

  • When to use FUNCTION MODULES

    In Generic Extraction why do we use FUNCTION MODULES over VIEWS (when do we use Function modules and views).

  • Can lync client use internet proxy settings to proxy edge servers, if direct access is not reachable?

    Hi everybody I am trying to Login with my lync Client out of my organization. So I am using lync as a remote user. I am in another organization, and I am using their coporate lan wired and wireless, but I cannot Login to lync in my organization. I se

  • [SOLVED] Playing sound simultaniously from wine and other applications

    I'm using Pulseaudio with the following packages installed: ~> pacman -Q | grep 'alsa\|pulse' alsa-lib 1.0.27.2-1 alsa-plugins 1.0.27-2 alsa-utils 1.0.27.2-1 lib32-alsa-lib 1.0.27.2-1 lib32-libpulse 5.0-1 libpulse 5.0-1 pulseaudio 5.0-1 pulseaudio-al