Es necesario incluir stdio.h
no iostream
(que es para std::cout
cosas) para printf
(ver man 3 printf
). Encontré el código fuente para el libro here.
chapter03/hello_world.cu
es en realidad:
/*
* Copyright 1993-2010 NVIDIA Corporation. All rights reserved.
*
* NVIDIA Corporation and its licensors retain all intellectual property and
* proprietary rights in and to this software and related documentation.
* Any use, reproduction, disclosure, or distribution of this software
* and related documentation without an express license agreement from
* NVIDIA Corporation is strictly prohibited.
*
* Please refer to the applicable NVIDIA end user license agreement (EULA)
* associated with this source code for terms and conditions that govern
* your use of this NVIDIA software.
*
*/
#include "../common/book.h"
int main(void) {
printf("Hello, World!\n");
return 0;
}
Dónde ../common/book.h
incluye stdio.h
.
Los detalles de los archivos README.txt
cómo compilar los ejemplos:
The vast majority of these code examples can be compiled quite easily by using
NVIDIA's CUDA compiler driver, nvcc. To compile a typical example, say
"example.cu," you will simply need to execute:
> nvcc example.cu
@awoodland: Hmmmm, la segunda respuesta dice que lo hace, y de hecho la sección B14 tiene "printf (“Hola hilo% d, f = f% \ n ", threadIdx.x, f);" – Kheldar
¿cómo se supone que se compilará entonces? – andandandand
las cosas del código de ese libro son simples fragmentos si recuerdo correctamente, y no siempre ejemplos completos. Sin mencionar que usan alto de mala práctica en esos ejemplos ... –