Mercurial > hg > truffle
comparison src/gpu/ptx/vm/gpu_ptx.cpp @ 12566:c17bfad2fa98
Merge.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Thu, 24 Oct 2013 15:56:08 +0200 |
parents | f020e149c1b6 |
children | 1a7e7011a341 |
comparison
equal
deleted
inserted
replaced
12565:e47f373499ec | 12566:c17bfad2fa98 |
---|---|
383 BasicType return_type = ptxka.get_ret_type(); | 383 BasicType return_type = ptxka.get_ret_type(); |
384 switch (return_type) { | 384 switch (return_type) { |
385 case T_INT: | 385 case T_INT: |
386 { | 386 { |
387 int return_val; | 387 int return_val; |
388 status = gpu::Ptx::_cuda_cu_memcpy_dtoh(&return_val, ptxka._return_value_ptr, T_INT_BYTE_SIZE); | 388 status = gpu::Ptx::_cuda_cu_memcpy_dtoh(&return_val, ptxka._dev_return_value, T_INT_BYTE_SIZE); |
389 if (status != GRAAL_CUDA_SUCCESS) { | 389 if (status != GRAAL_CUDA_SUCCESS) { |
390 tty->print_cr("[CUDA] *** Error (%d) Failed to copy value to device argument", status); | 390 tty->print_cr("[CUDA] *** Error (%d) Failed to copy value to device argument", status); |
391 return false; | 391 return false; |
392 } | 392 } |
393 ret.set_jint(return_val); | 393 ret.set_jint(return_val); |
394 } | 394 } |
395 break; | 395 break; |
396 case T_BOOLEAN: | 396 case T_BOOLEAN: |
397 { | 397 { |
398 int return_val; | 398 int return_val; |
399 status = gpu::Ptx::_cuda_cu_memcpy_dtoh(&return_val, ptxka._return_value_ptr, T_INT_BYTE_SIZE); | 399 status = gpu::Ptx::_cuda_cu_memcpy_dtoh(&return_val, ptxka._dev_return_value, T_INT_BYTE_SIZE); |
400 if (status != GRAAL_CUDA_SUCCESS) { | 400 if (status != GRAAL_CUDA_SUCCESS) { |
401 tty->print_cr("[CUDA] *** Error (%d) Failed to copy value to device argument", status); | 401 tty->print_cr("[CUDA] *** Error (%d) Failed to copy value to device argument", status); |
402 return false; | 402 return false; |
403 } | 403 } |
404 ret.set_jint(return_val); | 404 ret.set_jint(return_val); |
405 } | 405 } |
406 break; | 406 break; |
407 case T_FLOAT: | 407 case T_FLOAT: |
408 { | 408 { |
409 float return_val; | 409 float return_val; |
410 status = gpu::Ptx::_cuda_cu_memcpy_dtoh(&return_val, ptxka._return_value_ptr, T_FLOAT_BYTE_SIZE); | 410 status = gpu::Ptx::_cuda_cu_memcpy_dtoh(&return_val, ptxka._dev_return_value, T_FLOAT_BYTE_SIZE); |
411 if (status != GRAAL_CUDA_SUCCESS) { | 411 if (status != GRAAL_CUDA_SUCCESS) { |
412 tty->print_cr("[CUDA] *** Error (%d) Failed to copy value to device argument", status); | 412 tty->print_cr("[CUDA] *** Error (%d) Failed to copy value to device argument", status); |
413 return false; | 413 return false; |
414 } | 414 } |
415 ret.set_jfloat(return_val); | 415 ret.set_jfloat(return_val); |
416 } | 416 } |
417 break; | 417 break; |
418 case T_DOUBLE: | 418 case T_DOUBLE: |
419 { | 419 { |
420 double return_val; | 420 double return_val; |
421 status = gpu::Ptx::_cuda_cu_memcpy_dtoh(&return_val, ptxka._return_value_ptr, T_DOUBLE_BYTE_SIZE); | 421 status = gpu::Ptx::_cuda_cu_memcpy_dtoh(&return_val, ptxka._dev_return_value, T_DOUBLE_BYTE_SIZE); |
422 if (status != GRAAL_CUDA_SUCCESS) { | 422 if (status != GRAAL_CUDA_SUCCESS) { |
423 tty->print_cr("[CUDA] *** Error (%d) Failed to copy value to device argument", status); | 423 tty->print_cr("[CUDA] *** Error (%d) Failed to copy value to device argument", status); |
424 return false; | 424 return false; |
425 } | 425 } |
426 ret.set_jdouble(return_val); | 426 ret.set_jdouble(return_val); |
427 } | 427 } |
428 break; | 428 break; |
429 case T_LONG: | 429 case T_LONG: |
430 { | 430 { |
431 long return_val; | 431 long return_val; |
432 status = gpu::Ptx::_cuda_cu_memcpy_dtoh(&return_val, ptxka._return_value_ptr, T_LONG_BYTE_SIZE); | 432 status = gpu::Ptx::_cuda_cu_memcpy_dtoh(&return_val, ptxka._dev_return_value, T_LONG_BYTE_SIZE); |
433 if (status != GRAAL_CUDA_SUCCESS) { | 433 if (status != GRAAL_CUDA_SUCCESS) { |
434 tty->print_cr("[CUDA] *** Error (%d) Failed to copy value to device argument", status); | 434 tty->print_cr("[CUDA] *** Error (%d) Failed to copy value to device argument", status); |
435 return false; | 435 return false; |
436 } | 436 } |
437 ret.set_jlong(return_val); | 437 ret.set_jlong(return_val); |
441 break; | 441 break; |
442 default: | 442 default: |
443 tty->print_cr("[CUDA] TODO *** Unhandled return type: %d", return_type); | 443 tty->print_cr("[CUDA] TODO *** Unhandled return type: %d", return_type); |
444 } | 444 } |
445 | 445 |
446 // handle post-invocation object and array arguemtn | 446 // Copy all reference arguments from device to host memory. |
447 ptxka.reiterate(); | 447 ptxka.copyRefArgsFromDtoH(); |
448 | 448 |
449 // Free device memory allocated for result | 449 // Free device memory allocated for result |
450 status = gpu::Ptx::_cuda_cu_memfree(ptxka._return_value_ptr); | 450 status = gpu::Ptx::_cuda_cu_memfree(ptxka._dev_return_value); |
451 if (status != GRAAL_CUDA_SUCCESS) { | 451 if (status != GRAAL_CUDA_SUCCESS) { |
452 tty->print_cr("[CUDA] *** Error (%d) Failed to free device memory of return value", status); | 452 tty->print_cr("[CUDA] *** Error (%d) Failed to free device memory of return value", status); |
453 return false; | 453 return false; |
454 } | 454 } |
455 | 455 |