@@ -1,3 +1,9 @@
+2014-10-24 Martin Jambor <mjambor@suse.cz>
+
+ * README.hsa: Removed the part about extracting the HSA ELF sections.
+ * hsa-gen.c (wrap_hsa): Deduce the file name and pass it to libgomp.
+
+
2014-10-24 Martin Jambor <mjambor@suse.cz>
* hsa.h (hsa_symbol): Renamed offset to directive_offset. Updated all
@@ -65,8 +65,8 @@ have not tested anything else):
$ git clone 'https://github.com/HSAFoundation/Okra-Interface-to-HSA-Device'
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/testhsa/Okra-Interface-to-HSA-Device/okra/dist/bin
- These and the steps below were tested with revision 4c4dc65 from
- August 14 2014.
+ These and the steps below were tested with revision d457e8c from
+ October 6 2014.
You can now also try the sample check shipped with OKRA to test
whether your setup works. Go into directory
@@ -135,19 +135,21 @@ example, however, it reports success like this:
omp_veccopy.c:15:12: note: Parallel construct will be turned into an HSA kernel
-The next step is to extract the HSA ELF sections to a 32-bit file
-called hsakernel.o. OKRA currently handles 32-bit ELF files only.
-This step is currently necessary but there is ongoing work aimed at
-eliminating it (yes, it means that currently there is no way of
-combining HSA from different compilation units):
-
- $ objcopy -O elf32-i386 -j hsa_data -j hsa_code -j hsa_operand omp_veccopy.o hsakernel.o
-
Now link the program as usual, providing a path to libgomp of the
installed hsa branch gcc:
$ $HOME/gcc/hsa/inst/bin/gcc omp_veccopy.o -lm -fopenmp -Wl,-rpath,$HOME/gcc/hsa/inst/lib64 -o omp_veccopy
+The reason why it is necessary to proceed in two steps rather than do
+both at once is that at this point, HSA run time will expect the HSA
+kernel in object file with the same name as the input file, only with
+the suffix changed to .o, in the current working directory when
+executing the program. If you use LTO, there is no input file (such
+as when compiling from standard input) or the input file name does not
+have a dot in it, run-time will expect the HSA ELF sections in a file
+called hsakernel.o. This is a temporary situation and will be fixed,
+of course.
+
Assuming you have all necessary libraries in your LD_LIBRARY_PATH, you
can now run the example:
@@ -2102,8 +2102,25 @@ wrap_hsa (void)
str = build_string_literal (1, "");
bool kern_p = lookup_attribute ("hsakernel",
DECL_ATTRIBUTES (fndecl));
+ if (!in_lto_p && main_input_filename)
+ {
+ char *filename;
+ const char *part = strrchr (main_input_filename, '/');
+ if (!part)
+ part = main_input_filename;
+ asprintf (&filename, "%s", part);
+ char* extension = strchr (filename, '.');
+ if (extension)
+ {
+ strcpy (extension, "\0");
+ asprintf (&extension, "%s", ".o\0");
+ strcat (filename, extension);
+ str = build_string_literal (strlen(filename)+1,filename);
+ }
+ }
CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, str);
+
int slen = IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (fndecl));
if (asprintf (&tmpname, "&%s",
IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl))) < 0)
@@ -1,3 +1,8 @@
+2014-10-24 Martin Jambor <mjambor@suse.cz>
+
+ * hsaokra.c (__hsa_launch_kernel): Do not segfault if file cannot be
+ opened.
+
2014-09-26 Saravanan Ekanathan <saravanan.ekanathan@amd.com>
* hsaokra.c (__hsa_launch_kernel): Use BRIG generated by
@@ -129,6 +129,11 @@ __hsa_launch_kernel (__hsa_kernel_desc * _kd, __hsa_launch_range *range_p,
if (_kd->filename[0] == 0)
fileName = "hsakernel.o";
pfile = (const char *) fopen (fileName, "rb");
+ if (!pfile)
+ {
+ fprintf (stderr, "Unable to open file %s\n", fileName);
+ return NULL;
+ }
status = _okra_kernel_create_from_binary(context, pfile, size, _kd->name, &kernel);
fclose((FILE *)pfile);
if (status != OKRA_SUCCESS)