From 68f6b80acdb7ed7abf3ce56d17d759d12183c266 Mon Sep 17 00:00:00 2001 From: Liu Yiqun Date: Fri, 8 Dec 2017 02:44:53 +0000 Subject: [PATCH] Add some comments. --- .../examples/model_inference/multi_thread/main_gpu.c | 9 ++++++++- paddle/capi/main.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/paddle/capi/examples/model_inference/multi_thread/main_gpu.c b/paddle/capi/examples/model_inference/multi_thread/main_gpu.c index 63f2a9eeb09a0..6fd376e0d1a2f 100644 --- a/paddle/capi/examples/model_inference/multi_thread/main_gpu.c +++ b/paddle/capi/examples/model_inference/multi_thread/main_gpu.c @@ -9,6 +9,13 @@ pthread_mutex_t mutex; +/* + * @brief It is an simple inference example that runs multi-threads on a GPU. + * Each thread holds it own local gradient_machine but shares the same + * parameters. + * If you want to run on different GPUs, you need to launch + * multi-processes or set trainer_count > 1. + */ void* thread_main(void* gm_ptr) { // Initialize the thread environment of Paddle. CHECK(paddle_init_thread()); @@ -29,7 +36,7 @@ void* thread_main(void* gm_ptr) { paddle_real* cpu_input = (paddle_real*)malloc(784 * sizeof(paddle_real)); paddle_real* cpu_output = (paddle_real*)malloc(10 * sizeof(paddle_real)); for (int iter = 0; iter < NUM_ITER; ++iter) { - // There is only one input of this network. + // There is only one input layer of this network. CHECK(paddle_arguments_resize(in_args, 1)); CHECK(paddle_arguments_set_value(in_args, 0, mat)); diff --git a/paddle/capi/main.h b/paddle/capi/main.h index ffa4caa05a3b4..99c4e8428dbaa 100644 --- a/paddle/capi/main.h +++ b/paddle/capi/main.h @@ -29,6 +29,7 @@ PD_API paddle_error paddle_init(int argc, char** argv); /** * Initialize the thread environment of Paddle. * @note it is requisite for GPU runs but optional for CPU runs. + * For GPU runs, all threads will run on the same GPU devices. */ PD_API paddle_error paddle_init_thread();