Lines Matching refs:kernel

202 /* Structure describing the run-time and grid properties of an HSA kernel
215 /* Collection of information needed for a dispatch of a kernel from a
216 kernel. */
221 /* Pointer to a command queue associated with a kernel dispatch agent. */
223 /* Pointer to a memory space used for kernel arguments passing. */
241 /* Leave space for the real kernel arguments.
278 struct kernel_info *kernel;
365 /* Mkoffload uses this structure to describe a kernel.
367 OpenMP kernel dimensions are passed at runtime.
368 OpenACC kernel dimensions are passed at compile time, here. */
438 /* The HSA memory region from which to allocate kernel arguments. */
450 locked for reading while a kernel is being run, and for writing if the
454 /* The module associated with this kernel. */
468 /* Information required to identify, finalize and run any given kernel. */
474 /* Name of the kernel, required to locate it within the GCN object-code
477 /* The specific agent the kernel has been or will be finalized for and run
480 /* The specific module where the kernel takes place. */
482 /* Information provided by mkoffload associated with the kernel. */
484 /* Mutex enforcing that at most once thread ever initializes a kernel for
488 /* Flag indicating whether the kernel has been initialized and all fields
491 /* Flag indicating that the kernel has a problem that blocks an execution. */
495 /* Required size of kernel arguments. */
522 /* An array of kernel_info structures describing each kernel in this
539 The mutex is locked until the kernel exits. */
1027 /* Dump kernel DISPATCH data structure and indent it by INDENT spaces. */
1189 This depends on the kernel's resource usage levels. */
1697 The arena is released, but not deallocated, when the kernel exits. */
1750 hsa_fatal ("Could not allocate memory for GCN kernel arena", status);
1810 kernargs for kernels that have no inputs or outputs (the kernel may
1864 /* Create kernel dispatch data structure for given KERNEL, along with
1868 create_kernel_dispatch (struct kernel_info *kernel, int num_teams)
1870 struct agent_info *agent = kernel->agent;
1874 shadow->agent = kernel->agent;
1875 shadow->object = kernel->object;
1883 shadow->private_segment_size = kernel->private_segment_size;
1884 shadow->group_segment_size = kernel->group_segment_size;
1889 if (kernel->kernarg_segment_size > 8)
1899 hsa_fatal ("Could not allocate memory for GCN kernel arguments", status);
1913 kernargs->heap_ptr = (int64_t)kernel->module->heap;
1916 if (kernel->kind == KIND_OPENMP)
1927 /* Output any data written to console output from the kernel. It is expected
1928 that this function is polled during kernel execution.
1939 console_output (struct kernel_info *kernel, struct kernargs *kernargs,
1980 /* Release data structure created for a kernel dispatch in SHADOW argument,
1986 GCN_DEBUG ("Released kernel dispatch: %p\n", shadow);
2002 /* Extract the properties from a kernel binary. */
2005 init_kernel_properties (struct kernel_info *kernel)
2008 struct agent_info *agent = kernel->agent;
2011 kernel->name, agent->id,
2015 hsa_warn ("Could not find symbol for kernel in the code object", status);
2016 fprintf (stderr, "not found name: '%s'\n", kernel->name);
2020 GCN_DEBUG ("Located kernel %s\n", kernel->name);
2022 (kernel_symbol, HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_OBJECT, &kernel->object);
2024 hsa_fatal ("Could not extract a kernel object from its symbol", status);
2027 &kernel->kernarg_segment_size);
2029 hsa_fatal ("Could not get info about kernel argument size", status);
2032 &kernel->group_segment_size);
2034 hsa_fatal ("Could not get info about kernel group segment size", status);
2037 &kernel->private_segment_size);
2039 hsa_fatal ("Could not get info about kernel private segment size",
2042 /* The kernel type is not known until something tries to launch it. */
2043 kernel->kind = KIND_UNKNOWN;
2046 "following segment sizes: \n", kernel->name);
2048 (unsigned) kernel->group_segment_size);
2050 (unsigned) kernel->private_segment_size);
2052 (unsigned) kernel->kernarg_segment_size);
2056 kernel->initialization_failed = true;
2064 init_kernel (struct kernel_info *kernel)
2066 if (pthread_mutex_lock (&kernel->init_mutex))
2067 GOMP_PLUGIN_fatal ("Could not lock a GCN kernel initialization mutex");
2068 if (kernel->initialized)
2070 if (pthread_mutex_unlock (&kernel->init_mutex))
2071 GOMP_PLUGIN_fatal ("Could not unlock a GCN kernel initialization "
2077 init_kernel_properties (kernel);
2079 if (!kernel->initialization_failed)
2083 kernel->initialized = true;
2085 if (pthread_mutex_unlock (&kernel->init_mutex))
2086 GOMP_PLUGIN_fatal ("Could not unlock a GCN kernel initialization "
2098 run_kernel (struct kernel_info *kernel, void *vars,
2102 GCN_DEBUG ("SGPRs: %d, VGPRs: %d\n", kernel->description->sgpr_count,
2103 kernel->description->vpgr_count);
2107 if (kla->ndim == 3 && kernel->description->vpgr_count > 0)
2109 int granulated_vgprs = (kernel->description->vpgr_count + 3) & ~3;
2120 GCN_DEBUG ("GCN launch on queue: %d:%d\n", kernel->agent->device_id,
2147 struct agent_info *agent = kernel->agent;
2154 if (!kernel->initialized)
2155 GOMP_PLUGIN_fatal ("Called kernel must be initialized");
2157 hsa_queue_t *command_q = (aq ? aq->hsa_queue : kernel->agent->sync_queue);
2170 int override_x = kernel->kind == KIND_UNKNOWN ? 0 : override_x_dim;
2171 int override_z = kernel->kind == KIND_UNKNOWN ? 0 : override_z_dim;
2219 = create_kernel_dispatch (kernel, packet->grid_size_x);
2228 packet->private_segment_size = kernel->private_segment_size;
2229 packet->group_segment_size = kernel->group_segment_size;
2230 packet->kernel_object = kernel->object;
2238 GCN_DEBUG ("Copying kernel runtime pointer to kernarg_address\n");
2245 GCN_DEBUG ("Going to dispatch kernel %s on device %d\n", kernel->name,
2262 console_output (kernel, shadow->kernarg_address, false);
2264 console_output (kernel, shadow->kernarg_address, true);
2281 GOMP_PLUGIN_error ("Possible kernel exit value corruption, 2 most"
2313 init_basic_kernel_info (struct kernel_info *kernel,
2318 kernel->agent = agent;
2319 kernel->module = module;
2320 kernel->name = d->name;
2321 kernel->description = d;
2322 if (pthread_mutex_init (&kernel->init_mutex, NULL))
2324 GOMP_PLUGIN_error ("Failed to initialize a GCN kernel mutex");
2358 /* Find the kernel function in ELF, and calculate actual load offset. */
2721 GOMP_PLUGIN_error ("Failed to destroy a GCN kernel initialization "
2745 run_kernel (entry->u.launch.kernel,
2903 /* Request an asynchronous kernel launch on the specified queue. This
2905 kernel to run. */
2908 queue_push_launch (struct goacc_asyncqueue *aq, struct kernel_info *kernel,
2911 assert (aq->agent == kernel->agent);
2924 aq->queue[queue_last].u.launch.kernel = kernel;
3217 /* Execute an OpenACC kernel, synchronously or asynchronously. */
3220 gcn_exec (struct kernel_info *kernel, size_t mapnum, void **hostaddrs,
3224 if (!GOMP_OFFLOAD_can_run (kernel))
3227 /* If we get here then this must be an OpenACC kernel. */
3228 kernel->kind = KIND_OPENACC;
3231 void **ind_da = alloc_by_agent (kernel->agent, sizeof (void*) * mapnum);
3238 for (unsigned i = 0; i < kernel->module->image_desc->kernel_count; i++)
3241 = &kernel->module->image_desc->kernel_infos[i];
3242 if (d->name == kernel->name)
3250 hsa_kernel_desc->oacc_dims[] or dimensions passed to this offload kernel
3267 if (dims[0] == 0) dims[0] = get_cu_count (kernel->agent); /* Gangs. */
3317 = (char *) kernel->name;
3330 run_kernel (kernel, ind_da, &kla, NULL, false);
3335 queue_push_launch (aq, kernel, ind_da, &kla);
3483 GOMP_PLUGIN_error ("Could not find suitable memory region for kernel "
3487 GCN_DEBUG ("Selected kernel arguments memory region:\n");
3513 TARGET_DATA and return references to kernel descriptors in TARGET_TABLE.
3532 struct kernel_info *kernel;
3562 kernel = &module->kernels[0];
3564 /* Allocate memory for kernel dependencies. */
3568 if (!init_basic_kernel_info (kernel, d, agent, module))
3571 module->init_array_func = kernel;
3573 module->fini_array_func = kernel;
3576 pair->start = (uintptr_t) kernel;
3577 pair->end = (uintptr_t) (kernel + 1);
3580 kernel++;
3766 struct kernel_info *kernel = (struct kernel_info *) fn_ptr;
3768 init_kernel (kernel);
3769 if (kernel->initialization_failed)
3886 /* Run a synchronous OpenMP kernel on DEVICE and pass it an array of pointers
3887 in VARS as a parameter. The kernel is identified by FN_PTR which must point
3895 struct kernel_info *kernel = (struct kernel_info *) fn_ptr;
3898 assert (agent == kernel->agent);
3900 /* If we get here then the kernel must be OpenMP. */
3901 kernel->kind = KIND_OPENMP;
3905 GCN_WARNING ("Will not run GCN kernel because the grid size is zero\n");
3908 run_kernel (kernel, vars, kla, NULL, false);
3911 /* Run an asynchronous OpenMP kernel on DEVICE. This is similar to
3921 struct kernel_info *kernel = (struct kernel_info *) tgt_fn;
3924 assert (agent == kernel->agent);
3926 /* If we get here then the kernel must be OpenMP. */
3927 kernel->kind = KIND_OPENMP;
3931 GCN_WARNING ("Will not run GCN kernel because the grid size is zero\n");
3936 queue_push_launch (agent->omp_async_queue, kernel, tgt_vars, kla);
3944 /* Run a synchronous OpenACC kernel. The device number is inferred from the
3952 struct kernel_info *kernel = (struct kernel_info *) fn_ptr;
3954 gcn_exec (kernel, mapnum, hostaddrs, devaddrs, dims, targ_mem_desc, false,
3958 /* Run an asynchronous OpenACC kernel on the specified queue. */
3966 struct kernel_info *kernel = (struct kernel_info *) fn_ptr;
3968 gcn_exec (kernel, mapnum, hostaddrs, devaddrs, dims, targ_mem_desc, true,
4145 the asynchronous kernel and when it is executed will not be seen.