Thu Dec 12 15:13:24 2024
EVENTS
 FREE
SOFTWARE
INSTITUTE

POLITICS
JOBS
MEMBERS'
CORNER

MAILING
LIST

NYLXS Mailing Lists and Archives
NYLXS Members have a lot to say and share but we don't keep many secrets. Join the Hangout Mailing List and say your peice.

DATE 2016-10-01

LEARN

2024-12-12 | 2024-11-12 | 2024-10-12 | 2024-09-12 | 2024-08-12 | 2024-07-12 | 2024-06-12 | 2024-05-12 | 2024-04-12 | 2024-03-12 | 2024-02-12 | 2024-01-12 | 2023-12-12 | 2023-11-12 | 2023-10-12 | 2023-09-12 | 2023-08-12 | 2023-07-12 | 2023-06-12 | 2023-05-12 | 2023-04-12 | 2023-03-12 | 2023-02-12 | 2023-01-12 | 2022-12-12 | 2022-11-12 | 2022-10-12 | 2022-09-12 | 2022-08-12 | 2022-07-12 | 2022-06-12 | 2022-05-12 | 2022-04-12 | 2022-03-12 | 2022-02-12 | 2022-01-12 | 2021-12-12 | 2021-11-12 | 2021-10-12 | 2021-09-12 | 2021-08-12 | 2021-07-12 | 2021-06-12 | 2021-05-12 | 2021-04-12 | 2021-03-12 | 2021-02-12 | 2021-01-12 | 2020-12-12 | 2020-11-12 | 2020-10-12 | 2020-09-12 | 2020-08-12 | 2020-07-12 | 2020-06-12 | 2020-05-12 | 2020-04-12 | 2020-03-12 | 2020-02-12 | 2020-01-12 | 2019-12-12 | 2019-11-12 | 2019-10-12 | 2019-09-12 | 2019-08-12 | 2019-07-12 | 2019-06-12 | 2019-05-12 | 2019-04-12 | 2019-03-12 | 2019-02-12 | 2019-01-12 | 2018-12-12 | 2018-11-12 | 2018-10-12 | 2018-09-12 | 2018-08-12 | 2018-07-12 | 2018-06-12 | 2018-05-12 | 2018-04-12 | 2018-03-12 | 2018-02-12 | 2018-01-12 | 2017-12-12 | 2017-11-12 | 2017-10-12 | 2017-09-12 | 2017-08-12 | 2017-07-12 | 2017-06-12 | 2017-05-12 | 2017-04-12 | 2017-03-12 | 2017-02-12 | 2017-01-12 | 2016-12-12 | 2016-11-12 | 2016-10-12 | 2016-09-12 | 2016-08-12 | 2016-07-12 | 2016-06-12 | 2016-05-12 | 2016-04-12 | 2016-03-12 | 2016-02-12 | 2016-01-12 | 2015-12-12 | 2015-11-12 | 2015-10-12 | 2015-09-12 | 2015-08-12 | 2015-07-12 | 2015-06-12 | 2015-05-12 | 2015-04-12 | 2015-03-12 | 2015-02-12 | 2015-01-12 | 2014-12-12 | 2014-11-12 | 2014-10-12

Key: Value:

Key: Value:

