Trzeba to stdio.h
nie iostream
(co jest dla std::cout
rzeczy) dla printf
(patrz man 3 printf
). Znalazłem kod źródłowy do książki here.
chapter03/hello_world.cu
jest rzeczywiście:
/*
* 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;
}
Gdzie ../common/book.h
obejmuje stdio.h
.
The README.txt
szczegóły pliku jak skompilować przykłady:
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, druga odpowiedź mówi, że to robi, a nawet sekcja B14 ma „printf („Hello gwint% D, F =% f \ n ", threadIdx.x, f);" – Kheldar
jak to ma być wtedy skompilowane? – andandandand
kod z tej książki to zwykłe fragmenty, jeśli dobrze pamiętam, a nie zawsze pełne przykłady. Nie wspominając o tym, że w tym przykładzie używają alt złą praktyką .... –