1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772
|
#!/usr/bin/env python
"""
Python interface to CUFFT functions.
Note: this module does not explicitly depend on PyCUDA.
"""
import ctypes
import operator
import re
import sys
# Load library:
_linux_version_list = [10.1, 10.0, 9.2, 9.1, 9.0, 8.0, 7.5, 7.0, 6.5, 6.0, 5.5, 5.0, 4.0]
_win32_version_list = [10, 100, 92, 91, 90, 80, 75, 70, 65, 60, 55, 50, 40]
if 'linux' in sys.platform:
_libcufft_libname_list = ['libcufft.so'] + \
['libcufft.so.%s' % v for v in _linux_version_list]
elif sys.platform == 'darwin':
_libcufft_libname_list = ['libcufft.dylib']
elif sys.platform == 'win32':
if sys.maxsize > 2**32:
_libcufft_libname_list = ['cufft.dll'] + \
['cufft64_%s.dll' % v for v in _win32_version_list]
else:
_libcufft_libname_list = ['cufft.dll'] + \
['cufft32_%s.dll' % v for v in _win32_version_list]
else:
raise RuntimeError('unsupported platform')
# Print understandable error message when library cannot be found:
_libcufft = None
for _libcufft_libname in _libcufft_libname_list:
try:
if sys.platform == 'win32':
_libcufft = ctypes.windll.LoadLibrary(_libcufft_libname)
else:
_libcufft = ctypes.cdll.LoadLibrary(_libcufft_libname)
except OSError:
pass
else:
break
if _libcufft == None:
raise OSError('cufft library not found')
# General CUFFT error:
class cufftError(Exception):
"""CUFFT error"""
pass
# Exceptions corresponding to different CUFFT errors:
class cufftInvalidPlan(cufftError):
"""CUFFT was passed an invalid plan handle."""
pass
class cufftAllocFailed(cufftError):
"""CUFFT failed to allocate GPU memory."""
pass
class cufftInvalidType(cufftError):
"""The user requested an unsupported type."""
pass
class cufftInvalidValue(cufftError):
"""The user specified a bad memory pointer."""
pass
class cufftInternalError(cufftError):
"""Internal driver error."""
pass
class cufftExecFailed(cufftError):
"""CUFFT failed to execute an FFT on the GPU."""
pass
class cufftSetupFailed(cufftError):
"""The CUFFT library failed to initialize."""
pass
class cufftInvalidSize(cufftError):
"""The user specified an unsupported FFT size."""
pass
class cufftUnalignedData(cufftError):
"""Input or output does not satisfy texture alignment requirements."""
pass
cufftExceptions = {
0x1: cufftInvalidPlan,
0x2: cufftAllocFailed,
0x3: cufftInvalidType,
0x4: cufftInvalidValue,
0x5: cufftInternalError,
0x6: cufftExecFailed,
0x7: cufftSetupFailed,
0x8: cufftInvalidSize,
0x9: cufftUnalignedData
}
class _types:
"""Some alias types."""
plan = ctypes.c_int
stream = ctypes.c_void_p
worksize = ctypes.c_size_t
def cufftCheckStatus(status):
"""Raise an exception if the specified CUBLAS status is an error."""
if status != 0:
try:
e = cufftExceptions[status]
except KeyError:
raise cufftError
else:
raise e
_libcufft.cufftGetVersion.restype = int
_libcufft.cufftGetVersion.argtypes = [ctypes.c_void_p]
def cufftGetVersion():
"""
Get CUFFT version.
"""
version = ctypes.c_int()
result = _libcufft.cufftGetVersion(ctypes.byref(version))
cufftCheckStatus(result)
return version.value
_cufft_version = int(cufftGetVersion())
class _cufft_version_req(object):
"""
Decorator to replace function with a placeholder that raises an exception
if a specified condition on the installed CUFFT version `v` is not satisfied.
"""
def __init__(self, v, op):
self.op_str = op
if op == '>':
self.op = operator.gt
elif op == '>=':
self.op = operator.ge
elif op == '==':
self.op = operator.eq
elif op == '<':
self.op = operator.lt
elif op == '<=':
self.op = operator.le
else:
raise ValueError('unrecognized comparison operator')
self.vs = str(v)
if isinstance(v, int):
self.vi = str(v)
if len(self.vi) != 4:
raise ValueError('integer version number must be 4 digits')
else:
major, minor = re.search(r'(\d+)\.(\d+)', self.vs).groups()
self.vi = major.ljust(len(major)+1, '0')+minor.ljust(2, '0')
def __call__(self,f):
def f_new(*args,**kwargs):
raise NotImplementedError('CUFFT '+self.op_str+' '+self.vs+' required')
f_new.__doc__ = f.__doc__
if self.op(_cufft_version, int(self.vi)):
return f
else:
return f_new
# Data transformation types:
CUFFT_R2C = 0x2a
CUFFT_C2R = 0x2c
CUFFT_C2C = 0x29
CUFFT_D2Z = 0x6a
CUFFT_Z2D = 0x6c
CUFFT_Z2Z = 0x69
# Transformation directions:
CUFFT_FORWARD = -1
CUFFT_INVERSE = 1
# FFTW compatibility modes:
CUFFT_COMPATIBILITY_NATIVE = 0x00
CUFFT_COMPATIBILITY_FFTW_PADDING = 0x01
CUFFT_COMPATIBILITY_FFTW_ASYMMETRIC = 0x02
CUFFT_COMPATIBILITY_FFTW_ALL = 0x03
# FFT functions implemented by CUFFT:
_libcufft.cufftPlan1d.restype = int
_libcufft.cufftPlan1d.argtypes = [ctypes.c_void_p,
ctypes.c_int,
ctypes.c_int,
ctypes.c_int]
def cufftPlan1d(nx, fft_type, batch):
"""
Create 1D FFT plan configuration.
References
----------
`cufftPlan1d <http://docs.nvidia.com/cuda/cufft/#function-cufftplan1d>`_
"""
plan = _types.plan()
status = _libcufft.cufftPlan1d(ctypes.byref(plan), nx, fft_type, batch)
cufftCheckStatus(status)
return plan
_libcufft.cufftPlan2d.restype = int
_libcufft.cufftPlan2d.argtypes = [ctypes.c_void_p,
ctypes.c_int,
ctypes.c_int,
ctypes.c_int]
def cufftPlan2d(nx, ny, fft_type):
"""
Create 2D FFT plan configuration.
References
----------
`cufftPlan2d <http://docs.nvidia.com/cuda/cufft/#function-cufftplan2d>`_
"""
plan = _types.plan()
status = _libcufft.cufftPlan2d(ctypes.byref(plan), nx, ny,
fft_type)
cufftCheckStatus(status)
return plan
_libcufft.cufftPlan3d.restype = int
_libcufft.cufftPlan3d.argtypes = [ctypes.c_void_p,
ctypes.c_int,
ctypes.c_int,
ctypes.c_int,
ctypes.c_int]
def cufftPlan3d(nx, ny, nz, fft_type):
"""
Create 3D FFT plan configuration.
References
----------
`cufftPlan3d <http://docs.nvidia.com/cuda/cufft/#function-cufftplan3d>`_
"""
plan = _types.plan()
status = _libcufft.cufftPlan3d(ctypes.byref(plan), nx, ny, nz,
fft_type)
cufftCheckStatus(status)
return plan
_libcufft.cufftPlanMany.restype = int
_libcufft.cufftPlanMany.argtypes = [ctypes.c_void_p,
ctypes.c_int,
ctypes.c_void_p,
ctypes.c_void_p,
ctypes.c_int,
ctypes.c_int,
ctypes.c_void_p,
ctypes.c_int,
ctypes.c_int,
ctypes.c_int,
ctypes.c_int]
def cufftPlanMany(rank, n,
inembed, istride, idist,
onembed, ostride, odist, fft_type, batch):
"""
Create batched FFT plan configuration.
References
----------
`cufftPlanMany <http://docs.nvidia.com/cuda/cufft/#function-cufftplanmany>`_
"""
plan = _types.plan()
status = _libcufft.cufftPlanMany(ctypes.byref(plan), rank, n,
inembed, istride, idist,
onembed, ostride, odist,
fft_type, batch)
cufftCheckStatus(status)
return plan
_libcufft.cufftDestroy.restype = int
_libcufft.cufftDestroy.argtypes = [_types.plan]
def cufftDestroy(plan):
"""
Destroy FFT plan.
References
----------
`cufftDestroy <http://docs.nvidia.com/cuda/cufft/#function-cufftdestroy>`_
"""
status = _libcufft.cufftDestroy(plan)
cufftCheckStatus(status)
if _cufft_version <= 9010:
_libcufft.cufftSetCompatibilityMode.restype = int
_libcufft.cufftSetCompatibilityMode.argtypes = [_types.plan,
ctypes.c_int]
@_cufft_version_req(9.1, '<=')
def cufftSetCompatibilityMode(plan, mode):
"""
Set FFTW compatibility mode.
References
----------
`cufftSetCompatibilityMode <http://docs.nvidia.com/cuda/cufft/#function-cufftsetcompatibilitymode>`_
"""
status = _libcufft.cufftSetCompatibilityMode(plan, mode)
cufftCheckStatus(status)
_libcufft.cufftExecC2C.restype = int
_libcufft.cufftExecC2C.argtypes = [_types.plan,
ctypes.c_void_p,
ctypes.c_void_p,
ctypes.c_int]
def cufftExecC2C(plan, idata, odata, direction):
"""Execute single precision complex-to-complex transform plan as
specified by `direction`.
References
----------
`cufftExecC2C <http://docs.nvidia.com/cuda/cufft/#function-cufftexecc2c-cufftexecz2z>`_
"""
status = _libcufft.cufftExecC2C(plan, idata, odata,
direction)
cufftCheckStatus(status)
_libcufft.cufftExecR2C.restype = int
_libcufft.cufftExecR2C.argtypes = [_types.plan,
ctypes.c_void_p,
ctypes.c_void_p]
def cufftExecR2C(plan, idata, odata):
"""
Execute single precision real-to-complex forward transform plan.
References
----------
`cufftExecR2C <http://docs.nvidia.com/cuda/cufft/#function-cufftexecr2c-cufftexecd2z>`_
"""
status = _libcufft.cufftExecR2C(plan, idata, odata)
cufftCheckStatus(status)
_libcufft.cufftExecC2R.restype = int
_libcufft.cufftExecC2R.argtypes = [_types.plan,
ctypes.c_void_p,
ctypes.c_void_p]
def cufftExecC2R(plan, idata, odata):
"""
Execute single precision complex-to-real reverse transform plan.
References
----------
`cufftExecC2R <http://docs.nvidia.com/cuda/cufft/#function-cufftexecc2r-cufftexecz2d>`_
"""
status = _libcufft.cufftExecC2R(plan, idata, odata)
cufftCheckStatus(status)
_libcufft.cufftExecZ2Z.restype = int
_libcufft.cufftExecZ2Z.argtypes = [_types.plan,
ctypes.c_void_p,
ctypes.c_void_p,
ctypes.c_int]
def cufftExecZ2Z(plan, idata, odata, direction):
"""
Execute double precision complex-to-complex transform plan as
specified by `direction`.
References
----------
`cufftExecZ2Z <http://docs.nvidia.com/cuda/cufft/#function-cufftexecc2c-cufftexecz2z>`_
"""
status = _libcufft.cufftExecZ2Z(plan, idata, odata,
direction)
cufftCheckStatus(status)
_libcufft.cufftExecD2Z.restype = int
_libcufft.cufftExecD2Z.argtypes = [_types.plan,
ctypes.c_void_p,
ctypes.c_void_p]
def cufftExecD2Z(plan, idata, odata):
"""
Execute double precision real-to-complex forward transform plan.
References
----------
`cufftExecD2Z <http://docs.nvidia.com/cuda/cufft/#function-cufftexecr2c-cufftexecd2z>`_
"""
status = _libcufft.cufftExecD2Z(plan, idata, odata)
cufftCheckStatus(status)
_libcufft.cufftExecZ2D.restype = int
_libcufft.cufftExecZ2D.argtypes = [_types.plan,
ctypes.c_void_p,
ctypes.c_void_p]
def cufftExecZ2D(plan, idata, odata):
"""
Execute double precision complex-to-real transform plan.
References
----------
`cufftExecZ2D <http://docs.nvidia.com/cuda/cufft/#function-cufftexecc2r-cufftexecz2d>`_
"""
status = _libcufft.cufftExecZ2D(plan, idata, odata)
cufftCheckStatus(status)
_libcufft.cufftSetStream.restype = int
_libcufft.cufftSetStream.argtypes = [_types.plan,
_types.stream]
def cufftSetStream(plan, stream):
"""
Associate a CUDA stream with a CUFFT plan.
References
----------
`cufftSetStream <http://docs.nvidia.com/cuda/cufft/#function-cufftsetstream>`_
"""
status = _libcufft.cufftSetStream(plan, stream)
cufftCheckStatus(status)
_libcufft.cufftEstimate1d.restype = int
_libcufft.cufftEstimate1d.argtypes = [ctypes.c_int,
ctypes.c_int,
ctypes.c_int,
ctypes.c_void_p]
def cufftEstimate1d(nx, fft_type, batch=1):
"""
Return estimated work area for 1D FFT.
References
----------
`cufftEstimate1d <http://docs.nvidia.com/cuda/cufft/#function-cufftestimate1d>`_
"""
worksize = _types.worksize()
status = _libcufft.cufftEstimate1d(nx, fft_type, batch,
ctypes.byref(worksize))
cufftCheckStatus(status)
return worksize.value
_libcufft.cufftEstimate2d.restype = int
_libcufft.cufftEstimate2d.argtypes = [ctypes.c_int,
ctypes.c_int,
ctypes.c_int,
ctypes.c_void_p]
def cufftEstimate2d(nx, ny, fft_type):
"""
Return estimated work area for 2D FFT.
References
----------
`cufftEstimate2d <http://docs.nvidia.com/cuda/cufft/#function-cufftestimate2d>`_
"""
worksize = _types.worksize()
status = _libcufft.cufftEstimate2d(nx, ny, fft_type,
ctypes.byref(worksize))
cufftCheckStatus(status)
return worksize.value
_libcufft.cufftEstimate3d.restype = int
_libcufft.cufftEstimate3d.argtypes = [ctypes.c_int,
ctypes.c_int,
ctypes.c_int,
ctypes.c_int,
ctypes.c_void_p]
def cufftEstimate3d(nx, ny, nz, fft_type):
"""
Return estimated work area for 3D FFT.
References
----------
`cufftEstimate3d <http://docs.nvidia.com/cuda/cufft/#function-cufftestimate3d>`_
"""
worksize = _types.worksize()
status = _libcufft.cufftEstimate3d(nx, ny, nz, fft_type,
ctypes.byref(worksize))
cufftCheckStatus(status)
return worksize.value
_libcufft.cufftEstimateMany.restype = int
_libcufft.cufftEstimateMany.argtypes = [ctypes.c_int,
ctypes.c_void_p,
ctypes.c_void_p,
ctypes.c_int,
ctypes.c_int,
ctypes.c_void_p,
ctypes.c_int,
ctypes.c_int,
ctypes.c_int,
ctypes.c_int,
ctypes.c_void_p]
def cufftEstimateMany(rank, n,
inembed, istride, idist,
onembed, ostride, odist, fft_type, batch):
"""
Return estimated work area for batched FFT.
References
----------
`cufftEstimateMany <http://docs.nvidia.com/cuda/cufft/#function-cufftestimatemany>`_
"""
worksize = _types.worksize()
status = _libcufft.cufftEstimateMany(rank, n,
inembed, istride, idist,
onembed, ostride, odist,
fft_type, batch,
ctypes.byref(worksize))
cufftCheckStatus(status)
return worksize.value
_libcufft.cufftGetSize1d.restype = int
_libcufft.cufftGetSize1d.argtypes = [_types.plan,
ctypes.c_int,
ctypes.c_int,
ctypes.c_int,
ctypes.c_void_p]
def cufftGetSize1d(plan, nx, fft_type, batch=1):
"""
Return more accurate estimate of work area size required for 1D FFT,
taking into account any plan settings that may have been made.
References
----------
`cufftGetSize1d <http://docs.nvidia.com/cuda/cufft/#function-cufftgetsize1d>`_
"""
worksize = _types.worksize()
status = _libcufft.cufftGetSize1d(plan, nx, fft_type, batch,
ctypes.byref(worksize))
cufftCheckStatus(status)
return worksize.value
_libcufft.cufftGetSize2d.restype = int
_libcufft.cufftGetSize2d.argtypes = [_types.plan,
ctypes.c_int,
ctypes.c_int,
ctypes.c_int,
ctypes.c_void_p]
def cufftGetSize2d(plan, nx, ny, fft_type):
"""
Return more accurate estimate of work area size required for 2D FFT,
taking into account any plan settings that may have been made.
References
----------
`cufftGetSize2d <http://docs.nvidia.com/cuda/cufft/#function-cufftgetsize2d>`_
"""
worksize = _types.worksize()
status = _libcufft.cufftGetSize2d(plan, nx, ny, fft_type,
ctypes.byref(worksize))
cufftCheckStatus(status)
return worksize.value
_libcufft.cufftGetSize3d.restype = int
_libcufft.cufftGetSize3d.argtypes = [_types.plan,
ctypes.c_int,
ctypes.c_int,
ctypes.c_int,
ctypes.c_int,
ctypes.c_void_p]
def cufftGetSize3d(plan, nx, ny, nz, fft_type):
"""
Return more accurate estimate of work area size required for 3D FFT,
taking into account any plan settings that may have been made.
References
----------
`cufftGetSize3d <http://docs.nvidia.com/cuda/cufft/#function-cufftgetsize3d>`_
"""
worksize = _types.worksize()
status = _libcufft.cufftGetSize3d(plan, nx, ny, nz, fft_type,
ctypes.byref(worksize))
cufftCheckStatus(status)
return worksize.value
_libcufft.cufftGetSizeMany.restype = int
_libcufft.cufftGetSizeMany.argtypes = [_types.plan,
ctypes.c_int,
ctypes.c_void_p,
ctypes.c_void_p,
ctypes.c_int,
ctypes.c_int,
ctypes.c_void_p,
ctypes.c_int,
ctypes.c_int,
ctypes.c_int,
ctypes.c_int,
ctypes.c_void_p]
def cufftGetSizeMany(plan, rank, n,
inembed, istride, idist,
onembed, ostride, odist, fft_type, batch):
"""
Return more accurate estimate of work area size required for batched FFT,
taking into account any plan settings that may have been made.
References
----------
`cufftGetSizeMany <http://docs.nvidia.com/cuda/cufft/#function-cufftgetsizemany>`_
"""
worksize = _types.worksize()
status = _libcufft.cufftGetSizeMany(plan, rank, n,
inembed, istride, idist,
onembed, ostride, odist,
fft_type, batch,
ctypes.byref(worksize))
cufftCheckStatus(status)
return worksize.value
_libcufft.cufftGetSize.restype = int
_libcufft.cufftGetSize.argtypes = [_types.plan,
ctypes.c_void_p]
def cufftGetSize(plan):
"""
Return actual size of work area for FFT described in plan.
References
----------
`cufftGetSize <http://docs.nvidia.com/cuda/cufft/#function-cufftgetsize>`_
"""
worksize = _types.worksize()
status = _libcufft.cufftGetSize(plan, ctypes.byref(worksize))
cufftCheckStatus(status)
return worksize.value
_libcufft.cufftCreate.restype = int
_libcufft.cufftCreate.argtypes = [ctypes.c_void_p]
def cufftCreate():
"""
Create FFT plan handle.
References
----------
`cufftCreate <http://docs.nvidia.com/cuda/cufft/#function-cufftcreate>`_
"""
plan = _types.plan()
status = _libcufft.cufftCreate(ctypes.byref(plan))
cufftCheckStatus(status)
return plan
_libcufft.cufftMakePlan1d.restype = int
_libcufft.cufftMakePlan1d.argtypes = [_types.plan,
ctypes.c_int,
ctypes.c_int,
ctypes.c_int,
ctypes.c_void_p]
def cufftMakePlan1d(plan, nx, fft_type, batch):
"""
Create 1D FFT plan configuration.
References
----------
`cufftMakePlan1d <http://docs.nvidia.com/cuda/cufft/#function-cufftmakeplan1d>`_
"""
worksize = _types.worksize()
status = _libcufft.cufftMakePlan1d(plan, nx, fft_type, batch,
ctypes.byref(worksize))
cufftCheckStatus(status)
return worksize.value
_libcufft.cufftMakePlan2d.restype = int
_libcufft.cufftMakePlan2d.argtypes = [_types.plan,
ctypes.c_int,
ctypes.c_int,
ctypes.c_int,
ctypes.c_void_p]
def cufftMakePlan2d(plan, nx, ny, fft_type):
"""
Create 2D FFT plan configuration.
References
----------
`cufftMakePlan2d <http://docs.nvidia.com/cuda/cufft/#function-cufftmakeplan2d>`_
"""
worksize = _types.worksize()
status = _libcufft.cufftMakePlan2d(plan, nx, ny, fft_type,
ctypes.byref(worksize))
cufftCheckStatus(status)
return worksize.value
_libcufft.cufftMakePlan3d.restype = int
_libcufft.cufftMakePlan3d.argtypes = [_types.plan,
ctypes.c_int,
ctypes.c_int,
ctypes.c_int,
ctypes.c_int,
ctypes.c_void_p]
def cufftMakePlan3d(plan, nx, ny, nz, fft_type):
"""
Create 3D FFT plan configuration.
References
----------
`cufftMakePlan3d <http://docs.nvidia.com/cuda/cufft/#function-cufftmakeplan3d>`_
"""
worksize = _types.worksize()
status = _libcufft.cufftMakePlan3d(plan, nx, ny, nz, fft_type,
ctypes.byref(worksize))
cufftCheckStatus(status)
return worksize.value
_libcufft.cufftMakePlanMany.restype = int
_libcufft.cufftMakePlanMany.argtypes = [_types.plan,
ctypes.c_int,
ctypes.c_void_p,
ctypes.c_void_p,
ctypes.c_int,
ctypes.c_int,
ctypes.c_void_p,
ctypes.c_int,
ctypes.c_int,
ctypes.c_int,
ctypes.c_int,
ctypes.c_void_p]
def cufftMakePlanMany(plan, rank, n,
inembed, istride, idist,
onembed, ostride, odist, fft_type, batch):
"""
Create batched FFT plan configuration.
References
----------
`cufftMakePlanMany <http://docs.nvidia.com/cuda/cufft/#function-cufftmakeplanmany>`_
"""
worksize = _types.worksize()
status = _libcufft.cufftMakePlanMany(plan, rank, n,
inembed, istride, idist,
onembed, ostride, odist,
fft_type, batch,
ctypes.byref(worksize))
cufftCheckStatus(status)
return worksize.value
_libcufft.cufftSetAutoAllocation.restype = int
_libcufft.cufftSetAutoAllocation.argtypes = [_types.plan,
ctypes.c_int]
def cufftSetAutoAllocation(plan, auto_allocate):
"""
Indicate whether the caller intends to allocate and manage work areas for
plans that have been generated.
References
----------
`cufftSetAutoAllocation <http://docs.nvidia.com/cuda/cufft/#function-cufftsetautoallocation>`_
"""
status = _libcufft.cufftSetAutoAllocation(plan, auto_allocate)
cufftCheckStatus(status)
_libcufft.cufftSetWorkArea.restype = int
_libcufft.cufftSetWorkArea.argtypes = [_types.plan,
ctypes.c_void_p]
def cufftSetWorkArea(plan, work_area):
"""
Override the work area pointer associated with a plan.
References
----------
`cufftSetworkArea <http://docs.nvidia.com/cuda/cufft/#function-cufftsetworkarea>`_
"""
status = _libcufft.cufftSetWorkArea(plan, work_area)
cufftCheckStatus(status)
|