RuntimeAttributes

RuntimeAttributes

is an option for Compile that specifies attributes for the compiled function it creates.

Details

  • RuntimeAttributes applies to the execution of the compiled function.
  • A possible setting for RuntimeAttributes is Listable.
  • RuntimeAttributes->Listable is effectively equivalent to the Listable attribute of the built-in function.
  • If a compiled function with Listable attribute matches its argument specification, it will run in the normal way.
  • If a compiled function with Listable attribute receives any arguments with higher rank than specified, the function will thread over these arguments.

Examples

Basic Examples  (3)

This creates a compiled function that is listable:

It operates on a single input in normal fashion:

When the arguments include a list that does not match the input specification, it threads the function over that argument:

This compiled function is not listable:

An error results when the argument specification does not match:

If there is a branch, listability needs a function to be defined, as shown below using Function:

A listable compiled function does the same thing much faster:

A listable compiled function can run in parallel, giving an acceleration on multicore machines:

Wolfram Research (2010), RuntimeAttributes, Wolfram Language function, https://reference.wolfram.com/language/ref/RuntimeAttributes.html.

Text

Wolfram Research (2010), RuntimeAttributes, Wolfram Language function, https://reference.wolfram.com/language/ref/RuntimeAttributes.html.

CMS

Wolfram Language. 2010. "RuntimeAttributes." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/RuntimeAttributes.html.

APA

Wolfram Language. (2010). RuntimeAttributes. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RuntimeAttributes.html

BibTeX

@misc{reference.wolfram_2024_runtimeattributes, author="Wolfram Research", title="{RuntimeAttributes}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/RuntimeAttributes.html}", note=[Accessed: 21-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_runtimeattributes, organization={Wolfram Research}, title={RuntimeAttributes}, year={2010}, url={https://reference.wolfram.com/language/ref/RuntimeAttributes.html}, note=[Accessed: 21-November-2024 ]}