Path: blob/master/jcl/src/openj9.cuda/share/classes/com/ibm/cuda/CudaDevice.java
12927 views
/*[INCLUDE-IF Sidecar18-SE]*/1/*******************************************************************************2* Copyright (c) 2013, 2021 IBM Corp. and others3*4* This program and the accompanying materials are made available under5* the terms of the Eclipse Public License 2.0 which accompanies this6* distribution and is available at https://www.eclipse.org/legal/epl-2.0/7* or the Apache License, Version 2.0 which accompanies this distribution and8* is available at https://www.apache.org/licenses/LICENSE-2.0.9*10* This Source Code may also be made available under the following11* Secondary Licenses when the conditions for such availability set12* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU13* General Public License, version 2 with the GNU Classpath14* Exception [1] and GNU General Public License, version 2 with the15* OpenJDK Assembly Exception [2].16*17* [1] https://www.gnu.org/software/classpath/license.html18* [2] http://openjdk.java.net/legal/assembly-exception.html19*20* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception21*******************************************************************************/22package com.ibm.cuda;2324import java.util.Objects;2526/**27* The {@code CudaDevice} class represents a CUDA-capable device.28*/29public final class CudaDevice {3031/**32* {@code CacheConfig} identifies the cache configuration choices for33* a device.34*/35public static enum CacheConfig {3637/** prefer equal sized L1 cache and shared memory */38PREFER_EQUAL(0),3940/** prefer larger L1 cache and smaller shared memory */41PREFER_L1(1),4243/** no preference for shared memory or L1 (default) */44PREFER_NONE(2),4546/** prefer larger shared memory and smaller L1 cache */47PREFER_SHARED(3);4849final int nativeValue;5051CacheConfig(int value) {52this.nativeValue = value;53}54}5556/**57* {@code Limit} identifies device limits that may be queried or configured.58*/59public static enum Limit {6061/** maximum number of outstanding device runtime launches that can be made from this context */62DEV_RUNTIME_PENDING_LAUNCH_COUNT(0),6364/** maximum grid depth at which a thread can issue the device runtime call ::cudaDeviceSynchronize() to wait on child grid launches to complete */65DEV_RUNTIME_SYNC_DEPTH(1),6667/** size in bytes of the heap used by the ::malloc() and ::free() device system calls */68MALLOC_HEAP_SIZE(2),6970/** size in bytes of the FIFO used by the ::printf() device system call */71PRINTF_FIFO_SIZE(3),7273/** stack size in bytes of each GPU thread */74STACK_SIZE(4);7576final int nativeValue;7778private Limit(int value) {79this.nativeValue = value;80}81}8283public static enum SharedMemConfig {8485/**86* default shared memory bank size87*/88DEFAULT_BANK_SIZE(0),8990/**91* eight byte shared memory bank width92*/93EIGHT_BYTE_BANK_SIZE(2),9495/**96* four byte shared memory bank width97*/98FOUR_BYTE_BANK_SIZE(1);99100final int nativeValue;101102SharedMemConfig(int value) {103this.nativeValue = value;104}105}106107/** Number of asynchronous engines. */108public static final int ATTRIBUTE_ASYNC_ENGINE_COUNT = 40;109110/** Device can map host memory into CUDA address space. */111public static final int ATTRIBUTE_CAN_MAP_HOST_MEMORY = 19;112113/** Typical clock frequency in kilohertz. */114public static final int ATTRIBUTE_CLOCK_RATE = 13;115116/**117* Compute capability version number. This value is the major compute118* capability version * 10 + the minor compute capability version, so119* a compute capability version 3.5 function would return the value 35.120*/121public static final int ATTRIBUTE_COMPUTE_CAPABILITY = -1;122123/** Major compute capability version number. */124public static final int ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR = 75;125126/** Minor compute capability version number. */127public static final int ATTRIBUTE_COMPUTE_CAPABILITY_MINOR = 76;128129/** Compute mode (see COMPUTE_MODE_XXX for details). */130public static final int ATTRIBUTE_COMPUTE_MODE = 20;131132/** Device can possibly execute multiple kernels concurrently. */133public static final int ATTRIBUTE_CONCURRENT_KERNELS = 31;134135/** Device has ECC support enabled. */136public static final int ATTRIBUTE_ECC_ENABLED = 32;137138/** Global memory bus width in bits. */139public static final int ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH = 37;140141/** Device is integrated with host memory. */142public static final int ATTRIBUTE_INTEGRATED = 18;143144/** Specifies whether there is a run time limit on kernels. */145public static final int ATTRIBUTE_KERNEL_EXEC_TIMEOUT = 17;146147/** Size of L2 cache in bytes. */148public static final int ATTRIBUTE_L2_CACHE_SIZE = 38;149150/** Maximum block dimension X. */151public static final int ATTRIBUTE_MAX_BLOCK_DIM_X = 2;152153/** Maximum block dimension Y. */154public static final int ATTRIBUTE_MAX_BLOCK_DIM_Y = 3;155156/** Maximum block dimension Z. */157public static final int ATTRIBUTE_MAX_BLOCK_DIM_Z = 4;158159/** Maximum grid dimension X. */160public static final int ATTRIBUTE_MAX_GRID_DIM_X = 5;161162/** Maximum grid dimension Y. */163public static final int ATTRIBUTE_MAX_GRID_DIM_Y = 6;164165/** Maximum grid dimension Z. */166public static final int ATTRIBUTE_MAX_GRID_DIM_Z = 7;167168/** Maximum pitch in bytes allowed by memory copies. */169public static final int ATTRIBUTE_MAX_PITCH = 11;170171/** Maximum number of 32-bit registers available per block. */172public static final int ATTRIBUTE_MAX_REGISTERS_PER_BLOCK = 12;173174/** Maximum shared memory available per block in bytes. */175public static final int ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK = 8;176177/** Maximum number of threads per block. */178public static final int ATTRIBUTE_MAX_THREADS_PER_BLOCK = 1;179180/** Maximum resident threads per multiprocessor. */181public static final int ATTRIBUTE_MAX_THREADS_PER_MULTIPROCESSOR = 39;182183/** Maximum layers in a 1D layered surface. */184public static final int ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_LAYERS = 62;185186/** Maximum 1D layered surface width. */187public static final int ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_WIDTH = 61;188189/** Maximum 1D surface width. */190public static final int ATTRIBUTE_MAXIMUM_SURFACE1D_WIDTH = 55;191192/** Maximum 2D surface height. */193public static final int ATTRIBUTE_MAXIMUM_SURFACE2D_HEIGHT = 57;194195/** Maximum 2D layered surface height. */196public static final int ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_HEIGHT = 64;197198/** Maximum layers in a 2D layered surface. */199public static final int ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_LAYERS = 65;200201/** Maximum 2D layered surface width. */202public static final int ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_WIDTH = 63;203204/** Maximum 2D surface width. */205public static final int ATTRIBUTE_MAXIMUM_SURFACE2D_WIDTH = 56;206207/** Maximum 3D surface depth. */208public static final int ATTRIBUTE_MAXIMUM_SURFACE3D_DEPTH = 60;209210/** Maximum 3D surface height. */211public static final int ATTRIBUTE_MAXIMUM_SURFACE3D_HEIGHT = 59;212213/** Maximum 3D surface width. */214public static final int ATTRIBUTE_MAXIMUM_SURFACE3D_WIDTH = 58;215216/** Maximum layers in a cubemap layered surface. */217public static final int ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_LAYERS = 68;218219/** Maximum cubemap layered surface width. */220public static final int ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_WIDTH = 67;221222/** Maximum cubemap surface width. */223public static final int ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_WIDTH = 66;224225/** Maximum layers in a 1D layered texture. */226public static final int ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_LAYERS = 43;227228/** Maximum 1D layered texture width. */229public static final int ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_WIDTH = 42;230231/** Maximum 1D linear texture width. */232public static final int ATTRIBUTE_MAXIMUM_TEXTURE1D_LINEAR_WIDTH = 69;233234/** Maximum mipmapped 1D texture width. */235public static final int ATTRIBUTE_MAXIMUM_TEXTURE1D_MIPMAPPED_WIDTH = 77;236237/** Maximum 1D texture width. */238public static final int ATTRIBUTE_MAXIMUM_TEXTURE1D_WIDTH = 21;239240/** Maximum 2D texture height if CUDA_ARRAY3D_TEXTURE_GATHER is set. */241public static final int ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_HEIGHT = 46;242243/** Maximum 2D texture width if CUDA_ARRAY3D_TEXTURE_GATHER is set. */244public static final int ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_WIDTH = 45;245246/** Maximum 2D texture height. */247public static final int ATTRIBUTE_MAXIMUM_TEXTURE2D_HEIGHT = 23;248249/** Maximum 2D layered texture height. */250public static final int ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_HEIGHT = 28;251252/** Maximum layers in a 2D layered texture. */253public static final int ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_LAYERS = 29;254255/** Maximum 2D layered texture width. */256public static final int ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_WIDTH = 27;257258/** Maximum 2D linear texture height. */259public static final int ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_HEIGHT = 71;260261/** Maximum 2D linear texture pitch in bytes. */262public static final int ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_PITCH = 72;263264/** Maximum 2D linear texture width. */265public static final int ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_WIDTH = 70;266267/** Maximum mipmapped 2D texture height. */268public static final int ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_HEIGHT = 74;269270/** Maximum mipmapped 2D texture width. */271public static final int ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_WIDTH = 73;272273/** Maximum 2D texture width. */274public static final int ATTRIBUTE_MAXIMUM_TEXTURE2D_WIDTH = 22;275276/** Maximum 3D texture depth. */277public static final int ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH = 26;278279/** Alternate maximum 3D texture depth. */280public static final int ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH_ALTERNATE = 49;281282/** Maximum 3D texture height. */283public static final int ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT = 25;284285/** Alternate maximum 3D texture height. */286public static final int ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT_ALTERNATE = 48;287288/** Maximum 3D texture width. */289public static final int ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH = 24;290291/** Alternate maximum 3D texture width. */292public static final int ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH_ALTERNATE = 47;293294/** Maximum layers in a cubemap layered texture. */295public static final int ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_LAYERS = 54;296297/** Maximum cubemap layered texture width/height. */298public static final int ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_WIDTH = 53;299300/** Maximum cubemap texture width/height. */301public static final int ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_WIDTH = 52;302303/** Peak memory clock frequency in kilohertz. */304public static final int ATTRIBUTE_MEMORY_CLOCK_RATE = 36;305306/** Number of multiprocessors on device. */307public static final int ATTRIBUTE_MULTIPROCESSOR_COUNT = 16;308309/** PCI bus ID of the device. */310public static final int ATTRIBUTE_PCI_BUS_ID = 33;311312/** PCI device ID of the device. */313public static final int ATTRIBUTE_PCI_DEVICE_ID = 34;314315/** PCI domain ID of the device. */316public static final int ATTRIBUTE_PCI_DOMAIN_ID = 50;317318/** Device supports stream priorities. */319public static final int ATTRIBUTE_STREAM_PRIORITIES_SUPPORTED = 78;320321/** Alignment requirement for surfaces. */322public static final int ATTRIBUTE_SURFACE_ALIGNMENT = 30;323324/** Device is using TCC driver model. */325public static final int ATTRIBUTE_TCC_DRIVER = 35;326327/** Alignment requirement for textures. */328public static final int ATTRIBUTE_TEXTURE_ALIGNMENT = 14;329330/** Pitch alignment requirement for textures. */331public static final int ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT = 51;332333/** Memory available on device for __constant__ variables in a kernel in bytes. */334public static final int ATTRIBUTE_TOTAL_CONSTANT_MEMORY = 9;335336/** Device shares a unified address space with the host. */337public static final int ATTRIBUTE_UNIFIED_ADDRESSING = 41;338339/** Warp size in threads. */340public static final int ATTRIBUTE_WARP_SIZE = 10;341342/** Default compute mode (multiple contexts allowed per device). */343public static final int COMPUTE_MODE_DEFAULT = 0;344345/**346* Compute exclusive process mode (at most one context used by a single process347* can be present on this device at a time).348*/349public static final int COMPUTE_MODE_PROCESS_EXCLUSIVE = 3;350351/** Compute prohibited mode (no contexts can be created on this device at this time). */352public static final int COMPUTE_MODE_PROHIBITED = 2;353354/**355* Exclusive thread mode (at most one context, used by a single thread,356* can be present on this device at a time).357*/358public static final int COMPUTE_MODE_THREAD_EXCLUSIVE = 1;359360/** Keep local memory allocation after launch. */361public static final int FLAG_LMEM_RESIZE_TO_MAX = 0x10;362363/** Support mapped pinned allocations. */364public static final int FLAG_MAP_HOST = 0x08;365366/** Automatic scheduling. */367public static final int FLAG_SCHED_AUTO = 0x00;368369/** Set blocking synchronization as default scheduling. */370public static final int FLAG_SCHED_BLOCKING_SYNC = 0x04;371372/** Set spin as default scheduling. */373public static final int FLAG_SCHED_SPIN = 0x01;374375/** Set yield as default scheduling. */376public static final int FLAG_SCHED_YIELD = 0x02;377378public static final int MASK_SCHED = 0x07;379380static native void addCallback(int deviceId, long streamHandle,381Runnable callback) throws CudaException;382383private static native boolean canAccessPeer(int deviceId, int peerDeviceId)384throws CudaException;385386private static native void disablePeerAccess(int deviceId, int peerDeviceId)387throws CudaException;388389private static native void enablePeerAccess(int deviceId, int peerDeviceId)390throws CudaException;391392private static native int getAttribute(int deviceId, int attribute)393throws CudaException;394395private static native int getCacheConfig(int deviceId) throws CudaException;396397/**398* Returns the number of CUDA-capable devices available to the Java host.399*400* @return the number of available CUDA-capable devices401* @throws CudaException402* if a CUDA exception occurs403*/404public static int getCount() throws CudaException {405return Cuda.getDeviceCount();406}407408/**409* Returns a number identifying the driver version.410*411* @return412* the driver version number413* @throws CudaException414* if a CUDA exception occurs415* @deprecated416* Use Cuda.getDriverVersion() instead.417*/418@Deprecated419public static int getDriverVersion() throws CudaException {420return Cuda.getDriverVersion();421}422423private static native long getFreeMemory(int deviceId) throws CudaException;424425private static native int getGreatestStreamPriority(int deviceId)426throws CudaException;427428private static native int getLeastStreamPriority(int deviceId)429throws CudaException;430431private static native long getLimit(int deviceId, int limit)432throws CudaException;433434private static native String getName(int deviceId) throws CudaException;435436/**437* Returns a number identifying the runtime version.438*439* @return440* the runtime version number441* @throws CudaException442* if a CUDA exception occurs443* @deprecated444* Use Cuda.getRuntimeVersion() instead.445*/446@Deprecated447public static int getRuntimeVersion() throws CudaException {448return Cuda.getRuntimeVersion();449}450451private static native int getSharedMemConfig(int deviceId)452throws CudaException;453454private static native long getTotalMemory(int deviceId)455throws CudaException;456457private static native void setCacheConfig(int deviceId, int config)458throws CudaException;459460private static native void setLimit(int deviceId, int limit, long value)461throws CudaException;462463private static native void setSharedMemConfig(int deviceId, int config)464throws CudaException;465466private static native void synchronize(int deviceId) throws CudaException;467468private final int deviceId;469470/**471* Creates a device handle corresponding to {@code deviceId}.472* <p>473* No checking is done on {@code deviceId}, but it must be non-negative474* and less than the value returned {@link #getCount()} to be useful.475*476* @param deviceId477* an integer identifying the device of interest478*/479public CudaDevice(int deviceId) {480super();481this.deviceId = deviceId;482Cuda.loadNatives();483}484485/**486* Queues the given {@code callback} to be executed when the associated487* device has completed all previous actions in the default stream.488*489* @param callback490* code to run491* @throws CudaException492* if a CUDA exception occurs493*/494public void addCallback(Runnable callback) throws CudaException {495Objects.requireNonNull(callback);496addCallback(deviceId, 0, callback);497}498499/**500* Returns whether this device can access memory of the specified501* {@code peerDevice}.502*503* @param peerDevice504* the peer device505* @return506* true if this device can access memory of {@code peerDevice},507* false otherwise508* @throws CudaException509* if a CUDA exception occurs510*/511public boolean canAccessPeer(CudaDevice peerDevice) throws CudaException {512return canAccessPeer(deviceId, peerDevice.deviceId);513}514515/**516* Disable access to memory of {@code peerDevice} by this device.517*518* @param peerDevice519* the peer device520* @throws CudaException521* if a CUDA exception occurs522* @throws SecurityException523* if a security manager exists and the calling thread524* does not have permission to disable peer access525*/526public void disablePeerAccess(CudaDevice peerDevice) throws CudaException {527@SuppressWarnings("removal")528SecurityManager security = System.getSecurityManager();529530if (security != null) {531security.checkPermission(CudaPermission.DisablePeerAccess);532}533534disablePeerAccess(deviceId, peerDevice.deviceId);535}536537/**538* Enable access to memory of {@code peerDevice} by this device.539*540* @param peerDevice541* the peer device542* @throws CudaException543* if a CUDA exception occurs544* @throws SecurityException545* if a security manager exists and the calling thread546* does not have permission to enable peer access547*/548public void enablePeerAccess(CudaDevice peerDevice) throws CudaException {549@SuppressWarnings("removal")550SecurityManager security = System.getSecurityManager();551552if (security != null) {553security.checkPermission(CudaPermission.EnablePeerAccess);554}555556enablePeerAccess(deviceId, peerDevice.deviceId);557}558559/**560* Does the argument represent the same device as this?561*/562@Override563public boolean equals(Object other) {564if (this == other) {565return true;566}567568if (other instanceof CudaDevice) {569CudaDevice that = (CudaDevice) other;570571if (this.deviceId == that.deviceId) {572return true;573}574}575576return false;577}578579/**580* Returns the value of the specified {@code attribute}.581*582* @param attribute583* the attribute to be queried (see ATTRIBUTE_XXX)584* @return585* the attribute value586* @throws CudaException587* if a CUDA exception occurs588*/589public int getAttribute(int attribute) throws CudaException {590return getAttribute(deviceId, attribute);591}592593/**594* Returns the current cache configuration of this device.595*596* @return597* the current cache configuration598* @throws CudaException599* if a CUDA exception occurs600*/601public CacheConfig getCacheConfig() throws CudaException {602switch (getCacheConfig(deviceId)) {603default:604case 0:605return CacheConfig.PREFER_NONE;606case 1:607return CacheConfig.PREFER_SHARED;608case 2:609return CacheConfig.PREFER_L1;610case 3:611return CacheConfig.PREFER_EQUAL;612}613}614615/**616* Returns an integer identifying this device (the value provided when617* this object was constructed).618*619* @return an integer identifying this device620*/621public int getDeviceId() {622return deviceId;623}624625/**626* Returns the amount of free device memory in bytes.627*628* @return629* the number of bytes of free device memory630* @throws CudaException631* if a CUDA exception occurs632*/633public long getFreeMemory() throws CudaException {634return getFreeMemory(deviceId);635}636637/**638* Returns the greatest possible priority of a stream on this device.639* Note that stream priorities follow a convention where lower numbers imply640* greater priorities.641*642* @return643* the greatest possible priority of a stream on this device644* @throws CudaException645* if a CUDA exception occurs646*/647public int getGreatestStreamPriority() throws CudaException {648return getGreatestStreamPriority(deviceId);649}650651/**652* Returns the least possible priority of a stream on this device.653* Note that stream priorities follow a convention where lower numbers imply654* greater priorities.655*656* @return657* the greatest possible priority of a stream on this device658* @throws CudaException659* if a CUDA exception occurs660*/661public int getLeastStreamPriority() throws CudaException {662return getLeastStreamPriority(deviceId);663}664665/**666* Returns the value of the specified {@code limit}.667*668* @param limit669* the limit to be queried670* @return671* the value of the specified limit672* @throws CudaException673* if a CUDA exception occurs674*/675public long getLimit(Limit limit) throws CudaException {676return getLimit(deviceId, limit.nativeValue);677}678679/**680* Returns the name of this device.681*682* @return683* the name of this device684* @throws CudaException685* if a CUDA exception occurs686*/687public String getName() throws CudaException {688return getName(deviceId);689}690691/**692* Returns the current shared memory configuration of this device.693*694* @return695* the current shared memory configuration696* @throws CudaException697* if a CUDA exception occurs698*/699public SharedMemConfig getSharedMemConfig() throws CudaException {700switch (getSharedMemConfig(deviceId)) {701default:702case 0:703return SharedMemConfig.DEFAULT_BANK_SIZE;704case 1:705return SharedMemConfig.FOUR_BYTE_BANK_SIZE;706case 2:707return SharedMemConfig.EIGHT_BYTE_BANK_SIZE;708}709}710711/**712* Returns the total amount of memory on this device in bytes.713*714* @return715* the number of bytes of device memory716* @throws CudaException717* if a CUDA exception occurs718*/719public long getTotalMemory() throws CudaException {720return getTotalMemory(deviceId);721}722723@Override724public int hashCode() {725return deviceId;726}727728/**729* Configures the cache of this device.730*731* @param config732* the desired cache configuration733* @throws CudaException734* if a CUDA exception occurs735* @throws SecurityException736* if a security manager exists and the calling thread737* does not have permission to set device cache configurations738*/739public void setCacheConfig(CacheConfig config) throws CudaException {740@SuppressWarnings("removal")741SecurityManager security = System.getSecurityManager();742743if (security != null) {744security.checkPermission(CudaPermission.SetCacheConfig);745}746747setCacheConfig(deviceId, config.nativeValue);748}749750/**751* Configures the specified {@code limit}.752*753* @param limit754* the limit to be configured755* @param value756* the desired limit value757* @throws CudaException758* if a CUDA exception occurs759* @throws SecurityException760* if a security manager exists and the calling thread761* does not have permission to set device limits762*/763public void setLimit(Limit limit, long value) throws CudaException {764@SuppressWarnings("removal")765SecurityManager security = System.getSecurityManager();766767if (security != null) {768security.checkPermission(CudaPermission.SetLimit);769}770771setLimit(deviceId, limit.nativeValue, value);772}773774/**775* Configures the shared memory of this device.776*777* @param config778* the desired shared memory configuration779* @throws CudaException780* if a CUDA exception occurs781* @throws SecurityException782* if a security manager exists and the calling thread does783* not have permission to set device shared memory configurations784*/785public void setSharedMemConfig(SharedMemConfig config) throws CudaException {786@SuppressWarnings("removal")787SecurityManager security = System.getSecurityManager();788789if (security != null) {790security.checkPermission(CudaPermission.SetSharedMemConfig);791}792793setSharedMemConfig(deviceId, config.nativeValue);794}795796/**797* Synchronizes on this device. This method blocks until the associated798* device has completed all previous actions in the default stream.799*800* @throws CudaException801* if a CUDA exception occurs802*/803public void synchronize() throws CudaException {804synchronize(deviceId);805}806}807808809