MESSAGE
DATE 2016-10-31
FROM Christopher League
SUBJECT Re: [Learn] cudaMallac
From learn-bounces-at-nylxs.com Mon Oct 31 17:24:39 2016
Return-Path:
X-Original-To: archive-at-mrbrklyn.com
Delivered-To: archive-at-mrbrklyn.com
Received: from www.mrbrklyn.com (www.mrbrklyn.com [96.57.23.82])
by mrbrklyn.com (Postfix) with ESMTP id 94756161312;
Mon, 31 Oct 2016 17:24:39 -0400 (EDT)
X-Original-To: learn-at-nylxs.com
Delivered-To: learn-at-nylxs.com
Received: from liucs.net (contrapunctus.net [174.136.110.10])
by mrbrklyn.com (Postfix) with ESMTP id 415CA161311
for ; Mon, 31 Oct 2016 17:24:36 -0400 (EDT)
Received: from localhost (unknown [148.4.40.11])
by liucs.net (Postfix) with ESMTPSA id C284FE08E;
Mon, 31 Oct 2016 17:24:34 -0400 (EDT)
From: Christopher League
To: Ruben Safir , Samir Iabbassen ,
learn-at-nylxs.com
In-Reply-To:
References:
User-Agent: Notmuch/0.21 (http://notmuchmail.org) Emacs/25.1.1
(x86_64-unknown-linux-gnu)
Date: Mon, 31 Oct 2016 17:24:34 -0400
Message-ID: <87r36w8b59.fsf-at-contrapunctus.net>
MIME-Version: 1.0
Subject: Re: [Learn] cudaMallac
X-BeenThere: learn-at-nylxs.com
X-Mailman-Version: 2.1.17
Precedence: list
List-Id:
List-Unsubscribe: ,

List-Archive:
List-Post:
List-Help:
List-Subscribe: ,

Content-Type: multipart/mixed; boundary="===============1024648616=="
Errors-To: learn-bounces-at-nylxs.com
Sender: "Learn"

--===============1024648616==
Content-Type: multipart/alternative; boundary="=-=-="

--=-=-=
Content-Type: text/plain


Ruben Safir writes:

> Why are we using the ADDRESS of a pointer to a float as in &d_in

Because the first parameter of `cudaMalloc` is what, in some programming
languages, would be called an "output parameter". The `cudaMalloc`
function is going to overwrite the value of the pointer with a new
pointer to the allocated memory. For it to do that, we have to pass the
address of the pointer.

In C++, we could do it as a "reference parameter" instead, that type
would be `void*&` and then you don't have to do `&d_in` but just `d_in`.
(It still passes the address behind the scenes.)

Compare `cudoMalloc` to the regular `malloc` in `stdlib.h` -- it
*returns* the pointer, so there's no need for an "output parameter".

~~~~ {.cpp}
float* d_in = (float*) malloc(ARRAY_BYTES);
~~~~

CL

~~~~ {.cpp}
#include

int main(int argc, char ** argv)
{
const int ARRAY_SIZE = 64;
const int ARRAY_BYTES = sizeof(float) * ARRAY_SIZE;
//generate the input array on host
float h_in[ARRAY_SIZE];
float h_out[ARRAY_SIZE];
for( int i = 0; i < ARRAY_SIZE; i++)
{
h_in[i] = float(i);
}
//declare gpu memory pointers
float *d_in *d_out;
cudaMalloc(( void **) &d_in, ARRAY_BYTES );
cudaMalloc(( void **) &d_out, ARRAY_BYTES );
}
~~~~

--=-=-=
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable






1.0, user-scalable=3Dyes">




Ruben Safir ruben-at-mrbrklyn.com=
writes:



Why are we using the ADDRESS of a pointer to a float as in &d_in



Because the first parameter of cudaMalloc is what, in some =
programming languages, would be called an =E2=80=9Coutput parameter=E2=80=
=9D. The cudaMalloc function is going to overwrite the value o=
f the pointer with a new pointer to the allocated memory. For it to do that=
, we have to pass the address of the pointer.


In C++, we could do it as a =E2=80=9Creference parameter=E2=80=9D instea=
d, that type would be void*& and then you don=E2=80=99t ha=
ve to do &d_in but just d_in. (It still passe=
s the address behind the scenes.)


Compare cudoMalloc to the regular malloc in ode>stdlib.h =E2=80=93 it returns the pointer, so there=E2=
=80=99s no need for an =E2=80=9Coutput parameter=E2=80=9D.


ceCode cpp">  float* d_in =3D (>float*) malloc(ARRAY_BYTES);

CL


ceCode cpp">#include <stdio.h>

int main(int argc, n class=3D"dt">char ** argv)
{
const int ARRAY_SIZE =
=3D 64;
const int ARRAY_BYTES=
=3D sizeof(float) * AR=
RAY_SIZE;
//generate the input array on host
float h_in[ARRAY_SIZE];
float h_out[ARRAY_SIZE];
for( int i =3D class=3D"dv">0; i < ARRAY_SIZE; i++)
{
h_in[i] =3D float(i);
}
//declare gpu memory pointers
float *d_in *d_out;
cudaMalloc(( void **) &d_in, ARRAY_BYTES );
cudaMalloc(( void **) &d_out, ARRAY_BYTES );
}




--=-=-=--

--===============1024648616==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Learn mailing list
Learn-at-nylxs.com
http://lists.mrbrklyn.com/mailman/listinfo/learn

--===============1024648616==--

  1. 2016-10-04 ruben safir <ruben-at-mrbrklyn.com> Re: [Learn] Check List of Texts to learn Cladistics and
  2. 2016-10-04 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] Library access
  3. 2016-10-04 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] Library access
  4. 2016-10-04 Christopher League <christopher.league-at-liu.edu> Re: [Learn] phylogenetics
  5. 2016-10-04 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] 3rd scans and displays for msueums
  6. 2016-10-04 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] =?utf-8?q?Residual_diversity_estimates=E2=80=99_do_not_co?=
  7. 2016-10-04 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] another paper on this topic to dig through
  8. 2016-10-04 Ruben Safir <ruben.safir-at-my.liu.edu> Subject: [Learn] Basic Phylogeny and Systematics
  9. 2016-10-04 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Library access
  10. 2016-10-05 Ruben Safir <mrbrklyn-at-panix.com> Re: [Learn] 3rd scans and displays for msueums
  11. 2016-10-05 ruben safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Re: Check List of Texts to learn Cladistics and
  12. 2016-10-06 From: "Ruben.Safir" <ruben.safir-at-my.liu.edu> Subject: [Learn] TNT - Boom
  13. 2016-10-06 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] tomorrow
  14. 2016-10-09 ruben safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: phylogeny tyrannosauroid dinosaurs
  15. 2016-10-09 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Re: phylogeny tyrannosauroid dinosaurs
  16. 2016-10-09 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Re: [dinosaur] phylogeny tyrannosauroid dinosaurs
  17. 2016-10-10 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] Paleo meeting time
  18. 2016-10-10 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] phylogeny tyrannosauroid dinosaurs
  19. 2016-10-10 Steve Brusatte <brusatte-at-gmail.com> Re: [Learn] phylogeny tyrannosauroid dinosaurs
  20. 2016-10-10 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] phylogeny tyrannosauroid dinosaurs
  21. 2016-10-10 From: =?UTF-8?B?RGF2aWQgxIxlcm7DvQ==?= <david.cerny1-at-gmail.com> Re: [Learn] [dinosaur] phylogeny tyrannosauroid dinosaurs
  22. 2016-10-10 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] [dinosaur] phylogeny tyrannosauroid dinosaurs
  23. 2016-10-10 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] [dinosaur] phylogeny tyrannosauroid dinosaurs
  24. 2016-10-10 Dalton Meyer <paleonerd12-at-gmail.com> Re: [Learn] [dinosaur] phylogeny tyrannosauroid dinosaurs
  25. 2016-10-10 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] AI research
  26. 2016-10-10 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] CTScan in paelo
  27. 2016-10-10 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Re: [dinosaur] phylogeny tyrannosauroid dinosaurs
  28. 2016-10-10 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] http://palaeos.com/phylogeny/index.html
  29. 2016-10-10 Ruben Safir <ruben.safir-at-my.liu.edu> Subject: [Learn] maxillary fenestra and promaxillary fenestra
  30. 2016-10-10 Christopher League <league-at-contrapunctus.net> Subject: [Learn] Paleo meeting time
  31. 2016-10-10 Christopher League <league-at-contrapunctus.net> Subject: [Learn] Paleo meeting time
  32. 2016-10-10 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] promaxillary fenestra
  33. 2016-10-13 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] Invitation: Phylogenetics project mtg -at- Thu 2016-10-13
  34. 2016-10-13 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] Library access
  35. 2016-10-13 ruben safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: access to the screen
  36. 2016-10-13 ruben safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: access to the screen
  37. 2016-10-13 ruben safir <ruben-at-mrbrklyn.com> Subject: [Learn] graphics
  38. 2016-10-14 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] a new generation discovers freedom
  39. 2016-10-14 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Check out this picture...
  40. 2016-10-14 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Check out this picture...
  41. 2016-10-14 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Check out this picture...
  42. 2016-10-14 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Check out this picture...
  43. 2016-10-15 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] 3d scanning in the field
  44. 2016-10-15 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] 3d scanning in the field
  45. 2016-10-16 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Jobs
  46. 2016-10-19 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] tomorrows schedule and plan got the week
  47. 2016-10-20 Christopher League <league-at-contrapunctus.net> Re: [Learn] tomorrows schedule and plan got the week
  48. 2016-10-21 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] tomorrows schedule and plan got the week
  49. 2016-10-21 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] publication
  50. 2016-10-21 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] thesis resources
  51. 2016-10-25 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Phylogenetics educational links
  52. 2016-10-27 Christopher League <league-at-contrapunctus.net> Re: [Learn] Phylogenetics educational links
  53. 2016-10-27 Ruben Safir <mrbrklyn-at-panix.com> Re: [Learn] Phylogenetics educational links
  54. 2016-10-27 Ruben Safir <mrbrklyn-at-panix.com> Re: [Learn] Phylogenetics educational links
  55. 2016-10-27 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] Phylogenetics educational links
  56. 2016-10-27 Ruben Safir <mrbrklyn-at-panix.com> Re: [Learn] Phylogenetics educational links
  57. 2016-10-30 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Orders for the Thesis,
  58. 2016-10-31 Christopher League <league-at-contrapunctus.net> Re: [Learn] cuda kernels
  59. 2016-10-31 Ruben Safir <ruben.safir-at-my.liu.edu> Re: [Learn] cuda kernels
  60. 2016-10-31 Christopher League <league-at-contrapunctus.net> Re: [Learn] cudaMallac
  61. 2016-10-31 Ruben Safir <mrbrklyn-at-panix.com> Re: [Learn] cudaMallac
  62. 2016-10-31 Christopher League <league-at-contrapunctus.net> Subject: [Learn] Computational evolution
  63. 2016-10-31 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] cuda kernels
  64. 2016-10-31 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] cudaMallac

NYLXS are Do'ers and the first step of Doing is Joining! Join NYLXS and make a difference in your community today!