Passing -D defines to PET

7 views
Skip to first unread message

Emil Vatai

unread,
Oct 22, 2025, 11:32:39 PMOct 22
to isl Development
Hi!

TLDR: How do I set `-DMINI_DATASET`  within C code (i.e. not via commandline arg, because I'm in a lib, not an exe)?  

--

What is the easiest way to get PET to see defines (i.e. -D option). I tried setting CFLAGS=-D... (because this trick works with C_INCLUDE_PATH) but no luck (PET still assumes the default LARGE_DATASET for polybench even tho I want MINI).

I see that `pet_options` has defines/n_define members (and I guess this is what I'm looking for), but how do I set them? 

I see a possible solution in pet_loopback.c: 
- create a custom `options` type with macros (in loopback.c it is a struct for ISL and PET options) and 
- then `parse()` with argc/argv, which I could abuse by passing it custom arrays instead of argv (because I specify defines in Python, which calls functions in an .so file where the isl_ctx is created).

However, this solution feels too convoluted. Is there a better alternative? 
I tried creating a pet_options* object manually, but I get an error when I try to access its members. As I understand the error message, the struct body/implementation is not being exposed by #include <pet.h>.

Best,
E

Sven Verdoolaege

unread,
Oct 23, 2025, 12:28:46 PMOct 23
to Emil Vatai, isl Development
On Wed, Oct 22, 2025 at 08:32:38PM -0700, Emil Vatai wrote:
> Hi!
>
> TLDR: How do I set `-DMINI_DATASET` within C code (i.e. not via
> commandline arg, because I'm in a lib, not an exe)?

There doesn't appear to be a way to set those options yet.
I'll work on something.

skimo

Sven Verdoolaege

unread,
Oct 26, 2025, 5:40:38 PM (13 days ago) Oct 26
to Emil Vatai, isl Development
How about something like this?

diff --git a/include/pet.h b/include/pet.h
index ec5b754..f8ede98 100644
--- a/include/pet.h
+++ b/include/pet.h
@@ -44,6 +44,8 @@ int pet_options_get_encapsulate_dynamic_control(isl_ctx *ctx);
int pet_options_set_signed_overflow(isl_ctx *ctx, int val);
int pet_options_get_signed_overflow(isl_ctx *ctx);

+isl_stat pet_options_append_defines(isl_ctx *ctx, const char *val);
+
struct pet_loc;
typedef struct pet_loc pet_loc;

diff --git a/options.c b/options.c
index 39525ad..272a19d 100644
--- a/options.c
+++ b/options.c
@@ -84,6 +84,9 @@ ISL_CTX_SET_CHOICE_DEF(pet_options, struct pet_options, pet_options_args,
ISL_CTX_GET_CHOICE_DEF(pet_options, struct pet_options, pet_options_args,
signed_overflow)

+ISL_CTX_APPEND_STR_LIST_DEF(pet_options, struct pet_options, pet_options_args,
+ n_define, defines)
+
/* Create an isl_ctx that references the pet options.
*/
isl_ctx *isl_ctx_alloc_with_pet_options()

The required changes to isl are in attachment.

skimo
diff

Emil Vatai

unread,
Oct 29, 2025, 5:42:52 AM (10 days ago) Oct 29
to sven.ver...@gmail.com, isl Development
Dear skimo,

Yes. Thanks! Works like a charm!

Any chance to get this into official repos?

Also is it possible to also add the below diff to PET?

I sent a message to the ml some time ago, PET does not install the pkgconfig files. I don't think it should break anything.

Best,E

diff --git a/Makefile.am b/Makefile.am
index 56cb1fa..a924412 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -176,5 +176,8 @@ dist-hook: isl.py
  cp $< $(distdir)/
  echo @GIT_HEAD_VERSION@ > $(distdir)/GIT_HEAD_ID
 
+pkgconfigdir=$(pkgconfig_libdir)
+pkgconfig_DATA = $(pkgconfig_libfile)
+
 gitversion.h: @GIT_HEAD@
  $(AM_V_GEN)echo '#define GIT_HEAD_ID "'@GIT_HEAD_VERSION@'"' > $@

--
Emil Vatai

Sven Verdoolaege

unread,
Oct 30, 2025, 7:03:52 PM (8 days ago) Oct 30
to Emil Vatai, isl Development
On Wed, Oct 29, 2025 at 06:42:35PM +0900, Emil Vatai wrote:
> Dear skimo,
>
> Yes. Thanks! Works like a charm!
>
> Any chance to get this into official repos?

Done.

skimo

Emil Vatai

unread,
Oct 30, 2025, 10:40:17 PM (8 days ago) Oct 30
to sven.ver...@gmail.com, isl Development
The pkgconfig stuff is somehow still not there :'-)


Best,
E
--
Emil Vatai
Reply all
Reply to author
Forward
0 new messages