Lines Matching refs:kernel

141 /* Structure describing the run-time and grid properties of an HSA kernel
154 /* Collection of information needed for a dispatch of a kernel from a
155 kernel. */
159 /* Pointer to a command queue associated with a kernel dispatch agent. */
163 /* Pointer to a memory space used for kernel arguments passing. */
173 /* Number of children kernel dispatches. */
179 /* Kernel dispatch structures created for children kernel dispatches. */
352 /* Information required to identify, finalize and run any given kernel. */
356 /* Name of the kernel, required to locate it within the brig module. */
360 /* The specific agent the kernel has been or will be finalized for and run
363 /* The specific module where the kernel takes place. */
365 /* Mutex enforcing that at most once thread ever initializes a kernel for
369 /* Flag indicating whether the kernel has been initialized and all fields
372 /* Flag indicating that the kernel has a problem that blocks an execution. */
376 /* Required size of kernel arguments. */
382 /* List of all kernel dependencies. */
386 /* Maximum OMP data size necessary for kernel from kernel dispatches. */
388 /* True if the kernel is gridified. */
403 /* An array of kernel_info structures describing each kernel in this
429 /* Kernel from kernel dispatch command queue. */
431 /* The HSA memory region from which to allocate kernel arguments. */
436 locked for reading while a kernel is being run, and for writing if the
440 kernel. */
524 /* Find kernel for an AGENT by name provided in KERNEL_NAME. */
757 return hsa_error ("Error creating kernel dispatch command queue", status);
765 GOMP_PLUGIN_error ("Could not find suitable memory region for kernel "
771 HSA_DEBUG ("HSA agent initialized, kernel dispatch queue has id %llu\n",
858 init_basic_kernel_info (struct kernel_info *kernel,
863 kernel->agent = agent;
864 kernel->module = module;
865 kernel->name = d->name;
866 kernel->omp_data_size = d->omp_data_size;
867 kernel->gridified_kernel_p = d->gridified_kernel_p;
868 kernel->dependencies_count = d->kernel_dependencies_count;
869 kernel->dependencies = d->kernel_dependencies;
870 if (pthread_mutex_init (&kernel->init_mutex, NULL))
872 GOMP_PLUGIN_error ("Failed to initialize an HSA kernel mutex");
879 brig_image_desc in TARGET_DATA and return references to kernel descriptors
898 struct kernel_info *kernel;
923 kernel = &module->kernels[0];
925 /* Allocate memory for kernel dependencies. */
928 pair->start = (uintptr_t) kernel;
929 pair->end = (uintptr_t) (kernel + 1);
932 if (!init_basic_kernel_info (kernel, d, agent, module))
934 kernel++;
1122 /* Create kernel dispatch data structure for given KERNEL. */
1125 create_single_kernel_dispatch (struct kernel_info *kernel,
1128 struct agent_info *agent = kernel->agent;
1135 unsigned dispatch_count = kernel->dependencies_count;
1141 shadow->object = kernel->object;
1149 shadow->private_segment_size = kernel->private_segment_size;
1150 shadow->group_segment_size = kernel->group_segment_size;
1154 kernel->kernarg_segment_size,
1157 hsa_fatal ("Could not allocate memory for HSA kernel arguments", status);
1162 /* Release data structure created for a kernel dispatch in SHADOW argument. */
1167 HSA_DEBUG ("Released kernel dispatch: %p has value: %" PRIu64 " (%p)\n",
1190 init_single_kernel (struct kernel_info *kernel, unsigned *max_omp_data_size)
1193 struct agent_info *agent = kernel->agent;
1196 kernel->name, agent->id,
1200 hsa_warn ("Could not find symbol for kernel in the code object", status);
1203 HSA_DEBUG ("Located kernel %s\n", kernel->name);
1205 (kernel_symbol, HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_OBJECT, &kernel->object);
1207 hsa_fatal ("Could not extract a kernel object from its symbol", status);
1210 &kernel->kernarg_segment_size);
1212 hsa_fatal ("Could not get info about kernel argument size", status);
1215 &kernel->group_segment_size);
1217 hsa_fatal ("Could not get info about kernel group segment size", status);
1220 &kernel->private_segment_size);
1222 hsa_fatal ("Could not get info about kernel private segment size",
1226 "following segment sizes: \n", kernel->name);
1228 (unsigned) kernel->group_segment_size);
1230 (unsigned) kernel->private_segment_size);
1232 (unsigned) kernel->kernarg_segment_size);
1233 HSA_DEBUG (" omp_data_size: %u\n", kernel->omp_data_size);
1234 HSA_DEBUG (" gridified_kernel_p: %u\n", kernel->gridified_kernel_p);
1236 if (kernel->omp_data_size > *max_omp_data_size)
1237 *max_omp_data_size = kernel->omp_data_size;
1239 for (unsigned i = 0; i < kernel->dependencies_count; i++)
1242 = get_kernel_for_agent (agent, kernel->dependencies[i]);
1246 HSA_DEBUG ("Could not find a dependency for a kernel: %s, "
1247 "dependency name: %s\n", kernel->name,
1248 kernel->dependencies[i]);
1254 HSA_DEBUG ("HSA does not allow kernel dispatching code with "
1265 kernel->initialization_failed = true;
1276 /* Dump kernel DISPATCH data structure and indent it by INDENT spaces. */
1311 /* Create kernel dispatch data structure for a KERNEL and all its
1315 create_kernel_dispatch (struct kernel_info *kernel, unsigned omp_data_size)
1318 = create_single_kernel_dispatch (kernel, omp_data_size);
1321 shadow->omp_level = kernel->gridified_kernel_p ? 1 : 0;
1323 /* Create kernel dispatch data structures. We do not allow to have
1324 a kernel dispatch with depth bigger than one. */
1325 for (unsigned i = 0; i < kernel->dependencies_count; i++)
1328 = get_kernel_for_agent (kernel->agent, kernel->dependencies[i]);
1332 = kernel->agent->kernel_dispatch_command_q;
1344 init_kernel (struct kernel_info *kernel)
1346 if (pthread_mutex_lock (&kernel->init_mutex))
1347 GOMP_PLUGIN_fatal ("Could not lock an HSA kernel initialization mutex");
1348 if (kernel->initialized)
1350 if (pthread_mutex_unlock (&kernel->init_mutex))
1351 GOMP_PLUGIN_fatal ("Could not unlock an HSA kernel initialization "
1357 /* Precomputed maximum size of OMP data necessary for a kernel from kernel
1359 init_single_kernel (kernel, &kernel->max_omp_data_size);
1361 if (!kernel->initialization_failed)
1364 kernel->initialized = true;
1365 if (pthread_mutex_unlock (&kernel->init_mutex))
1366 GOMP_PLUGIN_fatal ("Could not unlock an HSA kernel initialization "
1459 struct kernel_info *kernel = (struct kernel_info *) fn_ptr;
1460 struct agent_info *agent = kernel->agent;
1466 init_kernel (kernel);
1467 if (kernel->initialization_failed)
1491 run_kernel (struct kernel_info *kernel, void *vars,
1494 struct agent_info *agent = kernel->agent;
1501 if (!kernel->initialized)
1502 GOMP_PLUGIN_fatal ("Called kernel must be initialized");
1505 = create_kernel_dispatch (kernel, kernel->max_omp_data_size);
1555 packet->private_segment_size = kernel->private_segment_size;
1556 packet->group_segment_size = kernel->group_segment_size;
1557 packet->kernel_object = kernel->object;
1567 if (kernel->kernarg_segment_size > vars_size)
1569 if (kernel->kernarg_segment_size != vars_size
1576 HSA_DEBUG ("Copying kernel runtime pointer to kernarg_address\n");
1583 HSA_DEBUG ("Going to dispatch kernel %s\n", kernel->name);
1619 /* Part of the libgomp plugin interface. Run a kernel on device N (the number
1621 device) and pass it an array of pointers in VARS as a parameter. The kernel
1628 struct kernel_info *kernel = (struct kernel_info *) fn_ptr;
1633 HSA_DEBUG ("Will not run HSA kernel because the grid size is zero\n");
1636 run_kernel (kernel, vars, kla);
1639 /* Information to be passed to a thread running a kernel asycnronously. */
1650 /* Thread routine to run a kernel asynchronously. */
1668 /* Part of the libgomp plugin interface. Run a kernel like GOMP_OFFLOAD_run
1693 GOMP_PLUGIN_fatal ("Failed to detach a thread to run HSA kernel "
1707 GOMP_PLUGIN_error ("Failed to destroy an HSA kernel initialization "
1803 return hsa_error ("Error destroying kernel dispatch command queue", status);