Skip to content

Commit

Permalink
Add some comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Xreki committed Dec 8, 2017
1 parent ee5df62 commit 68f6b80
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion paddle/capi/examples/model_inference/multi_thread/main_gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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));

Expand Down
1 change: 1 addition & 0 deletions paddle/capi/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 68f6b80

Please sign in to comment.